I’m trying to use the check_disk
command with custom partition thresholds in a single service. To do this, I need Icinga to run the following check command:
/usr/lib/nagios/plugins/check_disk -w 5% -c 2% -p /srv/archives -w 10% -c 5%
In this example, the /srv/archives
partition will be checked with 5% and 2% as warning/critical thresholds, and all other partitions will be checked with 10% and 5% as warning/critical thresholds.
To achieve this, and since I need to control the relative position of the arguments, I’m trying to add some arguments manually to the command
:
object CheckCommand "ee-disk" {
import "disk"
command = [ PluginDir + "/check_disk" ]
if (vars.disk_custom_partitions_thresholds) {
for (var item in vars.disk_custom_partitions_thresholds) {
if(item.warning_threshold) {
command += ["-w", item.warning_threshold]
}
if(item.critical_threshold) {
command += ["-c", item.critical_threshold]
}
command += ["-p", item.partition]
}
}
vars.disk_wfree = "10%"
vars.disk_cfree = "5%"
}
In my host definition:
object Host "test" {
vars.disk_custom_partitions_thresholds = [
{
partition = "/srv/archives"
warning_threshold = "5%"
critical_threshold = "2%"
}
]
}
However, this does not work, and Icinga still runs the command without my extra arguments. I know that this is not a traditional way to manage command arguments, but I don’t see another way to control the relative order of the arguments.
Note: My previous workaround for this issue was to define multiple services, but I hope to find a solution to achieve the same check with a single service.