Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
This version does some checking and if after 60 minutes a server is not back up, there is a page sent - this way normal server restarts don't page, but if there is a problem it can be addressed.. ;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
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 ]
$srvarray ='server01 server02'
$srvarray =$srvarray +' server03 server 04'
FOR EACH $i IN Split ($srvarray )
?'Checking Server: ' +$i
SHELL '%COMSPEC% /C PING -n 1 ' +$i
IF @error < >0
IF '' =READVALUE ('HKCU\Software\KiXtart' ,$i ) ;only do this once
$rc =WRITEVALUE ('HKCU\Software\KiXtart' ,$i ,$i +@time ,'REG_SZ' )
;Notify server is off-line
$amerdt =split (@date ,'/' )[1 ]+'/' +split (@date ,'/' )[2 ]+'/' +split (@date ,'/' )[0 ]
MAILER ('recipient@@company.com' ,'Offline' ,$i ,'Server is off-line ' +@time +' ' +$amerdt )
ENDIF
$ortime =READVALUE ('HKCU\Software\KiXtart' ,$i )
$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 < >READVALUE ('HKCU\Software\KiXtart' ,$i +'PAGE' ) ;only do this once
$rc =WRITEVALUE ('HKCU\Software\KiXtart' ,$i +'PAGE' ,$i ,'REG_SZ' )
MAILER ('pager@@messaging.sprintpcs.com' ,'Offline' ,$i ,'Paging: Server is off-line' +@time +' ' +$amerdt )
ENDIF
ENDIF
ELSE
IF '' < >READVALUE ('HKCU\Software\KiXtart' ,$i )
;Notify back on line
MAILER ('person@@company.com' ,'Online' ,$i ,'Server is online ' +@time +' ' +$amerdt )
$rc =DELVALUE ('HKCU\Software\KiXtart' ,$i )
$rc =DELVALUE ('HKCU\Software\KiXtart' ,$i +'PAGE' )
ENDIF
ENDIF
NEXT
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 Kent