Thanks!  I'll put this up on the site!

--------------------------------
Brent Ozar - UniFocus
--------------------------------
"I couldn't wait for success,
 so I went ahead without it."
       Jonathan Winters

-----Original Message-----
From: UXB Internet [mailto:Dennisp@;uxbinfo.com] 
Sent: Friday, October 25, 2002 12:14 PM
To: [EMAIL PROTECTED]
Subject: RE: [SA-list] Bar graphs for disk space

Brent,

Your work inspired me so I ported it over to Cold Fusion for those of us
who
stay away from M$ scripting languages <smile>.  Here is the CF template
code
to duplicate your excellent work.

Please feel free to post this on your web site and Dirk if you want to
include this as an example feel free to use it.  For the value I have
received from Servers Alive it is the least I can do:


===============================[ cut here ]==========================

<cfset IntResponse=0>
<saif sa_check is diskspace> <cfset intResponse =
<sa_checkresponse>></saif>
<cfif IntResponse neq 0>
        <cfset intStart = Find("{","<sa_prettyname>")>
        <cfset intEnd = Find("}","<sa_prettyname>")>

        <cfif intStart gt 0 AND intEnd gt 0>
                <cfset intFullSize =
Mid("<sa_prettyname>",IntStart+1,IntEnd-IntStart-1)>
        <cfset intGreen = Round(intResponse / intFullSize * 100)>
        <cfset intRed = 100 - intGreen>
                <cfoutput>
                <img src="images/red.gif" height="10"
width="#intRed#"><img
src="images/green.gif" height="10" width="#intGreen#"><br>
                <FONT FACE=verdana
SIZE=1>(#Numberformat(evaluate(intResponse /
1000000000),"99999.9")#GB (#intGreen#%) free of
#numberformat(evaluate(intFullSize / 1000000000),"99999.9")#GB)</font>
                </cfoutput>
        </cfif>
</cfif>

===============================[ cut here ]==========================


Best regards,

Dennis Powers
UXB Internet - A Web Design and Hosting Company
tel: (203)879-2844  fax: (203)879-6254
http://www.uxbinternet.com/
http://dennis.uxb.net/


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:salive-owner@;woodstone.nu]On
Behalf
Of Brent G. Ozar
Sent: Thursday, October 24, 2002 8:21 AM
To: [EMAIL PROTECTED]
Subject: RE: [SA-list] Bar graphs for disk space

Wooo!  Due to instant demand, I just went ahead and put my template up
online.  There's now a link to it on my explanation page, which you can
get to from http://www.brentozar.com/salive/.  Thanks for everybody's
interest!


--------------------------------
Brent Ozar - UniFocus
--------------------------------
"Don't wear rollerskates to a tug-of-war."
       Larry Wall

-----Original Message-----
From: Mike Tree [mailto:mike.tree@;clever4.net]
Sent: Thursday, October 24, 2002 7:03 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [SA-list] Bar graphs for disk space

Looks good. I'd like a copy of your template.

p.s. the link to your tips gives 404!!

-----Original Message-----
From: Brent G. Ozar [mailto:brento@;brentozar.com]
Sent: 24 October 2002 12:54
To: [EMAIL PROTECTED]
Subject: [SA-list] Bar graphs for disk space


OK, Mark, here's the full answer, assuming your web server (that's
serving up the SA report template) can handle VBscript ASP.  You'll want
to name the output file with an .asp extension, like default.asp, so
that the web server knows to process the logic.

The objective here 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. How
you do it is you use a 1-pixel wide red gif, and a 1-pixel wide green
gif, and you dynamically size them to the right width to represent the
numbers you want. It's important to keep the total width equal for all
checks, so I'm doing 100 pixels wide total. If the check is 74% good,
you would see a 74-pixel wide green gif, and a 26-pixel wide red gif.
Pictures are worth a thousand words, and you can see examples at:
http://www.unifocus.com/salive/
http://www.brentozar.com/salive/

Here's the code for the bar graph, and you would just put it wherever
you want the graph to show in your template.  (If this doesn't make
sense, I can send you my entire template.)

<%
intStart = inStr(1,"<sa_prettyname>","{")
intEnd = inStr(1,"<sa_prettyname>","}")
If isNumeric("<sa_checkresponse>") then
   intResponse = cdbl("<sa_checkresponse>")
Else
   intResponse = 0
End If
If intStart > 0 AND intEnd > 0 then
   intFullSize =
cdbl(Mid("<sa_prettyname>",intStart+1,(intEnd-intStart-1)))
   intGreen = Round(intResponse / intFullSize * 100,0)
   intRed = 100 - intGreen
   Response.Write("<img src=""red.gif"" height=""20"" width=""" & intRed
& """>")
   Response.Write("<img src=""green.gif"" height=""20"" width=""" &
intGreen & """>")
End If
%>

In order to do the bar graph, you 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.  Make sure that you're writing out the
full number in the check, and not using abbreviations like "5 gb",
because that won't get you a number.  (If there's enough demand, I can
write code to extract the abbreviations into full numbers.)

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 pretty name, like this:
Oscar Free Space {5000000000}. Make sure you put it inside those curly
brackets, because that's what our code looks for.

The code checks to make sure that both brackets are in the pretty name
(positions intStart and intEnd > 0), because that's how we know to draw
a bar graph for this check. Then, it grabs the full size from between
the brackets, compares the full size to <sa_checkresponse>, and uses
those percentages to figure out the widths of the bar graph (intGreen
and intRed).

This will break if you have check responses that return multi-line text
answers, like a POP3 check to MS Exchange or an FTP check to MS IIS.
I've had to hide those checks on my web pages in order for these bar
graphs to work.  You have problems because the asp code looks like this
after SA does its work:

If isNumeric("Microsoft's Big Multi-Line Answer
") then
   intResponse = cdbl("<sa_checkresponse>")

See how the first line wraps around?  That makes VBscript wig out,
because it doesn't like the unclosed quotes and parenthesis.

Any questions, let me know!
Brent


--------------------------------
Brent Ozar - UniFocus
--------------------------------
"Don't wear rollerskates to a tug-of-war."
       Larry Wall
-----Original Message-----
From: Mark Seniow [mailto:mseniow@;smsolutions.com]
Sent: Wednesday, October 23, 2002 3:36 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [SA-list] v4 request

OK, here's part of my wish list .... (unless it's already possible)

It would be nice to be able to evaluate simple mathematical expressions
in
the html template files when generating the html data file.

When my colleague saw me monitoring diskspace he quickly asked why I
could
not create a 'visual' representation of %disk space used (or free) of
total
disk space.  Now you could do this, I suppose, with two nested tables
but
you would have to be able to calculate the percentage.  Or is there an
easier way of doing this?

Thanks.


- Mark

Mark Seniow - [EMAIL PROTECTED]
S.M. Internet Solutions Inc.
Richmond Hill, ON     905-770-4481

To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
   unsubscribe SAlive
To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
   unsubscribe SAlive
To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
   unsubscribe SAlive
To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
   unsubscribe SAlive


To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
   unsubscribe SAlive
To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
   unsubscribe SAlive

Reply via email to