Tuesday, September 20, 2011

MS Windows - Self-Monitor Windows Service + Generate Syslog Message

Task Description:
Configure the Windows NMS system (eg: Orion NPM) to monitor the NMS application and database services itself and generate Syslog message to another NMS (eg: SMS gateway) should the services fail.

Steps:
1. Create a Windows batch file named script.cmd with the following content.
@echo off

tasklist | findstr svchost1.exe > NUL
REM *** %ERRORLEVEL% : 0 - FOUND | 1 - NOT FOUND ***
IF NOT %ERRORLEVEL% == 0 (start logger -l 127.0.0.1 The database service is down!)
Note: Modify the Windows service name and Syslog server IP address accordingly.

2. Download Adiscon Logger 1.3 (the Syslog client / generator) via http://www.monitorware.com/en/logger/download.asp.

3. Extract the logger.exe into the same directory as the script.cmd resides.

4. Schedule the script using Windows Task Scheduler.

Testing and Verification:

The content of the 3CDaemon syslog.log:
Sep 19 12:17:48 local Listening for Syslog messages on IP address: 10.34.10.177
Sep 19 12:17:48 local Listening for Syslog messages on IP address: 192.168.11.1
Sep 19 12:17:48 local Listening for Syslog messages on IP address: 192.168.18.1
Sep 19 12:18:06 127.0.0.1 Sep 19 12:18:06 DCMYKULMS-LT136 The database service is down!

No comments:

Post a Comment