Windows Nagios MPIO Path Plugin/Check

Recently I was installing and configuring a Fiber Channel SAN. The setup consisted of a NetApp E2760 with around 40TB of space, connected to some IBM Blades running Window Server 2012 R2 via redundant SAN controllers and brocade fabric switches. The resilient design enabled the servers to have a total of 4 8Gb FC paths to the storage.

I wanted to setup a check in Nagios to monitor the number of active paths so we would be alerted if any of the redundant cables/components failed. Below is very simply Powershell script that I wrote to do just that. The script returns a warning when a path is lost and a critical status when two or less paths are active. The script took around 10 minutes to write and was built to do one job, so it is simplistic. You could easily add improvements such as the use of arguments so the settings could be modified from the Nagios side.

I am guessing the script will work for MPIO iSCSI however I have not tested it.

# Name: MPIO Path Check 
# Version: 0.1 
# Author: Thomas Chubb 
# Date: 13/11/2015

# Clear host
Clear-Host

# Settings
$TotalPaths = 4
$WarningPaths = 3
$CriticalPaths = 2

# Get active MPIO paths
$PathCount = ((Get-WmiObject -Namespace root\wmi -Class MPIO_PATH_INFORMATION -ErrorAction SilentlyContinue).Pathlist | Measure-Object).Count
if (!$?){Write-Host "UNKNOWN - Error Querying WMI";Exit 3}

# Return results
switch ($PathCount){
    $TotalPaths              {Clear-Host;Write-Host "OK - All Paths Active ($PathCount/$TotalPaths)";Exit 0}
    0                        {Clear-Host;Write-Host "CRITICAL - No Active Paths Detected ($PathCount/$TotalPaths)";Exit 2}
    {$_ -le $CriticalPaths}  {Clear-Host;Write-Host "CRITICAL - Failed Path Detected ($PathCount/$TotalPaths)";Exit 2}
    {$_ -le $WarningPaths}   {Clear-Host;Write-Host "WARNING - Failed Path Detected ($PathCount/$TotalPaths)";Exit 1}
    default                  {Clear-Host;Write-Host "UNKNOWN - Error determining state";Exit 3}
}

MPIO_Path_Check_0.1

This entry was posted in Server and tagged , , . Bookmark the permalink.