Page 1 of 1
Monitoring Cluster Shared Volumes
Posted: Fri Apr 12, 2013 4:46 pm
by kiddbios
Hello,
We use Hyper-V 2012 for our virtualization platform. One of the features of Hyper-V in a clustered environment is the use of Cluster Shared Volumes, which are essentially mount points that all of the servers in the cluster can read and write to, but they can only hold Hyper-V data. The CSVs do not have a drive letter assigned to them. We had an issue recently where a CSV became full and this caused all the VMs hosted on that volume to stop. Is there a way to monitor CSVs with Nagios XI?
Re: Monitoring Cluster Shared Volumes
Posted: Fri Apr 12, 2013 4:55 pm
by abrist
There are plugins on the exchange for checking hyper-v systems, though none of the look like they are for CSV storage. Have you considered using snmp or writing a powershell script?
http://exchange.nagios.org/directory/Pl ... ce/details
http://exchange.nagios.org/directory/Pl ... th/details
http://powershellcommunity.org/Forums/t ... fault.aspx
Re: Monitoring Cluster Shared Volumes
Posted: Thu Apr 18, 2013 5:10 pm
by kiddbios
We have created the powershell script and confirmed that it works from the host, but we are unable to execute it via Nagios. We're using the following command:
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c check_csv
This has been added to the nsclient.ini file
check_csv=cmd /c echo scripts/check_csv.ps1; exit $LastExitCode | powershell.exe -Command -
This is the error we're getting:
COMMAND: /usr/local/nagios/libexec/check_nrpe -H 192.168.1.50 -t 30 -c check_csv
OUTPUT: No handler for command: cmd
Re: Monitoring Cluster Shared Volumes
Posted: Thu Apr 18, 2013 5:51 pm
by kiddbios
OK, we got all the script and NRPE parameters working properly. We can run the test from within the CCM (it prompts for a hostname) and we can also successfully run the test directly from the command line on the XI box itself. The issue we're having now is that as soon as we try to add any host or hostgroup to the service in the CCM, we get an error that the config cannot be applied. Looking at the config debug it just says there is an error on line 14.
Any help is greatly appreciated.
Re: Monitoring Cluster Shared Volumes
Posted: Thu Apr 18, 2013 9:10 pm
by sreinhardt
Could you post your error from applying configuration, as well as the check command you created please?
edit: more of the error than just line 14, like what file it is errorring on and what is the object containing line 14.
Re: Monitoring Cluster Shared Volumes
Posted: Fri Apr 19, 2013 10:33 am
by kiddbios
We got it sorted. Had to do with the max attempts and what not.
Thanks,
Brad
Re: Monitoring Cluster Shared Volumes
Posted: Fri Apr 19, 2013 10:45 am
by kiddbios
For those of you who need it:
This is the powershell script. It monitors all of the CSVs connected to a windows cluster. Copy this into a text document, name it check_csv.ps1 and put it in the NSClient++ scripts directory (Typically c:\program files\nsclient++\scripts). The warning threshold level can be set in the 4th line of the code ($warninglevel = X).
#Load the FailoverClusters module
Import-Module FailoverClusters
$warninglevel = 15 # The percent to send warning at
$message = @()
$warning = @()
$critical = @()
$nl = [Environment]::NewLine
$csv_status = Get-ClusterSharedVolume
foreach ( $csv in $csv_status )
{
$expanded_csv_info = $csv | select -Property Name -ExpandProperty SharedVolumeInfo
foreach ( $csvinfo in $expanded_csv_info )
{
$obj = New-Object PSObject -Property @{
Name = $csvinfo.Name
Path = $csvinfo.FriendlyVolumeName
Size = $csvinfo.Partition.Size
FreeSpace = $csvinfo.Partition.FreeSpace
UsedSpace = $csvinfo.Partition.UsedSpace
PercentFree = $csvinfo.Partition.PercentFree
}
if ($csvinfo.Partition.PercentFree -lt $warninglevel)
{ $critical = 2}
elseif ($csvinfo.Partition.PercentFree -eq $warninglevel)
{ $warning = 1}
else
{ $message = 0}
}
}
#Write-Output $ToSend
if($critical -eq 2)
{
$ToSend = "CRITICAL -CSV Status is above threshold capacity "
Write-Host $ToSend
exit 2
}
elseif ($warning -eq 1)
{
$ToSend = "WARNING - CSV Status is at threshold capacity "
Write-Host $ToSend
exit 1
}
else
{
Write-Host "OK - CSV status is good"
exit 0
}
You will then need to edit the nsclient.ini (we are using the most current version of NSC++ as of April 19th, 2013) and add these lines:
[/settings/external scripts/wrappings]
bat = scripts\\%SCRIPT% %ARGS%
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
[/settings/external scripts/wrapped scripts]
check_csv = check_csv.ps1
[/settings/external scripts/alias]
alias_updates = check_csv -warning 0 -critical 0
[/settings/NRPE/server]
allowed hosts = (your monitoring host here)
allow arguments = true
allow nasty characters = true
port = 5666
timeout = 60
[/settings/external scripts]
allow arguments = 1
allow nasty characters = 1
timeout = 60
You will then need to create a command in XI. This is the command:
$USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -t 30 -c check_csv
After that create your service using that check. You don't need to put in any arguments, just be sure to set your max attempts, check intervals, etc. Add your host or hostgroup to the service and you'll be monitoring the space utilization on your CSV.
Re: Monitoring Cluster Shared Volumes
Posted: Fri Apr 19, 2013 12:59 pm
by abrist
Thanks for the added info. Locking thread.