Novell Home

Monitoring IDM, Using Nagios for Windows

Novell Cool Solutions: Feature
By Adam Bradley

Digg This - Slashdot This

Posted: 26 Jul 2006
 

To monitor IDM using Nagios (for Windows), there are several tasks required. This article covers the following topics:

  • IDM Configuration
  • Nagios Server Configuration
  • Scripting the Nagios Service Availability File
  • Using NSJS with Nagios
  • Nagios Configuration with NSJS

Note: This solution was tested in an environment with Windows 2k/2k3 and Windows Scripting Host - Nagios.

IDM Configuration

1. Enable Publisher Heartbeat for each driver and set to a suitable interval.

2. Configure an IDM policy to detect this heartbeat and configured to call a script called "touch.vbs" (use a custom class to call the script - see following) and pass as a parameter to this script the driver name (in order to accurately name the file)

3. Use a Nagios agent to determine service availability (timestamp of the file).

4. Check for Port Availability. If a driver does not support the Driver Heartbeat facility, port level monitor will be required.

Nagios Server Configuration

1. Add IDM servers to hosts.cfg to allow host availability checking. Add additional entries to the services.cfg file for each IDM service (connector).

Publisher Command Policy (Unix)

<?xml version="1.0" encoding="UTF-8"?>
<policy mlns:Utils="<http://your.provider.com/your/provider/exec>">
<rule>
<description>Submit passive service check to Nagios</description>
<conditions>
<and>
<if-xpath op="true">self::status[@type='heartbeat']</if-xpath>
</and>
</conditions>
<actions>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">AJB Heartbeat</token-text>
</arg-string>
</do-trace-message>
<do-set-local-variable name="driverName">
<arg-string>
<token-escape-for-src-dn>
<token-text xml:space="preserve">~dirxml.auto.driverdn~</token-text>
</token-escape-for-src-dn>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="shortDriverName">
<arg-string>
<token-xpath expression="jstring:substring($driverName,jstring:lastIndexOf($driverName,'\')+1)"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="nagiosExecString">
<arg-string>
<token-global-variable name="wshPath"/>
<token-text xml:space="preserve"> </token-text>
<token-global-variable name="nagiosAgentPath"/>
<token-text xml:space="preserve"> </token-text>
<token-text xml:space="preserve">"</token-text>
<token-global-variable name="nagiosLogPath"/>
<token-text xml:space="preserve">"</token-text>
<token-text xml:space="preserve"> </token-text>
<token-text xml:space="preserve">"</token-text>
<token-local-variable name="shortDriverName"/>
<token-text xml:space="preserve">"</token-text>
</arg-string>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-local-variable name="nagiosExecString"/>
</arg-string>
</do-trace-message>
<do-set-local-variable name="nagiosResult">
<arg-string>
<token-xpath expression="Utils:exec($nagiosExecString)"/>
</arg-string>
</do-set-local-variable>
</actions>
</rule>
</policy>

Use a script to write the Nagios service availability file, touch.vbs. For example:

'// Script : touch.vbs
'// Purpose: Used to update <driver>.log file for Nagios testing - 
'//script called from IDM heartbeat.  
'// Usage  : touch.vbs <path> <drivername> To be run from IDM. 
'// All logs are located in drive:\idm\logs with the file extensions ihb
'// Author : Adam Bradley
'// Editors:
'// Usage: touch.vbs <path_to_log_files> <log_file_name>

Const ForWriting = 2

Dim oFso
Dim tf
Dim filePath 

Dim debug
Dim fileExists

' // Turns on messagebox's - do not enable when calling from the Heartbeat!
debug = 0

' // Turn off error trapping
On Error Resume Next

Set Wsh = WScript.CreateObject("Wscript.Shell")
Set oFso = CreateObject("Scripting.FileSystemObject")

Function ReportFileStatus(filespec)
   Dim fso, localFlag
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FileExists(filespec)) Then
      localFlag = 1
   Else
      localFlag = 0
   End If
   ReportFileStatus = localFlag
End Function

' // Construct the full path to the file
filePath = Wsh.arguments(0) & "\" & Wsh.arguments(1) & ".ihb"
if (debug) then Wscript.Echo(filePath)

' // Check to see if the file exists
fileExists = ReportFileStatus(filePath)

if (fileExists = 1) then
if (debug) then MsgBox("File exists")
else
if (debug) then MsgBox("File does not exist")
end if

' // For Windows, the same method can be used for both cases
Set tf = oFso.OpenTextFile(filePath, ForWriting, True)
tf.Close

' // Close the scripting engine
Wscript.Quit

Using NSJS

1. Enable a Heartbeat for each driver and set it to a minimum of 120 seconds (sufficient time for the NSJS Client Service to run - see below).

2. Configure a policy to detect this heartbeat.

3. Call a script and pass it a number of parameters, including service name, description, etc. (explained in the NagiosClient configuration section below). The script is responsible for calling the nsjs client to pass the passive service notification to Nagios.

Nagios Configuration with NSJS

1. Add IDM servers to the hosts.cfg file to allow host availability checking.

2. Add additional entries to the services.cfg file for each IDM service (connector).

NSJS Server

1. Run the NSJS Server component (nsjsd) on the Nagios server.

2. Ensure a JRE is available.

3. Modify the nsjsd.cfg and update the command_file entry to point to the nagios.cmd file (socket) usually located at /usr/local/nagios/var/rw/nagios.cmd

4. Add host= entries for each IDM server that will connect.

5. Ensure the entry includes a valid _Nagios_ host and the port on the Nagios server the NSJS client is allowed to connect on (e.g., name=idm.com:6789).

NSJS Client

The NSJS Client component (nsjc) is located on the IDM server and called by a script (nsjc.sh or nsjc.bat). Arguments to the script include:

  • Hostname/ip address of the Nagios server running the NSJS Server component
  • Nagios service name
  • Nagios status code
  • Service description
  • Port where the NSJS Server component is listening
  • Timeout value (at least 60 seconds, specified in milliseconds)


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell