Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Nt Alerts Delivered To Your Mailbox

Rated 3.91 (Ratings: 1)

Want more?

 
Picture of sgd

Scott Dexter

Member info

User since: 26 Apr 1999

Articles written: 10

So you got yer NT box, yer IIS server, and yer ASP pages humming quietly in the back room fer what seems like days now after the sudden explosion in traffic over the weekend that made you tune the box because a) you ran out of memory, b) the processor got stuck at 100% because of some problem the IT guys haven't patched, c) ASP processing was dog slow because you didn't have enough script engines cached and/or allocated, or d) all of the above or something else.

You've even learned some good Performance Monitor counters to pay attention to, like number of ASP requests queued, total processor utilization, current number of ASP sessions, and a couple others. But you hate having to manually go look at them every once in a while, cause you hafta get up from your seat and walk down the hall, er something.

My dear friend, take advantage of the Alerts page in Performance Monitor and some VBScript you've probably already written. On the Alerts page you specify a counter (like ASP requests queued) and a threshold (like 10) and a program to kick off when it happens (you got it, like a program you write using some VBScript). You can take some ASP code you probably have laying around --you know, that little routine that sends an email?-- and turn it into a WSH script that can be fired from a command line (don't worry, I've got code below). The program fired by the alert has to be specified by full pathname, so you know.

Here's the little diddy I have running, and yeah, I use a third party component from Mabry (http://www.mabry.com) to do the mailing. We like Mabry, they're nice. I have the script in the c:\ cause I'm lazy and I didn't want to type long directory paths in the Alerts box. You call it with two parameters, subject line and message text: emailsupport.vbs "This is a Test" "Your server is dying and all you can think about is hockey?"

And now, the code. It took me all of 15 minutes to learn the differences and get parameters passed in.

 *******BOF*********

' Don't hang around if there's an error

On Error Resume Next

' What's on the command line --its a Collection, not an array

Set oArgs = WScript.Arguments

if oArgs.Count<2 then

alert="test"

mesg = "test"

else

'first arg is where from, the second is the message

alert=oArgs(0)

mesg = oArgs(1)

end if

' send the mail with the argument:

mailAlert alert,mesg

' now go away

WScript.Quit

sub mailAlert(byval wherefrom, byval mesg)

On Error Resume Next

MailDstIsHost = 64 ' does this look familiar?

Set oMail = WScript.CreateObject("Mabry.MailCtrl")

oMail.Blocking = True

' Set header properties

oMail.To = "<sgd@ti3.com>"

oMail.From = "<alerts@ti3.com>"

oMail.EMailAddress = "<alerts@ti3.com>"

oMail.Date = Now

oMail.Subject = "Email Alert from " & wherefrom

oMail.Body(0) = Now & " : " & mesg

oMail.Host = "yourSMTPserverhere"

oMail.Flags = MailDstIsHost ' Connect to server

oMail.ConnectType = 0 ' basic SMTP

oMail.Connect

oMail.WriteMessage MailDstIsHost

' Disconnect

oMail.Disconnect

' instead of Set oMail=Nothing we do this:

WScript.DisconnectObject oMail

end sub

'*************EOF***********

Take it and run, I implore you

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.org Evolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.