Local and remote system monitor gadget
Nov 17, 2009
My entry for the EPiServer gadget contest is a system monitor. I wanted to provide administrators/developers a quick way of checking the health of a local or remote server at a glance.
I wanted:
- A gadget that gave the user control of what they wanted to monitor on a local or remote system
- A visually pleasing way of presenting core system information (CPU load, memory usage and disk space)
The gadget allows users to specify what to monitor and where to monitor it:
By adding a couple of instances of my gadget its possible to build up a simple dashboard that allows users to see what is going on with their server:
Users can set through configuration the critical threshold which is used when deciding what colour to use for memory and disk usage.
By supplying the appropriate credentials it possible to monitor remote machines (The screen shot shows the gadget running on my local machine but monitoring a remote machine (highlighted)):
Points of interest
There are a couple of interesting points about the gadget. Windows Management Instrumentation (WMI) is used to retrieve the system information (either locally or remotely). However the default ASP.net account does not have the required permissions to access some of the counters (such as CPU load) locally. Therefore I needed to temporarily elevate the permissions to those of the user credentials collected when first starting the gadget. Fortunately for me Shakti Singh Tanwar had already written a post of how to do this: http://forums.asp.net/p/1458098/3343489.aspx so I extend my gratitude to him. Also WMI is a huge area, its possible to collect information about your system in eye watering detail. For my gadget I decided to stick with some basic monitoring. However a full list of available classes are available on MSDN here: http://msdn.microsoft.com/en-us/library/aa394084%28VS.85%29.aspx.
In order to create visually pleasing charts I used the Google charts API http://code.google.com/apis/chart/. I like this API as its free, offers a simple way of generating decent looking charts and it doesn't require an API key.
Also in order get access to the model in the javascript I had to use some inline script in the views which I think is not the ideal way of doing things. It would be great if anyone could offer any insight on a better way of doing this within the EPiServer Gadget framework?
Conclusion
The gadget gives users control of what they want to monitor and where they want to monitor it. The gadget can be extended to include any kind of metrics you like. I'd be interested to hear of any additions and/or bugs!
Source code is available here [download] 59k, zip
An installer is available here [download] 19k, zip
Troubleshooting
If you are having trouble getting access to remote computers using WMI then Microsoft provide some WMI diagnosis tools: http://www.microsoft.com/downloads/details.aspx?familyid=d7ba3cd6-18d1-4d05-b11e-4c64192ae97d&displaylang=en.
I found the best way of troubleshooting was using dcomcnfg.exe and checking the permissions on “My Computer”.