BrianTX
(Korg Regular)
2002-05-08 03:22 PM
HELP with Microsoft IIS/Proxy

For the past several months, we have been using a product called SuperScout with Microsoft Proxy 2.0 to monitor web access by our users. Unfortunately, the SuperScout program seems to cause proxy/IIS to generate Dr. Watson errors on rare occasion. So, I have devised a script that uses BLAT to send an email to me or a co-worker when the proxy service stops. I do this by polling the Dr. Watson log size. Ideally, SurfControl would fix their product, but this hasn't happened, yet.

What I would like to do is to automatically restart the web proxy and default web service whenever these errors occur. This way, I don't have to run back to the server every time the proxy errors out. I have looked into the adsutil.vbs script, and I have a little understanding, but I'm not sure it is adequate. Generally, I right click on web proxy, then start, then I right click on default web server, then start (in iis.msc). This is all that is necessary. I would assume there is a way to do this via kixtart.

Any help you can give me would be greatly appreciated!!!

Brian


Howard Bullock
(KiX Supporter)
2002-05-08 03:54 PM
Re: HELP with Microsoft IIS/Proxy

I would think that you should monitor the service and not necessarily the DrWatson log file. Here is some code to that should point you in the right direction. Let me now if I missed your intended target.
code:
;Status of service. The values can be found in the following list: Status Constant 
;ADS_SERVICE_STOPPED 0x00000001
;ADS_SERVICE_START_PENDING 0x00000002
;ADS_SERVICE_STOP_PENDING 0x00000003
;ADS_SERVICE_RUNNING 0x00000004
;ADS_SERVICE_CONTINUE_PENDING 0x00000005
;ADS_SERVICE_PAUSE_PENDING 0x00000006
;ADS_SERVICE_PAUSED 0x00000007
;ADS_SERVICE_ERROR 0x00000008


$computer = GetObject("WinNT://@wksta,computer")
? @serror
$service = $computer.GetObject("Service", "Clipsrv")
? @serror
$rc = $service.Status
? "Status=$rc"
If $service.Status <> 4
$service.Start
EndIf
get $_
If $service.Status <> 1
$service.Stop
EndIf
$rc = $service.Status
? "Status=$rc"



[ 08 May 2002, 15:55: Message edited by: Howard Bullock ]


BrianTX
(Korg Regular)
2002-05-08 04:04 PM
Re: HELP with Microsoft IIS/Proxy

Maybe I SHOULD monitor the service, but I'm not sure it will help me that much. I still have to clear the Dr. Watson error that appears. The error has always been the same. (We've logged something like 30 of these errors on each of 3 proxy servers.) Does the "ADS_SERVICE_ERROR" get set when Dr. Watson is called? I will also need to close the Dr. Watson error that has popped up... Let me tool around with this a bit..

Brian


Les
(KiX Master)
2002-05-08 04:11 PM
Re: HELP with Microsoft IIS/Proxy

On my Terminal Server, I just disable Dr. Watson entirely.

To disable Dr. Watson from running, from start | Run | drwtsn32.exe
Clear all check marks from Options boxes
To reenable Dr. Watson type drwtsn32.exe -i in the run box


Les
(KiX Master)
2002-05-08 04:18 PM
Re: HELP with Microsoft IIS/Proxy

If you're running Proxy2 on Win2k, you should be able to set the service to monitor itself and restart. If you're on NT4, I believe there's a ResKit util that'll do that for you.

Schuliebug
(Hey THIS is FUN)
2002-05-08 04:33 PM
Re: HELP with Microsoft IIS/Proxy

Otherwise, have a look at Servers Alive. I know, this is not the place to mention it, but it is a neat tool which is cheap and does the job well. Have a look at the site of Servers Alive.

BrianTX
(Korg Regular)
2002-05-08 04:35 PM
Re: HELP with Microsoft IIS/Proxy

Disabling Dr. Watson isn't an option at this point. We are still waiting on the company to resolve the problems with their software, so we need a log of errors. Howard's solution works fine except that as the service is starting I get the return code of 8... so I will have to put a delay in there... might just be easier to use "net start"...

