Among the many possible services to monitor a Windows based operating system using Icinga2, the service that utilizes the check_command of disk-windows has not quite worked as expected. It may have been a combination of things that was done incorrectly over the years, or maybe plugin versioning. In any case, a snippet below demonstrates a thought to be working service for use with Icinga2.
The goal of this services is to check the C: drive and present a warning at 20% free and a critical at 10% free. This, however, was not happening.
apply Service "Disk C" {
import "generic-service"
check_command = "disk-windows"
vars.disk_win_path = "C:"
vars.disk_wfree = "20%"
vars.disk_cfree = "10%"
command_endpoint = host.vars.client_endpoint
assign where host.vars.os == "Windows"
}
A Windows server was discovered within the values to trigger a warning. A warning was never issued, only the OK status. After further reading and testing, I determined the cause of this. The values of vars.disk_wfree and vars.disk_cfree are for the Linux check command not the Windows check command. The correct values are vars.disk_win_warn and vars.disk_win_crit. The corrected snippet with the replaced values is this.
apply Service "Disk C" {
import "generic-service"
check_command = "disk-windows"
vars.disk_win_path = "C:"
vars.disk_win_warn = "20%"
vars.disk_win_crit = "10%"
command_endpoint = host.vars.client_endpoint
assign where host.vars.os == "Windows"
}
The predefined values are obtained from %programfiles%\ICINGA2\share\icinga2\include\command-plugins-windows.conf located on the Windows client. Here is a snippet of that file.
object CheckCommand "disk-windows" {
command = [ PluginDir + "/check_disk.exe" ]
arguments = {
"-w" = {
value = "$disk_win_warn$"
description = "Warning threshold"
}
"-c" = {
value = "$disk_win_crit$"
description = "Critical threshold"
}
"-p" = {
value = "$disk_win_path$"
description = "Optional paths to check"
repeat_key = true
}
"-u" = {
value = "$disk_win_unit$"
description = "Use this unit to display disk space"
}
"-x" = {
value = "$disk_win_exclude$"
description = "Exclude these drives from check"
}
}
vars.disk_win_unit = "mb"
//The default
}
Hope this helps someone else.