Multiple Service Check
Another use for Variables is within the context of ‘Multiple Service Checks’. For example, if there is a Service Check that monitors the capacity of a hard drive it may take the following format:
check_disk -a %DISK%
.
By having the %DISK%
variable, this Service Check requires the Variable %DISK%
to be added to the Host and populated with the value field of %DISK%
containing the hard disk to be monitored. If the value was set to ‘C’, the Service Check, when executed, would read:
check_disk -a C
This is great if we just have one disk, but what if we have multiple? A ‘D:/’ drive? An ‘F:/’ drive? That would require administrators to create three separate Service Checks:
check_disk -a C
check_disk -a D
check_disk -a F
This defeats the purpose of Variables. Therefore, Opsview Monitor created the concept of ‘Multiple Service Checks’. This allows an administrator to create the Service Check below:
check_disk -a %DISK%
But unlike before, there is an option called ‘Multiple Service Checks:’. Within this dropdown box, an administrator can select a Variable, i.e. %DISK%
. By selecting %DISK%
, this tells Opsview Monitor to create a new Service Check for every %DISK%
variable added.
This means, that for every %DISK%
variable added to the Host, Opsview Monitor will create a new Service Check. This means the administrator needs to only create and add one Service Check, check_disk -a %DISK%
. The administrator then simply adds three variables of the DISK type, with the values C, D and F respectively.
On Submit Changes, the one Service Check will create three copies - one per variable. You will need to go to Configuration > Apply Changes to put this setup into production.
In Opsview Monitor, this looks like the screen below:
This next step assumes the Service Check is already added to the Host; either via the Hosts’ ‘Service Check’ tab or via a Host Template. Add the 3 variables and enter the values:
Once you have performed an Apply Changes from the Configuration menu, the one Service Check will be cloned three times, one per variable, as shown below: