<< Click to Display Table of Contents >> Raynet One > 1.1 > User Guide > Technical overview > Custom inventory scripting > CSM inventory scripting Use case: internet connectivity test |
In large organizations, many IP network routing rules can complicate the IT landscape network traffic. To verify correct access to cloud services and resources, verifying the connection to important endpoints could be a good idea. Increase the stability of your device networks with factual evidence in an uncontrollably evolving IT world.
In this use-case, the general internet connectivity is tested by connecting to the device identified by the google.com hostname.
<CustomScriptSet Name="InternetConnectivityTest" Version="1">
<CustomScript Name="InternetConnectivityTest1">
<Command Name="value">if ping -c 1 google.com > /dev/null; then echo Yes; else echo No; fi</Command>
<Item Name="InternetConnectivity" Class="InternetConnectivity" ItemName="InternetConnectivity">
<Property Name="IsConnected" Value="$(value)" />
</Item>
</CustomScript>
</CustomScriptSet>
This program is the common CSM form of executing a single device command and creating an inventory object based on the single command's output. This form is restricted to the preliminary device command list. It is a very simple form.
Inside of the device command on line 3 shell conditional logic is used. This is done to differentiate between devices able to connect to the domain google.com and not. If a device is unable to, the script assigns the parameter IsConnected=No to the device. Otherwise, it assigns the parameter IsConnected=Yes.