This article’s script could be run on any Windows cluster that uses Cluster Shared Volumes. It is simple: it looks for the CSV that you specified, finds out its total space, finds out its free space, calculates the percentage, and returns an OK, warning, or critical status. In order to use this script, you must have a functioning Nagios environment and the NSClient++ software installed on each node in the cluster(s) to be monitored. You must also have placed the clusterbase.ps1 script as indicated in the cluster base script article. None of the Hyper-V scripts are required for this check script to operate.

If you’re new to Nagios you should definitely check out the article How To: Monitor Hyper-V with Nagios first, then move onto the cluster base script article linked about, and continue reading below.

Note: In the update to 1.2, the script has been altered to alert at the level of USED space as opposed to the level of FREE space. That brings its behavior more inline with similar checks by other authors. Upon updating to version 1.2, modify your checks accordingly. For example, you might be using “check-csvspace!CSV1!20!10” to warn at 20% remaining and report critical at 10% remaining; that same check will now be “check-csvspace!CSV1!80!90”.

NSClient++ Configuration

These changes are to be made to the NSClient++ files on all Hyper-V hosts to be monitored.


C:\Program Files\NSClient++\nsclient.ini

If the indicated INI section does not exist, create it. Otherwise, just add the second line to the existing section.

The NSClient++ service must be restarted after all changes to its ini file.


C:\Program Files\NSClient++\scripts\check_csvspace.ps1

The required script clusterbase.ps1 must exist in the same folder.


Nagios Configuration

These changes are to be made on the Nagios host. I recommend using WinSCP as outlined in our main Nagios and Ubuntu Server articles.

/usr/local/nagios/etc/objects/commands.cfg

The Hyper-V Host Commands section should already exist if you followed our main Nagios article. Add this command there. If you are not working with a Hyper-V system, then you can create any section heading that makes sense to you, or just insert the command wherever you like.

/usr/local/nagios/etc/objects/hypervhost.cfg

This file and section were created in the Hyper-V base scripts article. As long as it appears somewhere in one of the activated .cfg files, it will work.

This is a sample! You must use your own cluster name object!

Nagios must be restarted after these files are modified.