NSClient documentation

ClearCentral Software Inc. - support.tsmgsoftware.com
Original author - Yves Rubin – rubiyz1047@swyz.com

Contents

Purpose
License
Requirements
History
Features
Installation
Uninstallation
Configuration
Plugin Syntax
        CPU Load
        Disk Usage
        Uptime
        Service States
        Process States
        Client Version
        Memory Usage
        File Age Usage
        Custom Counter
        Instances
Technical Information
Problems
Known Issues


Purpose

NSClient has been developed to get performance information from Windows Servers and return them to Nagios using the check_nt client. In addition to the standard metrics, a generic COUNTER function is provided to return the value of any counter maintained by Windows.


License

This software is released under the GNU General Public License. A copy of the license is included here.


Requirements

For compilation:

    These must downloaded, extracted and added to your Delphi library path.

    These must be installed on your development system. There are automatically added to the Delphi environment.


History

29.11.2000 - 1.02

  • First release by original author

7.5.2003
21.5.2003
  • version 1.0.8.3
  • enhanced error logging to Event Log on startup
  • enhancement to FILEAGE, return format is now determined by adding section to the -l variable to include a format string. See the File Age Usage section for details.
  • new INSTANCES parameter, see Instances section for details.
  • these last two new features require new version of check_nt included in both source and binary form in this package
21.10.2003
  • version 2.0
  • bug fix to memory leak (thanks to Yves Rubin)
  • official transfer of maintenance of NSClient to ClearCentral Software Inc. from Yves Rubin
23.10.2003
  • version 2.0.1
  • bug fix to check file age when file is missing
  • bug fix to check_nt.c in check disk space (thanks to Phil Randall)
  • bux fix to returned date of file in FILEAGE check, timezone correction was being applied twice - once by NSClient and once by check_nt. Now the timezone correction is done by NSClient and will report the file date/time as it exists on the Windows server
  • enhancement to FILEAGE that now permits wildcards, See the File Age Usage section for details.


Features

|
Installation

On the Windows machine

  1. Copy pNSClient.exe, pdh.dll, psapi.dll and counters.defs in any directory on the machine you want to monitor. ie. (c:\nsclient).
  2. Open a dos prompt in the installation directory
  3. Run the following command : >pNSClient.exe /install
  4. Type 'net start nsclient' on the command line or start the service 'Nagios Agent' in the services applet of the control panel.

The installation will create an entry for the service in the registry and create a new key to store parameters. The created key is the following:

HKEY_LOCAL_MACHINE\SOFTWARE\NSClient

Please read if you are using another Windows version than English !

The cpu load, disk usage, uptime and memory usage parameters are collected internally using queries to the Windows performance counters. These counters are language-specific. The language of a version of Windows is defined by a hex code (English is 0x049)  Additionally, the System Processor usage counter changed from Windows NT to Windows 2000/XP.A file “counters.defs” is in the NSClient folder. This file contains translations of the counter names into various other languages organized by the languages hex code and operating system version. On startup, NSClient looks up the operating system version and language code and then queries the file for the appropriate counter names. If you are using a language that is not included in the file, it must be added for NSClient to function correctly. These is no requirement to add any other counters to this file.

On the Unix machine

  1. Copy the file 'check_nt' under the libexec folder of Nagios.
  2. Add the following lines to the commands.cfg file:

# NSClient basic return types

command[check_nt_disk]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v USEDDISKSPACE -l $ARG1$ -w $ARG2$ -c $ARG3$
command[check_nt_cpuload]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v CPULOAD -l $ARG1$
command[check_nt_uptime]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v UPTIME
command[check_nt_clientversion]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v CLIENTVERSION
command[check_nt_process]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v PROCSTATE -l $ARG1$
command[check_nt_service]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v SERVICESTATE -l $ARG1$
command[check_nt_memuse]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v MEMUSE -w $ARG1$ -c $ARG2$
command[check_nt_fileage]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v FILEAGE –l $ARG1$ -w $ARG2$ -c $ARG3$

# Custom counters (one per required counter, or define a generic one and use $ARG1$ to specify the requested counter).

command[check_nt_pagingfile]=$USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v COUNTER -l "
\\Paging File(_Total)\\%% Usage","Paging File usage is %.2f %%" -w $ARG1$ -c $ARG2$


Uninstallation

  1. Go to the installation directory and run the following command: >pNSClient.exe /uninstall (ensure that the services applet and Event Viewer are closed).

All entries in the registry will be removed as well as the definition of the service..


Configuration

There are two parameters you can change: the port (default: 1248) and the password (default: 'None'). These two settings are store in the registry and can only be changed using 'regedit'. Open the following key and change the values if needed :

HKEY_LOCAL_MACHINE\SOFTWARE\NSClient\Parms

If you change the password, you will have to use the -s <password> with every request you send to NSClient.


Plugin Syntax

