After reading a few other posts on the KB regarding requests for better monitoring for EMC SAN arrays, I took it upon myself to create something that provided the data I personally wanted to see about my SAN. This script requires naviseccli to be installed and configured on the same system where the probe is running from.
This is based on the modified version of another very basic script by WayneJesse that monitors the individual disks in the SAN and reports on their health. The original discussion is here:
https://kb.paessler.com/en/topic/26423-emc-storage-array
However, this has been modified very extensively. In addition to reporting on physical disks for health/failure/rebuilding, you can now also display the free space in all storage pools, and the free space/health of all LUNs.
############################################################################################### # PRTG EMC San InfoScript v1.0 # By Digitalhigh, 6/30/2016 ############################################################################################### <# .SYNOPSIS This is a custom PRTG script that will connect to NaviSecCli and enumerate system information for EMC Sans. This has been tested with an EMC VNX5400. .DESCRIPTION Use this to populate the PRTG Exe/Script Advanced Sensor with EMC SAN information. You can use this to display used capacity for all storage pools, used capacity for all LUNS, or status and count of physical disks. You can show one or all of these fields, which is useful if you'd like multiple sensors for the various values. There are a number of parameters that can be used to customize the data displayed, the parameters are described as follows. .PARAMETER h Specify the storage processor/SAN to connect to. You can use hostname, IP address, or pass the PRTG variable %host to use the value set in PRTG. .PARAMETER user Specify the username to use. Defaults to "sysadmin" if none specified. .PARAMETER password Specify the password to use. Defaults to "sysadmin" if none specified. .PARAMETER scope Specifies whether the user account on the storage system you want to log in to is local or global. A 0 (default) indicates global; a 1 indicates local. Defaults to 0 if none specified. .PARAMETER lunwarnlevel This value determines at what percentage of free space a warning will be issued for LUNs. Default is 25 percent. .PARAMETER lunerrorlevel This value determines at what percentage of free space an error will be issued for LUNs. Default is 10 percent. .PARAMETER poolwarnlevel This value determines at what percentage of free space a warning will be issued for storage pools. Default is 25 percent. .PARAMETER poolerrorlevel This value determines at what percentage of free space an error will be issued for storage pools. Default is 10 percent. .PARAMETER showpools Set this to 0 to hide pool data, 1 to display it. .PARAMETER showluns Set this to 0 to hide lun data, 1 to display it. .PARAMETER showdisks Set this to 0 to hide physical disk information, 1 to display it. #> param ( $h, [string]$user = "sysadmin", [string]$password = "sysadmin", [int]$scope = "0", [int]$lunwarnlevel = "25", [int]$lunerrorlevel = "10", [int]$poolwarnlevel = "25", [int]$poolerrorlevel = "10", [switch]$showpools, [switch]$showluns, [switch]$showdisks ) $Query2 = & "C:\Program Files (x86)\EMC\Navisphere CLI\NaviSECCli.exe" ""-h $h -User $user -Password $password -scope $scope storagepool -list -consumedcap -availablecap"" $Query = & "C:\Program Files (x86)\EMC\Navisphere CLI\NaviSECCli.exe" ""-h $h -User $user -Password $password -scope $scope getdisk -state"" $Query3 = & "C:\program files (x86)\EMC\Navisphere CLI\Naviseccli.exe" ""-h $h -User $user -password $password -scope $scope lun -list -userCap -consumedCap"" write-host "<prtg>" ############################################################################################### # Pool Info Display ############################################################################################### if ($showpools) { for ($i = 0; $i -lt $Query2.length; $i++) { if ([regex]::ismatch($Query2[$i],"Pool Name:")) { $PoolName = ($Query2[$i]).replace("Name: ","LUN ") $PoolCapacity = ($Query2[$i+3]).replace("Consumed Capacity (GBs): ","") $PoolUsed = ($Query2[$i+5]).replace("Available Capacity (GBs): ","") $PoolFree = [Math]::round((($PoolUsed/$PoolCapacity) * 100)) write-host " <result>" write-host " <channel>$PoolName Percent Free</channel>" write-host " <value>$PoolFree</value>" write-host " <unit>Percent</unit>" write-host " <LimitMode>1</LimitMode>" write-host " <LimitMinWarning>$poolwarnlevel</LimitMinWarning>" write-host " <LimitMinError>$poolerrorlevel</LimitMinError>" write-host " </result>" } } } ############################################################################################### # Disk Info Display ############################################################################################### if ($showdisks) { #Calculate the total number of disks $TotalDisks = (Select-String -InputObject $Query -Pattern "disk" -AllMatches).Matches.Count #Calculate the total number of Hot Spares $HotSpares = (Select-String -InputObject $Query -Pattern "hot" -AllMatches).Matches.Count #Calculate the number of disks in notable states $RebuildingDisks = (Select-String -InputObject $Query -Pattern "rebuilding|equalizing" -AllMatches).Matches.Count $FailedDisks = (Select-String -InputObject $Query -Pattern "failed|faulted|fault" -AllMatches).Matches.Count #PRTG service condition write-host " <result>" write-host " <channel>Total Disks</channel>" write-host " <customunit>Disk(s)</customunit>" write-host " <value>$TotalDisks</value>" write-host " <ShowTable>0</ShowTable>" write-host " <ShowChart>0</ShowChart>" write-host " </result>" write-host " <result>" write-host " <channel>Hot Spare Disks</channel>" write-host " <customunit>Disk(s)</customunit>" write-host " <value>$HotSpares</value>" write-host " <ShowTable>0</ShowTable>" write-host " <ShowChart>0</ShowChart>" write-host " </result>" If ($RebuildingDisks -gt 0) { write-host " <result>" write-host " <channel>Rebuilding Disks</channel>" write-host " <customunit>Disk(s)</customunit>" write-host " <value>$RebuildingDisks</value>" write-host " <ShowTable>0</ShowTable>" write-host " <ShowChart>0</ShowChart>" write-host " <warning>1</warning>" write-host " </result>" } ElseIf ($RebuildingDisks -eq 0) { write-host " <result>" write-host " <channel>Rebuilding Disks</channel>" write-host " <customunit>Disk(s)</customunit>" write-host " <ShowTable>0</ShowTable>" write-host " <ShowChart>0</ShowChart>" write-host " <value>0</value>" write-host " </result>" } If ($FailedDisks -gt 0) { write-host " <result>" write-host " <channel>Failed Disks</channel>" write-host " <customunit>Disk(s)</customunit>" write-host " <value>$FailedDisks</value>" write-host " <ShowChart>0</ShowChart>" write-host " <ShowTable>0</ShowTable>" write-host " </result>" } ElseIf ($FailedDisks -eq 0) { write-host " <result>" write-host " <channel>Failed Disks</channel>" write-host " <customunit>Disk(s)</customunit>" write-host " <ShowChart>0</ShowChart>" write-host " <value>0</value>" write-host " <ShowTable>0</ShowTable>" write-host " </result>" } } ############################################################################################### # Lun Info Display ############################################################################################### if ($showluns) { $LunCount = 0 for ($i = 0; $i -lt $Query3.length; $i++) { if ([regex]::ismatch($Query3[$i],"LOGICAL UNIT NUMBER")) { $LunCount += 1 } } #Display Total LUNS write-host " <result>" write-host " <channel>Total Luns</channel>" write-host " <value>$LunCount</value>" write-host " <ShowTable>0</ShowTable>" write-host " <ShowChart>0</ShowChart>" write-host " </result>" #Enumerate and show percentage for LUNS for ($i = 0; $i -lt $Query3.length; $i++) { if ([regex]::ismatch($Query3[$i],"LOGICAL UNIT NUMBER")) { $LunName = ($Query3[$i+1]).replace("Name: ","LUN ") $LunCapacity = ($Query3[$i+3]).replace("User Capacity (GBs): ","") $LunUsed = ($Query3[$i+5]).replace("Consumed Capacity (GBs): ","") $LunFree = [Math]::round((($LunUsed/$LunCapacity) * 100)) if ($LunFree -le 25 -and $LunFree -ge 11 -and !$Error) {$Warn=1} ElseIf ($LunFree -le 10 ) { $Error=1 $Warn=0 } if ($LunFree -le 100) { write-host " <result>" write-host " <channel>$LunName Percent Free</channel>" write-host " <value>$LunFree</value>" write-host " <unit>Percent</unit>" write-host " <LimitMode>1</LimitMode>" write-host " <LimitMinWarning>$lunwarnlevel</LimitMinWarning>" write-host " <LimitMinError>$lunerrorlevel</LimitMinError>" write-host " </result>" } else { write-host " <result>" write-host " <channel>$LunName Percent Free</channel>" write-host " <value>100</value>" write-host " <unit>Percent</unit>" write-host " </result>" } } } } if ($showdisks) { #PRTG message display If ($FailedDisks -eq 0 -and $RebuildingDisks -eq 0 -and $Error -eq 0 -and $Warn -eq 0) { write-host " <text>All Disks OK</text>" } ElseIf ($FailedDisks -eq 0 -and $RebuildingDisks -gt 0) { write-host " <text>WARNING $RebuildingDisks disk(s) rebuilding or equalising</text>" } ElseIf ($FailedDisks -gt 0) { write-host " <text>FAILURE $FailedDisks disk(s) failed</text>" write-host " <error>1</error>" } } if (!$showpools -and !$showdisks -and !$showluns) { write-host " <text>ERROR - no display data selected, please select something to show.</text>" write-host " <error>1</error>" } write-host "</prtg>"
Parameters:
-h : REQUIRED. This specifies the hostname/array to connect to. I recommend you use the value %host , this will pass the hostname or IP address you specified for the device in PRTG.
-user : Username. If none specified, it defaults to the system default of "sysadmin".
-password : Password. If none specified, it defaults to the system default of "sysadmin".
-scope : Login Scope. Can either be 0 for global, or 1 for local. Defaults to "0" if none specified.
-lunwarnlevel : The percentage to display a warning for Lun free space. Default is 25.
-lunerrorlevel : The percentage to display an error for Lun free space. Default is 10.
-poolwarnlevel : The percentage to display a warning for Storage pool free space. Default is 25.
-poolerrorlevel : The percentage to display an error for Storage pool free space. Default is 10.
-showpools : Flag to display storage pool information.
-showluns : Use this flag to display LUN information.
-showdisks : Use this flag to display disk information.
Notes:
- You can display pool, lun, and disk information in one sensor using all three -show flags, or show the information in individual sensors. If you choose to display all information at once, please note that there is a recommended limit of 50 channels per sensor, and that PRTG has stated that more channels than this could cause issues.
- For my SAN, this is not an issue, but for users with more than 50 LUNS/Storage pools, this may be problematic.
- You may run into security issues with NaviSecCli if it's security mode is set to "medium". Please refer to the following link on how to change the certificate security level in NaviSecCli if you have issues or you're not sure.
http://www.pragmaticio.com/2015/04/emc-certificate-issues-after-naviseccli-upgrade/
- The position of parameters is not mandatory - any can be specified at any position.
- The only parameters you HAVE TO specify is the host address and at least one dataset to display. And actually, you don't have to display any data, but you'll get an error if you don't pick something.
- I'm open to requests, suggestions, pointing out mistakes I've made, etc. I could have stopped working on this after I got it running last night, but I deliberately tried to make this more universal and more flexible so that it could be used to meet anybody's use-case scenario. But, I've only got one EMC San to test against, and it's not the biggest one out there, so there may be other things people want to see. I've got this down pretty well now, so if there's data I don't have in here, LMK, and I'll be happy to try and accommodate.
Examples:
Pass the hostname from PRTG, use default credentials and scope, show disk status only:
-h %host -showdisks
Pass an IP, username, password; use local scope; show disk status and LUN freespace:
-h 192.168.1.33 -user bob -password BobRox666 -scope 1 -showdisks -showluns
Use custom warning and error levels for luns, show all info:
-h %host -lunwarnlevel 20 -lunerrorlevel 5 -showluns -showdisks -showpools
Photos:
Add comment