When a LUN goes offline, bad things tend to happen on the host using it. It is good to know sooner rather than later if that happens. I was looking for a way to do this and what made the most sense was using PowerShell and PRTG.
You'll need to setup:
The code lets you run the script specifying "all" controllers (which will use the array defined at the beginning of the script), or a controller of your choice.
The function Display-PRTGText takes the $netAppObject object that is built below in the switch option luncheck. It first displays the PRTG header, the LUN information, and finally the PRTG footer.
The switch looks for the action you'd like to take. Right now there is only one, "luncheck". You can add more for different sensor types to check different things based on what you pass to -action.
Examples
To test the script, run it as follows:
.\Lun-Check.ps1 -Controller yourcontroller-c -action luncheck
The above code will execute and if all goes well it will return results with opening and closing <prtg> tags.
If there are any offline, they will be returned into the PRTG sensor via the <text> tag.
Exclusions
You can exclude certain LUNs from being checked. If you have decommissioned a server or are testing anything that involves setting a LUN's state to be offline this can be handy. Add entries to exclude.txt line by line. You can include either the full LUN path, or anything in the path name with wildcards around it. Please note that there is also a line that omits any LUN with "test" in the name. To change this, remove that if line.
Examples:
The first example will omit just that one LUN, whereas the second example will omit any LUN with finance in the path. Any exclusions you do add will be noted in the sensor's message as text if no LUNs are currently offline.
Once you have verified you received the results from the script as needed, we can now perform the sensor setup in PRTG.
You'll want to perform the following steps in PRTG:
If you do not want to use the array with all the NetApp(s) change 'all' to the name of a controller. If it is a CDOT controller, be sure to add -c to the name.
You should now see channels for total and offline LUNs.
I have it setup to show the sensor as down if there are any LUNs offline. To do this, be sure to change the channel limits accordingly. It will return the path of the LUN and the VServer it is on (CDOT) or just the path for 7-Mode. This is displayed in the sensor's message as text.
And finally, you'll want to tweak the notification settings of the sensor if for some reason you want it different than the parent's settings.
I wrote this to fill a need rather quickly. For error handling, the PRTG sensor itself does a good job at telling you why and where the script broke. As for variable renaming and cleanup, that is something I am always striving to do.
I hope you found this helpful, and as always feedback is appreciated!
-Ginger Ninja
No comments yet. Be the first!