scripun
asked on
vbscript to monitor windows service elapsed time
Experts,
I am looking for vbscript to monitor windows service elapsed time. Service is not active at all times but gets initiated when there is a request to run reports. If there is a problem with report query (too big/complicated) that particular service gets stuck and keeps on running until someone kills it. The report service its self is very cpu hungry and when stuck, main app becomes unresponsive.
Script needs to keep track when service gets initiated, monitor how many minutes it stays running and if predetermined amount (let’s say 15min) has exceeded, send notification email about the service, running time, etc… and kill it. App can initiate two reports at any given time, but not more. Each report will have its own report service executing it. One can get stuck without affecting the other. Script needs to be active at all times.
Please let me know if you need more info.
Thanks
I am looking for vbscript to monitor windows service elapsed time. Service is not active at all times but gets initiated when there is a request to run reports. If there is a problem with report query (too big/complicated) that particular service gets stuck and keeps on running until someone kills it. The report service its self is very cpu hungry and when stuck, main app becomes unresponsive.
Script needs to keep track when service gets initiated, monitor how many minutes it stays running and if predetermined amount (let’s say 15min) has exceeded, send notification email about the service, running time, etc… and kill it. App can initiate two reports at any given time, but not more. Each report will have its own report service executing it. One can get stuck without affecting the other. Script needs to be active at all times.
Please let me know if you need more info.
Thanks
Does the service have a unique executable? That way you could monitor for a particular process and start tracking when it is detected as running (if the script checks every 5 or 10 or 30 seconds depending on your threshold). I believe I have something very close to what you're looking for.
ASKER
@mlongoh,
Yes it does have a unique executable.
Yes it does have a unique executable.
OK, stand by.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I just had to edit the code in the last post... I was missing one crucial line - it's in there now.
Also, Line 19 should read like this:
LogMe Now & vbtab & objNetwork.ComputerName & vbtab & ServiceStartTime & vbtab & DateDiff("n", ServiceStartTime, NOW), LogFile
LogMe Now & vbtab & objNetwork.ComputerName & vbtab & ServiceStartTime & vbtab & DateDiff("n", ServiceStartTime, NOW), LogFile
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Let me try it...
i'm probably a little off-topic, here, but...
maybe would it be easier to monitor the report files
if the file is older than some configurable time (15mn), restart the service; and wait for some time (30mn) before checking again, if the file is older than another threshold (2h), maybe move it to a failed directory and warn the operator. it should be easy to determine which process works on each report either through it's command line or through its open files
maybe would it be easier to monitor the report files
if the file is older than some configurable time (15mn), restart the service; and wait for some time (30mn) before checking again, if the file is older than another threshold (2h), maybe move it to a failed directory and warn the operator. it should be easy to determine which process works on each report either through it's command line or through its open files
ASKER
I am sorry, got tied up putting fires out last week. Will try it tomorrow.
tasklist /FI "CPUTIME gt 1:00:00"
pslist http://technet.microsoft.com/fr-fr/sysinternals/bb896682.aspx gives the process start time as far as i can remember but i am unsure