Next rev.. This ENUMERATES an INI file to pull in the server list.

 ;Function SRVAVAIL() 
;
;Author Kent Dyer(leptonator@hotmail.com)
;
;Contributors Lonkero and Doc for ideas
; Jens for his time-based UDFs
;
;Action Checks to see if a set of servers or machines are available
; and as needed e-mail and after 60 minutes page
;
;Syntax SRVAVAIL()
;
;Version 1.3
;
;Date 24-October-2003
;
;Date Revised 28-October-2003
;
;Remarks This is a poor-mans WhatsUP Gold, it was a re-write of
; batch script I put together about 2-1/2 years ago.
; http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=004261#000005
; "Call the in charge person"
; The idea is to check for if a server is up and running. If it is not,
; e-mail appropriate staff. If a server is off-line for over an hour
; page appropriate staff. When a server comes back on-line an e-mail is
; also generated
; Version 1.0 Original Script
; Version 1.1 Added Paging component
; Version 1.2 Changed from using the Registry to INI
; Do a check for existence of an Admin share rather than a PING
; Version 1.3 Changed back to a PING method
; Use a separate INI file and enumerate the data within
;
;Returns Nothing
;
;Dependencies
;TimeDiff
; http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000040

;SerialTime
; http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000039
;
;Mailer (added to this script as it has a fourth parameter)
; http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000483
;
;SRVAVAIL.INI - List of Servers to check in the following format
; [SERVERS]
; SERVER01=OK
; SERVER02=OK
; SERVER03=OK
;
;KiXtart Ver 4.02
;
;Example(s) SRVAVAIL()

SRVAVAIL()
FUNCTION SRVAVAIL()
CLS
BREAK ON
DIM $i,$amerdt,$srvarray,$rc,$time,$tcheck,$ortime,$recipitent,$status,$server,$body

$amerdt=split(@date,'/')[1]+'/'+split(@date,'/')[2]+'/'+split(@date,'/')[0]
$chk=@scriptdir+'\srvavail.ini'
$srv=split(readprofilestring($chk,'SERVERS',''),chr(10))
FOR EACH $i IN $srv
IF $i <>''
$status=readprofilestring($chk,'SERVERS',$i)
;?$sectionkey+' '+$status
?'Checking Server: '+$i
SHELL '%COMSPEC% /C PING -n 1 '+$i
IF @error<>0
IF 'OK'=$status ;only do this once
$rc=WRITEPROFILESTRING($chk,'SERVERS',$i,$i+@time)
;Notify server is off-line
MAILER('recipient@@company.com','Offline',$i,'Server is off-line '+@time+' '+$amerdt)
ENDIF
$ortime=READPROFILESTRING($chk,'SERVERS',$i)
IF 0=instr($ortime,'PAGE')
$time=SUBSTR($ortime,LEN($i)+1,len($ortime))
$tcheck=TIMEDIFF($time,@time)
$tcheck=split($tcheck,':')[0]
IF $tcheck > '00' ;If beyond 60 minutes, page
IF $i+'PAGE'<>READPROFILESTRING($chk,'SERVERS',$i) ;only do this once
$rc=WRITEPROFILESTRING($chk,'SERVERS',$i,$i+'PAGE')
MAILER('pager@@messaging.sprintpcs.com','Offline',$i,'Paging: Server is off-line'+@time+' '+$amerdt)
ENDIF
ENDIF
ENDIF
ELSE
IF'OK'<>READPROFILESTRING($chk,'SERVERS',$i)
;Notify back on line
MAILER('recipient@@company.com','Online',$i,'Server is online '+@time+' '+$amerdt)
$rc=WRITEPROFILESTRING($chk,'SERVERS',$i,'ok')
ENDIF
ENDIF
ENDIF
NEXT
ENDFUNCTION

FUNCTION MAILER($recipient,$status,$server,$body)
$mailhost = 'smtp.company.com'
$sender = 'ServerMonitor@@company.com'
$mailline = @ldrive+'Programs\blat.exe - -to $recipient -server $mailhost -subject "$server $status" '
$mailline = $mailline+'-body "$body" -f $sender -q'
SHELL $mailline
ENDFUNCTION


[ 04. November 2003, 14:38: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's