Monitoring system service
Posted: 02 Apr 2010 01:57
Hi,
I'm new in this forum and new for the dos .
I have the same problem:
I want to monitoring one my windows server 2000 system services if the state change from ACTIVATE to STOPPED.
For this, I have thought first to lunch a command: (now I use for example the windows service spooler)
1- sc query spooler ---> that return this:
That's the correct state of te service.
I put this state in a .txt file ---> sc query spooler > original_state.txt
I lunch this batch script evrey /n hour on the server for create a current_state.txt
Now I want to comparing the two file for analyse if the state of services change... for example if the current_state.txt contain this:
How can comparing a file and if are different lunch another .bat ???
For comparing, i can lunch: " fc original_state.txt currentent_state.txt /n " and this is the output:
Any Idea??? how create an If or other control to analyse if two file are different or equal?
There is another metod???
Thank you in advance and sorry for my poor english.
waiting for your help.
Massimo
I'm new in this forum and new for the dos .
I have the same problem:
I want to monitoring one my windows server 2000 system services if the state change from ACTIVATE to STOPPED.
For this, I have thought first to lunch a command: (now I use for example the windows service spooler)
1- sc query spooler ---> that return this:
Code: Select all
SERVICE_NAME: spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
That's the correct state of te service.
I put this state in a .txt file ---> sc query spooler > original_state.txt
I lunch this batch script evrey /n hour on the server for create a current_state.txt
Now I want to comparing the two file for analyse if the state of services change... for example if the current_state.txt contain this:
Code: Select all
SERVICE_NAME: spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 1 STOPPED
(STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
How can comparing a file and if are different lunch another .bat ???
For comparing, i can lunch: " fc original_state.txt currentent_state.txt /n " and this is the output:
Code: Select all
***** original_state.txt
3: TYPE : 110 WIN32_OWN_PROCESS (interactive)
4: STATE : 4 RUNNING
5: (STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
***** current_state.TXT
3: TYPE : 110 WIN32_OWN_PROCESS (interactive)
4: STATE : 1 STOPPED
5: (STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
*****
Any Idea??? how create an If or other control to analyse if two file are different or equal?
There is another metod???
Thank you in advance and sorry for my poor english.
waiting for your help.
Massimo