AddExtender("WWPST32I.DLL") AddExtender("WWWNT32I.DLL") Addextender("WWIPG32I.DLL") Time=TimeDate ( ) loop=0 list=0 :START ;TimeDelay(60) chng=FileOpen("c:\SrvrMntr.txt","APPEND") gosub MONITOR goto START :MONITOR ;debug(1) H="C:\servers2.txt" srvr = FileOpen(H, "READ") while @TRUE y = FileRead(srvr) If y == "*EOF*" FileClose(chng) FileClose(srvr) goto Start endif ParseData(y) srvrp="%param1%" srvcp="%param2%" Errormode(@off) host=strcat(srvrp,".YourDomain.com") Boxopen(host,"Pinging %host%") test00=ipPing(host,10) If test00==@TRUE boxtext("Checking %srvcp% service") gosub EXCHNG endIf endwhile ErrorMOde(@ON) goto START :EXCHNG sa="MSExchangeIMC" sb="MSExchangeMTA" sc="MSExchangeDS" sd="MSExchangeIS" ;***************************************MSExchangeIMC If srvrp=="NTEX01 counta=0 statea=wntSvcStatus(srvrp, sa,1000,2) If statea ==1 a=strcat("SERVICE_STOPPED"," The service is not running.") wntSvcStart(srvrp,sa,1000,"","") statea=wntSvcStatus(srvrp, 1,1000,2) If statea ==1 a1=strcat(sa," state is ",a) count1=1 endif endif If statea ==2 a=strcat("SERVICE_START_PENDING"," The service is starting.") counta=0 If statea ==3 a=strcat("SERVICE_STOP_PENDING"," The service is stopping.") counta=0 If statea ==4 a=strcat("SERVICE_RUNNING"," The service is running.") counta=0 If statea ==5 a=strcat("SERVICE_CONTINUE_PENDING"," The service continue is pending." ) counta=0 If statea ==6 a=strcat("SERVICE_PAUSE_PENDING"," The service pause is pending.") counta=0 If statea ==7 a=strcat("SERVICE_PAUSED"," The service is paused.") counta=0 endif endif endif endif endif endif endif ;***************************************MSExchangeMTA stateb=wntSvcStatus(srvrp, sb,1000,2) countb=0 stateb=wntSvcStatus(srvrp, sa,1000,2) If stateb ==1 a=strcat("SERVICE_STOPPED"," The service is not running.") wntSvcStart(srvrp,sa,1000,"","") stateb=wntSvcStatus(srvrp, 1,1000,2) If stateb ==1 a1=strcat(sa," state is ",a) countb=1 endif endif If stateb ==2 a=strcat("SERVICE_START_PENDING"," The service is starting.") countb=0 If stateb ==3 a=strcat("SERVICE_STOP_PENDING"," The service is stopping.") countb=0 If stateb ==4 a=strcat("SERVICE_RUNNING"," The service is running.") countb=0 If stateb ==5 a=strcat("SERVICE_CONTINUE_PENDING"," The service continue is pending." ) countb=0 If stateb ==6 a=strcat("SERVICE_PAUSE_PENDING"," The service pause is pending.") countb=0 If stateb ==7 a=strcat("SERVICE_PAUSED"," The service is paused.") countb=0 endif endif endif endif endif endif endif ;***************************************MSExchangeDS statec=wntSvcStatus(srvrp, sc,1000,2) countc=0 statec=wntSvcStatus(srvrp, sa,1000,2) If statec ==1 a=strcat("SERVICE_STOPPED"," The service is not running.") wntSvcStart(srvrp,sa,1000,"","") statec=wntSvcStatus(srvrp, 1,1000,2) If statec ==1 a1=strcat(sa," state is ",a) countb=1 endif endif If statec ==2 a=strcat("SERVICE_START_PENDING"," The service is starting.") countc=0 If statec ==3 a=strcat("SERVICE_STOP_PENDING"," The service is stopping.") countc=0 If statec ==4 a=strcat("SERVICE_RUNNING"," The service is running.") countc=0 If statec ==5 a=strcat("SERVICE_CONTINUE_PENDING"," The service continue is pending." ) countc=0 If statec ==6 a=strcat("SERVICE_PAUSE_PENDING"," The service pause is pending.") countc=0 If statec ==7 a=strcat("SERVICE_PAUSED"," The service is paused.") countc=0 endif endif endif endif endif endif endif ;***************************************MSExchangeIS stated=wntSvcStatus(srvrp, sd,1000,2) countd=0 stated=wntSvcStatus(srvrp, sa,1000,2) If stated ==1 a=strcat("SERVICE_STOPPED"," The service is not running.") countd=1 wntSvcStart(srvrp,sa,1000,"","") stated=wntSvcStatus(srvrp, 1,1000,2) If stated==1 countd=1 endif If stated==4 endif endif If stated ==2 a=strcat("SERVICE_START_PENDING"," The service is starting.") countd=0 If stated ==3 a=strcat("SERVICE_STOP_PENDING"," The service is stopping.") countd=0 If stated ==4 a=strcat("SERVICE_RUNNING"," The service is running.") countd=0 If stated ==5 a=strcat("SERVICE_CONTINUE_PENDING"," The service continue is pending." ) countd=0 If stated ==6 a=strcat("SERVICE_PAUSE_PENDING"," The service pause is pending.") countd=0 If stated ==7 a=strcat("SERVICE_PAUSED"," The service is paused.") countd=0 endif endif endif endif endif endif endif srv_count= "counta + countb + countc + countd" If srv_count== If count==0 Then gosub ALERT4 If count !==0 Then gosub checkup :ALERT4 Filewrite(chng,"%srvrp% is up and mail services are functioning; %time%") Filewrite(chng," %a5%") :ALERT Filewrite(chng,"*************") Filewrite(chng,"%srvrp% can be pinged but a service is stopped: %time%") Filewrite(chng,"*************") ;CIS_recip="helpdesk@YourDomain.com,dan_kingsbury@YourDomain.com" a1=strcat(sa," state is ",a) a2=strcat(sb," state is ",b) a3=strcat(sc," state is ",c) a4=strcat(sd," state is ",d) a5=strcat("Further info:","%@CRLF%",a1,"%@CRLF%",a2,"%@CRLF%",a3,"%@CRLF%",a4) a6=strcat(srvrp,"is up but mail services may not be funtioning: Time:",time,"%@CRLF%","Attempted to restart service.") a7=strcat(a6,"%@CRLF%",a5) host="ntex01.YourDomain.com" fromaddr="Helpdesk@YourDomain.com" userid="carcon" password="" port="" tolist="chuck_arconi@YourDomain.com" ;%CIS_recip% cclist="" bcclist="" subject="%srvrp% is up but a service is stopped:%time%" msg=a7 attachments="" flags="" kInit(host,fromaddr,userid,password,port) kDest(tolist,cclist,bcclist) kSendText(subject,msg,attachments,flags) return :ALERT If st==4 Filewrite(chng,"*************") Filewrite(chng,"%srvrp% -The %srvcp% service was stopped: Restart was successful %time%") Filewrite(chng,"*************") endif a1=strcat(sa," state is ",a) a2=strcat(sb," state is ",b) a3=strcat(sc," state is ",c) a4=strcat(sd," state is ",d) a5=strcat("Further info:","%@CRLF%",a1,"%@CRLF%",a2,"%@CRLF%",a3,"%@CRLF%",a4) a6=strcat(srvrp," is up and mail services were restarted: ",time,"%@CRLF%","Check event logs for errors.") a7=strcat(a6,"%@CRLF%",a5) host="ntex01.YourDomain.com" fromaddr="Helpdesk@YourDomain.com" userid="carcon" password="" port="" tolist="chuck_arconi@YourDomain.com" ;%CIS_recip% cclist="" bcclist="" subject="%srvrp% -The service was stopped: Restart was successful %time%" msg=a7 attachments="" flags="" kInit(host,fromaddr,userid,password,port) kDest(tolist,cclist,bcclist) kSendText(subject,msg,attachments,flags) return return