ServersAlive ASP Template: Bar Graphs for Drive Space & Ping Times

To use this template:

  1. Download the zip file and extract it.
  2. Copy the ASPbars.htm file into your ServersAlive directory.
  3. Copy the ServersAlive.css file and the gif files into your web server’s directory, like c:\inetpub\wwwroot.
  4. Set up the template output in ServersAlive. Your template setup screen should look like this.
  5. Set up the remarks in your checks for the fancy features….

Disk Space Remark
Setting Up Your Checks

For each disk space check you have in ServersAlive, put the total drive size in megabytes in curly brackets, in the Remark field. If you have a 72 gigabyte drive, you would enter “{72000}”. It doesn’t have to be exact - we just need a rough number to base the graphs on.

How It Works

On the ServersAlive mailing list, Mark Seniow asked if you could visually represent drive space on the status page. That set me to thinking, because I’ve done it before in ASP, so he and I cranked out the code to do it for ServersAlive. The objective is to end up with a red & green bar graph, where if you see a lot of red space, you’re looking at an impending problem.

First, a note about building bar graphs in ASP. The trick is to use a 1-pixel wide red gif, and a 1-pixel wide green gif, and dynamically size them to the right width to represent the numbers we want. If the check is 75% good (free drive space) and 25% bad (used drive space), you would see a 75-pixel wide green gif, and a 25-pixel wide red gif:

<img src=”red.gif” width=”25″ height=”20″>
<img src=”green.gif” width=”75″ height=”20″>

Pictures are worth a thousand words:

75% OK:

 

50% OK:

 

25% OK:

These all use the same 1×1 pixel red and green gifs, but just force the size to whatever width we want using ASP code.

So now we have to know at least 2 of the numbers involved: the good part, the bad part, and the total number. For drive space, that’s free space, used space, and total space. We can get free space easily by using the <sa_checkresponse> tag, which ServersAlive populates with the free bytes.

Disk Space Remark
It’s a little tougher to get the used or total space. What we’re doing here is putting the total space in the check’s Remark, in megabytes inside curly brackets, like this screen shot which shows a 72 gigabyte drive with a remark of {72000}. Make sure you put it inside those curly brackets, because that’s what our code looks for.