Brian


BrianTX
(Korg Regular)
2002-05-08 05:27 PM
Re: HELP with Microsoft IIS/Proxy

Howard:

I'm using WinNT 4.0. The script you posted only works on Windows 2000. I couldn't get the line

$service=$computer.GetObject("Service","ClipSrv") to work. It gives me an error.

Brian


Howard Bullock
(KiX Supporter)
2002-05-08 05:38 PM
Re: HELP with Microsoft IIS/Proxy

Do you have ADSI installed on your NT4 computer? I would assume that much but had to ask. [Wink]

"ClipSrv" is a W2K service name and only included as an example. You would have to substitute the correct service (short names) "W3SVC" etc.

Here are the services our Proxy2 server use.

:Down
net stop w3svc
net stop msftpsvc
net stop iisadmin /y

set process="inetinfo"
call :Killprocess

net stop mailalrt
net stop mspadmin

set process="DRWTSN32"
call :Killprocess

set LogText=Proxy Service has been stopped.
call :Log
goto End

:Up
net start mspadmin
net start mailalrt
net start iisadmin
net start msftpsvc
net start w3svc


Howard Bullock
(KiX Supporter)
2002-05-08 05:43 PM
Re: HELP with Microsoft IIS/Proxy

We use HP Openview to monitor the INETinfo process in order to determine if proxy is up or not.

BrianTX
(Korg Regular)
2002-05-08 06:06 PM
Re: HELP with Microsoft IIS/Proxy

I don't know if we have ADSI installed. We don't have any win2k servers, yet, so this may be a worthless pursuit until then. I don't have a great understanding of how all this stuff relies on ADSI. Interestingly, though, the adsutil.vbs script seems to enumerate objects just fine... maybe I'll just go ahead an use it... or stick with net start and net stop.

Brian


BrianTX
(Korg Regular)
2002-05-08 08:36 PM
Re: HELP with Microsoft IIS/Proxy

Ok.. now that it comes right down to it, what I really need is a script that allows me to reactivate the filter w3proxy on Windows NT4 Server. The path should be:

IIS://computername/W3SVC/1/Filters/w3proxy

or something similar. I noticed that there is no way to run a "net start w3proxy"... because it comes back with the message that the service doesn't exist. I can start the w3svc, but for some reason it doesn't reload the w3proxy. I'm not sure it makes a difference if I do a "net stop w3svc" then a "net start w3svc"... Can anyone help?

Brian


Howard Bullock
(KiX Supporter)
2002-05-08 09:37 PM
Re: HELP with Microsoft IIS/Proxy

Please revisit the list of services above. I think you want "iisadmin".

The message above details the stops and starts for shutting down and starting up our MSproxy 2.0 services.


BrianTX
(Korg Regular)
2002-05-08 09:48 PM
Re: HELP with Microsoft IIS/Proxy

I think you're right, Howard.. upon further review.. I think I was being too nitpicky and trying to make it to "neat". Stopping the IISADMIN and W3SVC then restarting them should do the trick. ISAPI filters are loaded when the IISADMIN service is loaded. Yes, there has to be some way reload ISAPI filters outside of restarting IISADMIN, but Microsoft has not been so kind as to document how (in so far as I've looked -- MSDN, etc). So.. I've settled on the method:

code:
shell '%comspec% /c net stop W3SVC'
shell '%comspec% /c net stop IISADMIN'
shell '%comspec% /c net start IISADMIN'
shell '%comspec% /c net start W3SVC'

Ah well.. I guess i'll have to live with 30 seconds downtime instead of 10 or 15.. [Smile]

Brian


Howard Bullock
(KiX Supporter)
2002-05-08 09:55 PM
Re: HELP with Microsoft IIS/Proxy

Since you posted this in the COM forum, I think that you should install ADSI and use the code provided above instead of that nasty "SHELL net stuff". [Big Grin]

[ 08 May 2002, 21:55: Message edited by: Howard Bullock ]


