Page 1 of 1 1
Topic Options
#52964 - 2001-01-03 01:33 AM Has anyone done this before: Script to check IIS status, if down, restart service ...
Anonymous
Unregistered


. . .or re-boot the box ??

I just got handed a request: develop a script
that will check IIS status every so often, and if it isn't responding, stop and start the IIS service, or, alternately, re-start the box.

I was planning on using AT to run the script, but has anyone done anything REMOTELY like this in Kixtart ???

Top
#52965 - 2001-01-03 04:51 AM Re: Has anyone done this before: Script to check IIS status, if down, restart service ...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I have done this with a batch File.. You could shell out and do it with KIX..

Here are the BATCH Commands..

code:

::STOP THE FTP SERVICE
NET STOP "FTP Publishing Service"
::STOP THE WWW PUBLISHING SERVICE
NET STOP W3SVC
::STOP IISADMIN
ECHO Y | NET STOP IISADMIN
::WAIT 30 SECONDS FOR THE SERVICE TO COMPLETELY STOP
SLEEP 30
: :DELETE TEMP/JUNK FILES IN THE TEMP LOCATION
DEL /S/Q %TEMP%\*.TMP
DEL /S/Q %TEMP%\~*.*
DEL /S/Q %TEMP%\ff*.TMP
: :DELETE TEMP/JUNK FILES FROM WINNT
DEL /S/Q %WINDIR%\*.TMP
DEL /S/Q %WINDIR%\~*.TMP
DEL /S/Q %WINDIR%\ff*.TMP
: :DELETE FDF FILES FROM WORKORDER LOCATION
DEL /S/Q "E:\PDF Personalization\Workorder\*.FDF"
::RESTART THE WEB SERVICE
NET START IISADMIN
::START THE FTP SERVICE
NET START "FTP Publishing Service"
::INSURE W3SVC IS STARTED
NET START|FIND /I "WORLD WIDE WEB PUBLISHING SERVICE"
IF ERRORLEVEL 1 GOTO :W3SVC
IF ERRORLEVEL 0 GOTO :EOF

:W3SVC
NET START W3SVC
GOTO :EOF

:EOF
EXIT
::IF EXIT DOES NOT WORK, THIS DOES ;-)
CLS


I know this is not KIX, but this should get you going.. You can also use the shutdown from the NT Resource Kit.

Cheers,

Kent

[This message has been edited by kdyer (edited 03 January 2001).]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#52966 - 2001-01-03 03:47 PM Re: Has anyone done this before: Script to check IIS status, if down, restart service ...
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Here is a service stop|start routine that i came up with, to stop and restart a remote service.

You need to assign the variables $service, $target, and $tempfile for this routine to work. It also used the program xnet.exe that came with kix to stop and start the services.

code:

:StartStop
? "Stopping and restarting $service on $target"
? shell '%comspec% /c xnet stop $target\$service'
do
shell '%comspec% /c xnet list $target | find /i "$service" > $tempfile'
$nul = open(2,$tempfile,2) $data = readline(2) $nul = close (2) del $tempfile
"." sleep 1
until substr("$data",63,len("$data")) = "stopped"
? shell '%comspec% /c xnet start $target\$service'
return

Now all you need to do is figure out if the service is running like it should be...

Bryce

Top
#52967 - 2001-01-05 07:15 PM Re: Has anyone done this before: Script to check IIS status, if down, restart service ...
Anonymous
Unregistered


Try using NETSVC from the NT Resource kit with the /query switch to check the status of a server.

Good luck.

Roneil

Top
#52968 - 2001-01-11 04:09 PM Re: Has anyone done this before: Script to check IIS status, if down, restart service ...
Anonymous
Unregistered


I think it's simpler to use the Unix-like command GREP (also from the Resource Kit) to check shell output results. This will avoid creating and reading temporary files ....

I use a script like this one:

$SERVICE_NAME="W3SVC"
SHELL "%COMSPEC% /C SC.EXE QUERY " + $SERVICE_NAME + " |GREP RUNNING"
IF @ERROR=0
? "It's running"
ELSE
? "It's NOT running"
ENDIF

Top
#52969 - 2001-01-11 04:23 PM Re: Has anyone done this before: Script to check IIS status, if down, restart service ...
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
kaidza,

damn! I learn something new every day! this also works with the built in FIND dos command!!

But there are still times when you will want to read the data back in to kix.

Thanks!
Bryce

Top
#52970 - 2001-01-11 05:45 PM Re: Has anyone done this before: Script to check IIS status, if down, restart service ...
Anonymous
Unregistered


Geeze. . . I can GREP in NT now ??? Excellent. There's a CRON for NT out there as well, beats the pants off of AT. . . .
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.126 seconds in which 0.1 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org