Icinga2 -Disk notification only for Critical Drive

I have been using the following service block to check all Disks on windows systems.

apply Service "disks" {
  check_command = "disk"
  vars.disk_wfree = "20%"
  vars.disk_cfree = "10%"
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

but we are getting notifications as shown below…

disks on ********************* is CRITICAL!

Info: DISK CRITICAL - free space:C:\ 69691 MB (40%); C:\ClusterStorage\Volume1\ 292986 MB (48%); C:\ClusterStorage\Volume2\ 285726 MB (37%); C:\ClusterStorage\Volume3\ 296919 MB (2%); C:\ClusterStorage\Volume4\ 511695 MB (100%); C:\ClusterStorage\Volume5\ 511695 MB (100%); C:\ClusterStorage\Volume6\ 270431 MB (88%); C:\ClusterStorage\Volume7\ 20962304 MB (100%); D:\ 114482 MB (8%); F:\ 9760 MB (95%); S:\ 324346 MB (63%);

I have been trying to understand how can i send out notification only for critical drives instead of notifying all the information…

& i am trying to define specific threshold to each drive… currently i have defined 20% free as warning & 10% free as critical…

Can you please someone help on this?

Hello
If you want to get notification on specific drives, you need ti change the check to test the specific drive.
By default the plugin, if not specific disk is defined, will check all available partitions ( disks) and will report back on all of them regardless of status.

If one of them answer the criteria of the thresholds, then it will send the notification, but with the information on all the disks in the data accompanying the notification.

Regards

Assaf,

Thanks for your response…

So with disk command we have the possibility to check the one specific drive?

Previously i tried the service check as shown below…

apply Service "Disk C" {
 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.client_endpoint && host.vars.os == "Windows"
}

I can define the service checks for specific drives. But the problem there are bunch of windows servers with drive K, M & N where other servers have doesn’t…

I would like to understand how can we handle this? Any help that i can get here? …

thanks in advance

Hi

You can create a template with the check for the K,M & N and add the hosts that have those drives to a host group and then use an assign rule to apply those checks to the hostgroup.

Regards

Thanks again… looks like its long process… We have around 200-300 windows… every server has different drives lots of servers doesn’t have D drive or any other drive… Every server has different number of drives…

looks like i need to do analysis what kind of drives that are available for all servers… Based on those i need to create hostgroups & need to make apply rules? or any other simpler process like service checks query the list of drives on server & if any drive has issues it should notify something like that?

Sorry if this is not possible at all… Can you please advise on this? thanks in advance

Hm… IMAO you don’t even need hostgroups here.

object Host "example.com" {
  vars.os = "Windows"
  vars.disks = [ "C", "D" ]
}

apply Service "Disk " for (disk in host.vars.disks) {
  assign where host.vars.os == "Windows"
  vars.disk_win_path = disk + ":"
}

Hello

so basically if I understand you correctly monitoring all drives vom A-Z is your intention with lets say warning on 20% free and critical on 10% free - correct?

You do how ever want to only add the drives inside your notification that are “bad” instead of adding all 10 drives (C-L) for example - correct?

If so, you might want to have a look on the Icinga for Windows solution: https://icinga.com/docs/windows/latest/

By default, checks will only output the values with an error instead of everything. Example:

powershell -C { Use-Icinga; Invoke-IcingaCheckUsedPartitionSpace -Warning 80 -Critical 90; }

Output:

[WARNING] Check package "Used Partition Space" - [WARNING] Partition G, Used Space Partition G
\_ [WARNING] Partition G: Value "89.21%" is greater than threshold "80%"
| 'partition_c'=51.15%;80;90;0;100 'partition_g'=89.21%;80;90;0;100 'used_space_partition_r'=2.05TB;2.91;3.27;0;3.64 'used_space_partition_g'=1.62TB;1.46;1.64;0;1.82 'used_space_partition_c'=476.19GB;744.71;837.79;0;930.88 'partition_r'=56.36%;80;90;0;100

You can also add a verbosity flag to output everything:

powershell -C { Use-Icinga; Invoke-IcingaCheckUsedPartitionSpace -Warning 80 -Critical 90 -Verbosity 2; }

Output

[WARNING] Check package "Used Partition Space" (Match All) - [WARNING] Partition G, Used Space Partition G
\_ [OK] Partition C: 51.25%
\_ [WARNING] Partition G: Value "89.21%" is greater than threshold "80%"
\_ [OK] Partition R: 56.38%
| 'partition_c'=51.25%;80;90;0;100 'partition_g'=89.21%;80;90;0;100 'used_space_partition_r'=2.05TB;2.91;3.27;0;3.64 'used_space_partition_g'=1.62TB;1.46;1.64;0;1.82 'used_space_partition_c'=477.06GB;744.71;837.79;0;930.88 'partition_r'=56.38%;80;90;0;100

All disk drives are fetched automatically. Maybe this helps (at least I hope so :smiley: )

1 Like