Introducing IIS Stats v1.0 for Windows Sidebar
My first experiment with building a Windows Sidebar gadget was more for show than anything. Launching perfmon (or any other path) is hardly a good use of Sidebar screen real estate. Regardless, it was a good excuse to try out Windows sidebar development, and have something flashy to show in my PHP demo.
Over the weekend I decided to build something more useful, and with all the roads in and out of my city completely flooded today, I took the opportunity to finish it tonight and make it available for download. I'm calling it IIS Stats (ok the name sucks). Like most v1.0 efforts, it is pretty minimal, but hopefully useful enough to catch your interest.
IIS Stats Sidebar Gadget v1.0
Requirements:
-IIS7 must be installed
-you must run Sidebar elevated, or disable UAC (not recommended)
Features:
-launches "IIS Manager" on click
-shows total "get" requests for your server since boot
-shows current requests per second (RPS) for all sites
Important note: to run sidebar elevated you must first close sidebar, then click start->all programs->accessories then "right click" on "Windows Sidebar" and choose "Run as Administrator". This will enable the gadget to use the WMI scripting interface to get performance counter information to display in the gadget. Doing this will cause Windows Sidebar, and all gadgets that are running, to have Administrators privledges. This is not a good security practice, but unfortunately it is a requirement until the Sidebar team improves their APIs to provide greater access to performance information of the machine. As far as I can tell, the built-in APIs only support accessing CPU, memory, and wireless network status (note the built-in gadgets).
The Code: if you'd like to inspect the code for this gadget (and borrow it for your own project), install the gadget then browse to the c:\users\<your user name>\appdata\Local\Microsoft\Windows Sidebar\Gadgets\IISStats.gadget and check out the gadget manifest: gadget.xml and the StartIISStats.html file. Inside the StartIISStats.html file you'll see some very basic vbscript / jscript which performs the actions of the gadget. <<insert long explanation here as to why I use both JScript and VBScript>>
Disclaimer: This is something I built for fun on my own spare time. It is not a Microsoft product, and I am not responsible for your use of this gadget, and any potential harm it causes you. Use at your own risk!
Install instructions: You can download IIS Stats Sidebar Gadget from gallery.live.com. In order to install the gadget, download it to your desktop, rename the file from IISStats.zip to IISStats.gadget. Then double click on the icon. This will automatically install it into your sidebar. Enjoy! If you like it, or have ideas on how to enhance the gadget, be sure and leave a comment!
Known issues:
- if you take a look at the code, I'm dividing the results I get from WMI for GetRequestsPerSec by 3. Why? Because the number was consistently 3x higher than what I observed in perfmon or Wcat. Why? I have no idea... but I'll look into it more.
- if you make a request to http://localhost/ and you have the default IIS page installed, you will notice the total requests increments three times. You may think this is a related performance counter issue - after all - you just made one request, right? Wrong. You made three requests. The first request you made was for http://localhost/ Internally, IIS looks up the defaultDocument for that request and then executes the request again for iisstart.htm (that is the second request). The iisstart.htm file references the welcome.png file, which IE requests, making the third request. You can prove the counter is working properly by requesting http://localhost/welcome.png directly, and seeing the counter increment only once. Also, hold down "F5" in the browser and see how many RPS you can generate. Weee! fun!!!