BrianTX
(Korg Regular)
2002-05-08 09:59 PM
Re: HELP with Microsoft IIS/Proxy

Yeah.. well, I wanted a COM solution.. none has been forthcoming.. [Razz] IIS has ADSI capabilities whether NT does or not. [Smile]

Brian


Howard Bullock
(KiX Supporter)
2002-05-08 10:13 PM
Re: HELP with Microsoft IIS/Proxy

Try this. If it does not work because ADSI is not there, you can DL it from the link in my previous post.
code:
$computer = GetObject("WinNT://@wksta,computer")
$service1 = $computer.GetObject("Service", "iisadmin")
$service2 = $computer.GetObject("Service", "w3svc")
$service2.Stop
$service1.Stop
$service1.Start
$service2.Start



BrianTX
(Korg Regular)
2002-05-13 03:51 PM
Re: HELP with Microsoft IIS/Proxy

Well, unfortunately, simply stopping and starting the services does NOT reactivate proxy properly after a crash. So, I'm still looking for a solution that simply turns on the proxy the same as the IIS.msc allows you to do it by right clicking on the service and clicking start. Other methods cause errors in the event log...

Brian


robbocop
(Fresh Scripter)
2002-06-20 09:51 AM
Re: HELP with Microsoft IIS/Proxy

I need a help. I have to check on several wks if there are some IIS webserver. Do you think that using Com looking for the iisadmin service is right.
Thanks for your help


BrianTX
(Korg Regular)
2002-06-20 03:37 PM
Re: HELP with Microsoft IIS/Proxy

Do you want to see if IIS is installed or if it is running a webserver or what specifically? COM is a great way to do this.

Brian


LonkeroAdministrator
(KiX Master Guru)
2002-06-20 03:41 PM
Re: HELP with Microsoft IIS/Proxy

brian, can I ask why you use IIS proxy?
it's well known fact that is slow as sh*t...

it's working fine on server which is not used for any other purpose and which has no much simultaneous queries, but when you go over 20 queries you need a super computer for the proxy to work properly on IIS...

well, perhaps you {edit} have {/edit} one doing that. [Big Grin]

cheers,

[ 20 June 2002, 15:42: Message edited by: Lonkero ]


BrianTX
(Korg Regular)
2002-06-20 03:43 PM
Re: HELP with Microsoft IIS/Proxy

I use IIS Proxy because.......
It was someone else's project which I inherited and am not allowed to change. [Smile]

Brian


LonkeroAdministrator
(KiX Master Guru)
2002-06-20 03:48 PM
Re: HELP with Microsoft IIS/Proxy

sad...

this happens when you have tight *ss boss...

have heard similar stuff before.
I'm glad my boss trustes what I say.

as an example:
"I was working that day 10 hours. I just didn't have time to come to office." [Razz]

cheers,


robbocop
(Fresh Scripter)
2002-06-24 09:02 AM
Re: HELP with Microsoft IIS/Proxy

I would like to know how to check both if IIS is installed and if a web server is running.

BrianTX
(Korg Regular)
2002-06-24 06:58 PM
Re: HELP with Microsoft IIS/Proxy

Here is a little script whipped up just for you.. (although I'm positive there is a UDF somewhere that basically does this):

code:
break on
$cpname = "server"
$domain = "domain"
$service = "IISADMIN"
$objcomp = GetObject("WinNT://$domain/$cpname,Computer")
IF @error = 0 ;computer exists
$obj=GetObject("WinNT://$domain/$cpname/$service,Service")
If @error = 0
$service + " exists on the target PC." ?
$scode = "unknown","stopped","start pending","stop pending","running","continue pending","pause pending","paused","error","unknown"
$Status = $obj.status
$Service+ " " + $scode[$status] + "."
Else
$Service + " does not exist on the target PC." ?
Endif
Else
"Computer does not exist or is not available."
Endif

You can get by with crossing into another domain to see if IISADMIN is installed as long as your administrator passwords match. However, you may have trouble finding out the status of the service unless you can authenticate properly on the domain in question. Essentially, this works best if you only run from the domain you're checking.

Brian