CPU Load

Syntax: check_nt -H <hostname> -p <port> -v CPULOAD -l <minutes range>,<warning percent>,<critical percent>

You can check several intervals in one shot. The follwing command get the average for the last 10min., 60min. and 24hours.

Example:
./check_nt -H 192.168.1.1 -p 1248 -v CPULOAD -l 10,80,95,60,80,95,1440,80,95


Disk Usage

Syntax: check_nt -H <hostname> -p <port> -v USEDDISKSPACE -l <drive letter> [-w <warning percent> ] [-c <critical percent>]

Example:
./check_nt -H 192.168.1.1 -p 1248 -v USEDDISKSPACE -l C -w 80 -c 90


Uptime

Syntax: ./check_nt -H <hostname> -p <port> -v UPTIME

This plugin doesn't care about warning or critical values. Only the uptime of the machine is received.


Services States

Syntax: check_nt -H <hostname> -p <port> -v SERVICESTATE [-d SHOWALL] -l <service 1>[,<service 2>,<service 3>,...]

or use the free utility: 'Service Manager NT' : http://www-rnks.informatik.tu-cottbus.de/~fsch/english/nttols.htm

You can specify serveral services in one request. No blank should appear in the list !

If not all services are running, you get the faulty one(s) and a critical state.

Example:
./check_nt -H 192.168.1.1 -p 1248 -v SERVICESTATE -d SHOWALL -l LanmanServer,Schedule


Processes States

Syntax: check_nt -H <hostname> -p <port> -v PROCSTATE [-d SHOWALL] -l <process 1>[,<process 2>,<process 3>,...]

You can specify serveral processes in one request. No blank should appear in the list !

If not all processes are running, you get the faulty one(s) and a critical state.

Example:
./check_nt -H 192.168.1.1 -p 1248 -v PROCSTATE -d SHOWALL -l McShield.exe,RASMAN.EXE


Client Version

Syntax: check_nt -H <hostname> -p <port> -v CLIENTVERSION

Return the NSClient version. No warning or critical threshold can be specified.


Memory Usage

Syntax: check_nt -H <hostname> -p <port> -v MEMUSE [-w <warning percent> ] [-c <critical percent>]

Example: 
./check_nt -H 192.168.1.1 -p 1248 -v MEMUSE -w 80 -c 90


File Age Usage

Syntax: check_nt -H <hostname> -p <port> -v FILEAGE –l <filename>[,<date format>] [-w <warning> ] [-c <critical >]

strftime(description, 50, "Date: %D %I:%M:%S %p", localtime(&rettime));

Change the "Date: %D %I:%M:%S %p" part to what you want as a default and then compile it.

Example: 
./check_nt -H 192.168.1.1 -p 1248 -v FILEAGE –l "c:\\program files\\nsclient\\pnsclient.exe" -w 1440 -c 2880
./check_nt -H 192.168.1.1 -p 1248 -v FILEAGE -l "c:\\program files\\nsclient\\pnsclient.exe","Date: %d-%m-%Y %I:%M:%S %p" -w 1440 -c 2880


Custom Counter

Syntax: check_nt -H <hostname> -p <port> -v COUNTER -l <counter name>[,<counter description>] [-w <warning percent> ] [-c <critical percent>]

The results returned by NSClient have five decimal digits.

Example: 
./check_nt -H 192.168.1.1 -p 1248 -v COUNTER -l "\\Paging File(_Total)\\%% Usage","Paging file usage is %.2f %%" -w 80 -c 90
./check_nt -H 192.168.1.1 -p 1248 -v COUNTER -l "\\Process(_Total)\\Thread Count","Thread Count: %.f" -w 600 -c 800
./check_nt -H 192.168.1.1 -p 1248 -v COUNTER -l "\\Server\\Server Sessions","Server Sessions: %.f" -w 20 -c 30  


Instances

Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>

Example

./check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process

 


Technical information

Windows agent

NSClient has been developed using Borland Delphi 7. It is installed as a service.

Every five seconds, NSClient query Windows to get the CPU load and store this information in a circular buffer which keeps the measures for the last 24 hours. It also collects the uptime, memory and disk utilization metrics every 5 seconds and stores them in global variables. When requested, the client returns these results from the global variables.

Have a look at the source code in case you want to know more about it. It's well documented so you shouldn't have too much pain to figure out how it works. Some functions and pieces of code where found on the internet, so I thank very much the programmers who release them as open source. When possible, credits are left in the code.

Unix plug in

The Unix plugin has been written in C, using a template by Ethan Galstad. It mostly uses common functions and should be compiled in the same directory as all other plugins. I hope that it will be included in the common distribution. 


Problems

In case of problems, have a look at the Event Log of the machine. You should find messages from Nagios with an error code in hexadecimal. The corresponding English description can be found in NTSource\pdhmsg.pas.

Known Issues