NSCLIENT++可以采集的指标

Documentation
Information
Commands/Modules
CheckDisk
CheckFileSize
CheckDriveSize
CheckFile
CheckEventLog
CheckSystem
CheckCPU
CheckUpTime
CheckServiceState
CheckProcState
CheckMem
CheckCounter
CheckHelpers
CheckAlwaysOK
CheckAlwaysCRITICAL
CheckAlwaysWARNING
CheckMultiple
FileLogger
NRPEListener
NSClientListener
SysTray
CheckWMI
CheckWMIValue
RemoteConfiguration
CheckExternalScripts
LUAScript
Guide
NSCAAgent
Donate
CheckDisk.dll
The CheckDisk module has various disk related checks currently focusing on size. But hopefully it will be extended with date existence and many other disk related checks in the future. Feel free to request checks that you need.
• CheckFileSize, Check the size of one or more files or directories.
• CheckDriveSize, Check the size of one or more Drives
• CheckFile, Check various aspects on one or more files or directories.
Configuration
This module has no configuration directives.
CheckFileSize
CheckFileSize is part of the wiki:CheckDisk module
This check does a recursive size calculation of the directory (or file) specified. A request has one or more options described in the table below. The order only matter in that the size has to be specified before the File option this becaous you can change the size for each drive by specifying multiple Size options.
Option Values Description
MaxWarn
size-value
The maximum size the directory is allowed before a warning state is returned.
MaxCrit
size-value
The maximum size the directory is allowed before a critical state is returned.
MinWarn
size-value
The minimum size the directory is allowed before a warning state is returned.
MinCrit
size-value
The minimum size the directory is allowed before a critical state is returned.
ShowAll
None A Boolean flag to show size of directories that are not in an alarm state. If this is not specified only drives with an alarm state will be listed in the resulting string.
File File or directory name The name of the file or directory that should have its size calculated. Notice that large directory structures will take a long time to check.
File:<alias> File or directory name Same as the file option but using a short alias in the returned data.
The size-value is a normal numeric-value with a unit postfix. The available postfixes are B for Byte, K for Kilobyte, M for Megabyte and finally G for Gigabyte.
Examples
Check the size of the windows directory and make sure it stays below 1 gigabyte:
CheckFileSize ShowAll MaxWarn=1024M MaxCrit=4096M File:WIN=c:\WINDOWS\*.*
WARNING: WIN: 2G (2325339822B)|WIN=2325339822;1073741824;4294967296
define command {
command_name CheckFileSize
command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MaxWarn=$ARG1$ MaxCrit=$ARG2$ File:$ARG4$=$ARG5$
}
check_command CheckFileSize!1024M!4096M!WIN!c:\WINDOWS\*.*
Check the size of the pagefile.sys and make sure it stays above 1 gigabyte:
CheckFileSize ShowAll MinWarn=1G MinCrit=512M File=c:\pagefile.sys
OK: c:\pagefile.sys: 1G (1610612736B)
define command {
command_name CheckPageFile
command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MinWarn=$ARG1$ MinCrit=$ARG2$ File:PageFile=c:\pagefile.sys
}
check_command CheckPageFile!1G!512M
Sample of using individual size for multiple files.:
CheckFileSize MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
OK all file sizes are within bounds.
define command {
command_name CheckMyFiles
command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
}
check_command CheckMyFiles
I have had to set this up like this for our Windows Servers
# Check File Size === Greg Small
define command {
command_name CheckFileSize
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a MaxWarn=$ARG1$ MaxCrit=$ARG2$ File=$ARG3$
}

define service{
use xx-app-service
host_name SERVER01
service_description Information store database
check_command CheckFileSize!13G!15.5G!'d:\\exchsrvr\\mdbdata\\priv1.edb'
}
CheckDriveSize
CheckDriveSize is part of the CheckDisk module
This check verifies the size of various drives specified on the command line. A request has one or more options described in the table below. The order only matters in that the size has to be specified before the Drive option because you can change the size for each drive by specifying multiple Size options.
Option Values Description
MaxWarnFree size-value or %
The maximum allowed free space for the drive(s).
MaxCritFree size-value or %
The maximum allowed free space for the drive(s).
MinWarnFree size-value or %
The minimum allowed free space for the drive(s).
MinCritFree size-value or %
The minimum allowed free space for the drive(s).
MaxWarnUsed size-value or %
The maximum allowed used space for the drive(s).
MaxCritUsed size-value or %
The maximum allowed used space for the drive(s).
MinWarnUsed size-value or %
The minimum allowed used space for the drive(s).
MinCritUsed size-value or %
The minimum allowed used space for the drive(s).
ShowAll Empty, long If present will display information even if an item is not reporting a state. If set to long will display more information.
Drive A Drive letter or the path of a mounted Volume The letter of the drive to check.
FilterType FIXED, CDROM, REMOVABLE, REMOTE Filter for drive type to prevent checking drives of certain kinds (most useful when using CheckAll?). The default is FIXED
CheckAll None Check all available drives
CheckAllOthers None Check all drives (matching Filters) except those specified in the Drive= clause.
The size-value or % is a normal numeric-value with an optional unit or percentage postfix to specify large sizes. The available postfixes are B for Byte, K for Kilobyte, M for Megabyte, G for Gigabyte and finally % for percent free space.
Examples
Check the size of C:\ and make sure it has 10% free space:
CheckDriveSize ShowAll MinWarnFree=10% MinCritFree=5% Drive=c:\
CRITICAL: C:: Total: 74.5G - Used: 71.2G (95%) - Free: 3.28G (5%) < critical|C:;5%;10;5;
define command {
command_name CheckDriveSize
command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckDriveSize -a Drive=$ARG1$ ShowAll MaxWarn=$ARG2$ MaxCrit=$ARG3$
}
check_command CheckDriveSize!C:\!50%!75%
To check the size of mounted volume c:\volumne_test and make sure it has 1M free space
CheckDriveSize ShowAll MaxWarn=1M MaxCrit=2M Drive="c:\\volumne_test\\"
CRITICAL: c:\volumne_test\: 3M (4193280B)|c:\volumne_test\=4193280;0;0;
check_command CheckDriveSize!c:\volumne_test\!1M!2M
To check the size of all fixed and network drives and make sure they have atleast 1gig free space
CheckDriveSize MinWarn=50% MinCrit=25% CheckAll FilterType=FIXED FilterType=REMOTE
CRITICAL: D:\: Total: 186G - Used: 186G (99%) - Free: 709M (1%) < warning, Y:\: Total: 279G - Used: 279G (99%) - Free: 384M (1%) < critical|C:\;76514398208;1073741824;536870912; D:\;199303897088;1073741824;536870912; X:\;35467034624;1073741824;536870912; Y:\;299649466368;1073741824;536870912;
define command {
command_name CheckAllDrives
command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckDriveSize -a CheckAll FilterType=FIXED FilterType=REMOTE MinWarn=$ARG1$ MinCrit=$ARG2$
}
check_command CheckAllDrives!25%!50%
Check all fixed and network drives but ignore C and F
define command {
command_name CheckAllDrivesExceptCF
command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckDriveSize -a CheckAllOthers FilterType=FIXED FilterType=REMOTE MinWarn=$ARG1$ MinCrit=$ARG2$ "Drive=C:\\" Drive=F:\\
}
CheckFile
A new command to check a bunch of files.
BETA
Simple draft and subject to change. This works similarily to CheckEventLog and uses filters to filter out (or in) a certain amount of files and then checks the count against a given number reporting an error if the count is not within bounds.
Option Values Description
file A filename, filter or path The files to check for instance c:\*.* will check the entire drive (bad idea) c:\foo\bar\my\file.txt will check only that file.
filter in, out, any, all Specify the way you want to filter things. (See section below)
descriptions None Flag to specify if you want to include string representation of the file data (not implemented yet)
truncate length of the returned set This will truncate the output after the specified length. As NRPE can only handle 1024 chars you need to truncate the output.
MaxWarn
number of records The maximum hits to allow before reporting a warning state.
MaxCrit
number of records The maximum hits to allow before reporting a critical state.
MinWarn
number of records The minimum hits to allow before reporting a warning state.
MinCrit
number of records The minimum hits to allow before reporting a critical state.
filter-size size-expression
The size a file should have.
filter-creation time-expression
Filter on a date (the time is specified from "now" not absolute. so filter-created=>2d will mean files created more then 2 days ago will match.
filter-accessed time-expression
Filter on a date (the time is specified from "now" not absolute.)
filter-written time-expression
Filter on a date (the time is specified from "now" not absolute.)
syntax String A syntax string that describes how each matched file is shown the string can have the following keywords: %filename%, %creation%, %access%, %write%, %size%
Filter
filter = (in, out, any, all) Specify the way you want to filter things.
in means any thing matching this filter will be included in the result.
out means any thing matching this filter will be excluded from the result.
any means any of the filter rules has to match.
all means all of the filter rules have to match.
Thus filter=all filter=in and filter=any filter=out is the combinations that makes the most sense depending on your filter concept.
Examples
This command will check the date of a file (boot.ini) and alert if it's modified (written) date is greater than 3 days (3d).

checkcommand.cfg {
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c CheckFile -a file="$ARG1$" filter-written=\>"$ARG2$" syntax="%filename% last updated %write%" MaxCrit=1
}
service.cfg {
check_command nrpe_check_file_last_written!"C:\\boot.ini"!3d
}
CheckEventLog.dll
The CheckEventLog module checks for problems reported to the windows event log.
• CheckEventLog, Check to find errors in the event log.
Configuration
Option Default value Description
syntax Set this to use a specific syntax string for all commands (that don't specify one)
Advanced options:
Option Default value Description
debug 0 Log all "hits" and "misses" on the eventlog filter chain, useful for debugging eventlog checks but very very very noisy so you don't want to accidentally set this on a real machine.
CheckSystem.dll
A module to check various system related things. A list of the modules and there potential use is listed below here.
• wiki:CheckCPU, Check CPU load
• wiki:CheckUpTime, Check system uptime
• wiki:CheckServiceState, Check state of a service
• wiki:CheckProcState, Check state of a process
• wiki:CheckMem, Check memory usage (page)
Command Line
To simplify debug and setup there is two commandline options that list and test all avalible PDH counters.
• NSClient++ -noboot CheckSystem debugpdh
• NSClient++ -noboot CheckSystem listpdh
Configuration
This module should auto detect most versions of windows (if you have a problem with this let me know so I can update it). Thus you no longer need to configure the grayed out options. There is also some other tweaks that can be configured such as check resolution and buffer size. For more details on how to configure this refer to the Configuration section.
[Check System]
Option Default value Description
CPUBufferSize 1h The time to store CPU load data.
CheckResolution?
10 Time between checks in 1/10 of seconds.
Advanced options:
Option Default value Description
auto_detect_pdh 1 Set this to 0 to disable auto detect (counters.defs) PDH language and OS version.
dont_use_pdh_index 0 Set this to 1 if you dont want to use indexes for finding PDH counters.
force_language Set this to a locale ID if you want to force auto-detection of counters from that locale.
ProcessEnumerationMethod?
auto Set the method to use when enumerating processes PSAPI, TOOLHELP or auto
check_all_services[SERVICE_BOOT_START] ignored Set how to handle services set to SERVICE_BOOT_START state when checking all services
check_all_services[SERVICE_SYSTEM_START] ignored Set how to handle services set to SERVICE_SYSTEM_START state when checking all services
check_all_services[SERVICE_AUTO_START] started Set how to handle services set to SERVICE_AUTO_START state when checking all services
check_all_services[SERVICE_DEMAND_START] ignored Set how to handle services set to SERVICE_DEMAND_START state when checking all services
check_all_services[SERVICE_DISABLED][string expression][numeric expression] Match the column againast a numeric expression
Filter <Columns>s
A Column (if specified) will make the filter woirk againast a specific column in the result set.
string expression
A string expression is a key followed by a string that specifies a string expression. Currently substr and regexp are supported. Thus you enter filter.message=regexp:(foo|bar) to enter a regular expression and filter-message=substr:foo to enter a substring patter match.
Examples
Check to see if there is 2 CPUs present (or cores)
CheckWMI MaxCrit=3 MinWarn=1 "Query:load=Select * from win32_Processor"
Check to see that no CPU has less then 2.66GHz frequency
CheckWMI MinCrit=1 MinWarn=1 "Query:load=Select CurrentClockSpeed from win32_Processor" +filter-numeric:CurrentClockSpeed=<2659
To try a query use the following syntax:
nsclient++ CheckWMI Select * from win32_Processor
(I know these are not very usefull, but hopefully they will give you an idea how to do things, there a *a lot* of things to check via the WMI so you ought to be able to do most things you want.)
CheckWMIValue
CheckWMIValue is part of the wiki:CheckWMI module.
It is still alpha need to do more testing but I would like to get some initialö feedback on the syntax and such. Also feel free to try it out and report bugs to me (might wanna keep track of memory and such as I have not done so myself yet) To debug and help you setup your queries there is also a command line interface to run queries and see the result.
nsclient++ CheckWMI <query>
The syntax for this is Similar to other check commands so it should be pretty straight forward to set it up. The plugin will run a WMI query and check the returned columns against bounds provided by the checker (nagios) and report the result.
Option Values Description
MaxWarn Numeric value The maximum allowed value for the column(s).
MaxCrit Numeric value The maximum allowed value for the column(s).
MinWarn Numeric value The minimum allowed value for the column(s).
MinCrit Numeric value The minimum allowed value for the column(s).
ShowAll Empty, long If present will display information even if an item is not reporting a state. If set to long will display more information.
Query WMI Query The WMI query to ask (not stackable, only one query at a time)
Check A column name A column name to check (if * all columns will be checked) (this is stackable, so you can compare any number of columns)
truncate numeric value The maximum length of the query-result.
AliasCol?
Column name A column to be included (prefixed) in the alias for matching columns.
Examples
Check to see if there is 2 CPUs present (or cores)
CheckWMI MaxCrit=3 MinWarn=1 "Query:load=Select * from win32_Processor"
Check the CPU load on all CPUs and warn if above 50 and critical if above 80
CheckWMIValue "Query=Select * from win32_Processor" MaxWarn=50 MaxCrit=80 Check:CPU=LoadPercentage ShowAll=long
To try a query use the following syntax:
nsclient++ CheckWMI Select * from win32_Processor
Check threads in processes and make sure a process does not have more then 50 threads (critical at 100)
CheckWMIValue "Query=select Caption, ThreadCount from Win32_Process" MaxWarn=50 MaxCrit=100 Check:threads=ThreadCount AliasCol=Caption
Gives you:
System threads: 98 > warning, svchost.exe threads: 87 > warning|'System Idle Process threads'=2;50;100; 'System threads'=98;50;100; 'smss.exe threads'=3;50;100; 'csrss.exe threads'=13;50;100; 'winlogon.exe threads'=21;50;100; 'services.exe threads'=18;50;100; 'lsass.exe threads'=21;50;100; 'svchost.exe threads'=19;50;100; 'svchost.exe threads'=11;50;100; 'svchost.exe threads'=87;50;100; 'svchost.exe threads'=6;50;100; 'svchost.exe threads'=18;50;100; 'aswUpdSv.exe threads'=3;50;100; 'ashServ.exe threads'=28;50;100; 'sdmcp.exe threads'=3;50;100; 'spoolsv.exe threads'=11;50;100; 'svchost.exe threads'=4;50;100; 'MSCamS32.exe threads'=5;50;100; 'nTuneService.exe threads'=4;50;100; 'nvsvc32.exe threads'=4;50;100; 'svchost.exe threads'=7;50;100; 'tlswrap.exe threads'=4;50;100; 'vmount2.exe threads'=4;50;100; 'vmnat.exe threads'=3;50;100; 'vmnetdhcp.exe threads'=2;50;100; 'vmware-authd.exe threads'=7;50;100; 'ashMaiSv.exe threads'=8;50;100; 'ashWebSv.exe threads'=22;50;100; 'alg.exe threads'=5;50;100; 'explorer.exe
(I know these are not very usefull, but hopefully they will give you an idea how to do things, there a *a lot* of things to check via the WMI so you ought to be able to do most things you want.)
CheckExternalScripts.dll
This module allows you to check external scripts and/or programs.
Configuration
[External Script]
Configure how the External Scripts module works (not to be confused with the "External Scripts" section below that holds scripts that can be run.
Option Default value Description
command_timeout 60 The maximum time in seconds that a command can execute. (if more then this execution will be aborted). NOTICE this only affects external commands not internal ones.
allow_arguments 0 A Boolean flag to determine if arguments are accepted on the incoming socket. If arguments are not accepted you can still use external commands that need arguments but you have to define them in the NRPE handlers below. This is similar to the NRPE "dont_blame_nrpe" option.
allow_nasty_meta_chars 0 Allow NRPE execution to have “nasty” meta characters that might affect execution of external commands (things like > “ etc).
script_dir When set all files in this directory will be available as scripts. This is pretty dangerous but can be a bit useful if you use many scripts and you are sure no one else can add files there.
[External Scripts]
A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments> for instance:
check_es_long=scripts\long.bat
check_es_ok=scripts\ok.bat
check_es_nok=scripts\nok.bat
check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs
[External Alias]
Works like the "inject" concept of NRPE scripts module. But in short a list of aliases available. An alias is an internal command that has been "wrapped" (to add arguments). Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_service=checkServiceState CheckAll
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=physical
LUAScript.dll
This module allows you to write and change checks in the Lua scripting language. For a quite "guide" on how to write scripts for NSClient++ see the LUAScript/guide page. For information on the Lua scripting language and built-in modules and commands refer to the official Lua pages at: http://www.lua.org/ and http://lua-users.org/wiki/SampleCode
Configuration
[LUA Scripts]
A list of LUA script to load at startup. In difference to "external checks" all LUA scripts are loaded at startup. Names have no meaning since the script (on boot) submit which commands are available and tie that to various functions.
[LUA Scripts]
scripts\test.lua
This is just a quick intro, I will try to add more info here and also try to add more system related functions (like WMI and performance counter access) in the future.
Debugging Lua
Use the print statement to print to the console (can bee sen from nsclient++ /test).
With a Lua script like this loaded:
register_command('lua_debug', 'debug')

function debug (command)
print ('Hello world: ' .. command)
end
Then you run nsclient++ /test:
nsclient++ /test
...
lua_debug Greetings
...
d \nsclient++.cpp(540) Injecting: lua_debug: Greetings
Hello world: lua_debug
e \script_wrapper.hpp(280) No arguments returned from script.
l \nsclient++.cpp(575) No handler for command: 'lua_debug'
A simple script
print('Loading test script...') -- Just print some debug info

register_command('check_something', 'something') -- Register a check-command to a function

function something (command)
-- Check command function (notice arguments are not supported yet)

-- Inject and run another check command
code, msg, perf = inject('CheckCPU','time=5','MaxCrit=5')
-- Print the resulting code
print(code .. ': ' .. msg .. ', ' .. perf)
-- Return the information (slightly modified)
return code, 'hello from LUA: ' .. msg, perf
end
Structure of a script
First all script register all commands they will use (it is possible to register commands at a later time) So you could have a command that "turn on" other commands, but since there is no "turn off" (ie. remove) it does not make much sense as of yet.
To register command you call the register_command function like so:
register_command('command_alias', 'function_in_lua_to_use');
This will when the command command_alias is run execute the function_in_lua_to_use in your script. You can have as many commands as you like so the following is possible:
register_command('lua_1', 'lua_function_1');
register_command('lua_2', 'lua_function_2');
register_command('lua_3', 'lua_function_3');
register_command('lua_4', 'lua_function_4');
register_command('lua_5', 'lua_function_5');
The functions have the following syntax:
function lua_check_function (command)
print ('Hello world: ' .. command)
return 'ok', 'Everything is fine!', 'fine=10%;80;90;'
As of now there are no support for arguments but in the future they will be added. Printing from a check_function is useless (apart from debug) so generally don't do that. The return is a variable list If;
• 3 options are returned they are assumed to be in order: code, message and performance data
• 2 options are returned they are assumed to be in order: code, message
• 1 options are returned they are assumed to be in order: code
The code can be:
• crit (critical)
• warn (warning)
• ok (ok)
• error (critical)
A 'useful' script
-- Register the command
register_command('has', 'check_file_exists')

-- Return true if file exists and is readable.
function file_exists(path)
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end

function check_file_exists (command)
if file_exists('c:\\foo.bar') then
return 'ok', 'File exists'
else
return 'crit', 'File does not exist'
end
end


USAGE
TODO
for now:
If you only wish to test it or debug the client you can use the following without installing it first.
NSClient++ /test
When you see this prompt:
Enter command to inject or exit to terminate...
you can paste in examples from the Commands page at CheckCommands. For example, I get this on my system:
C:\Program Files\NSClient++>NSClient++.exe -test
Launching test mode...
d \NSClient++.cpp(375) Loading plugin: CheckDisk...
d \NSClient++.cpp(375) Loading plugin: CheckSystem...
d \CheckSystem.cpp(79) Autodetected W2K>, using TOOLHELP process enumeration.
d \PDHCollector.cpp(83) Autodetected w2k or later, using w2k PDH counters.
d \NSClient++.cpp(375) Loading plugin: NSClient server...
d \PDHCollector.cpp(103) Detected language: English US (0x0409)
l \NSClient++.cpp(123) Using settings from: INI-file
d \Socket.h(538) Bound to: 0.0.0.0:12489
l \NSClient++.cpp(124) Enter command to inject or exit to terminate...
CheckDriveSize ShowAll MinWarnFree=10% MinCritFree=5% Drive=c:\
d \NSClient++.cpp(440) Injecting: CheckDriveSize: ShowAll, MinWarnFree=10%, MinC
ritFree=5%, Drive=c:\
d \NSClient++.cpp(460) Injected Result: OK 'OK: c:\: 12.3G'
d \NSClient++.cpp(461) Injected Performance Result: ''c:\'=38%;10;5; '
OK:OK: c:\: 12.3G|'c:\'=38%;10;5;
exit
d \NSClient++.cpp(349) Unloading plugin: NSClient server...
d \Socket.h(558) Listener is preparing to shutdown...
d \NSClient++.cpp(349) Unloading plugin: CheckSystem...
d \NSClient++.cpp(349) Unloading plugin: CheckDisk...

C:\Program Files\NSClient++>

Configuration
Configuration is fairly simple and straight forward. Open the configuration file in notepad (or you favorite editor) "notepad <installation path>\NSC.ini" and edit it accordingly. A longer description of the Configuration file is included in the following page.
The file has sections (denoted with section name in brackets) and key/value pairs (denoted by key=value). Thus it has the same syntax as pretty much any other INI file in windows.
The sections are described in short below. The default configuration file has a lot of examples and comments so make sure you change this before you use NSClient++ as some of the examples might be potential security issues.
The configuration can also be stored in the system registry (HKLM\Software\NSClient++) there is currently no UI to configure this so the simplest way is to maintain the configuration in the INI file and "Migrate that" to the registry. This is can be done via the [RemoteConfiguration] module but in short:
NSClient++ -noboot RemoteConfiguration ini2reg
A sample configuration file is included in the download but can also be found here trunk/NSC.dist
Modules
This is a list of modules to load at startup. All the modules included in this list has to be NSClient++ modules and located in the modules subdirectory. This is in effect the list of plug-ins that will be available as the service is running. For information on the various plug-ins check the Modules section in the navigation box.
A good idea here is to disable all modules you don’t actually use for two reasons. One less code equals less potential security holes and two less modules means less resource drain.
Settings
This section has generic options for how NSClient++will work, some of these settings (such as allowed_hosts) is inherited in sections below so it is probably a better idea to set them here in the "global" section.
The options you have available here are
Option Default value Description
obfuscated_password ... An obfuscated version of password. For more details refer to the password option below. To create the obfuscated Password use: "NSClient++.exe /encrypt"
password ... The password used by various (presently only NSClient) daemons. If no password is set everyone will be able to use this service remotely.
allowed_hosts 127.0.0.1 A list (comma separated) with hosts that are allowed to connect and query data. If this is empty all hosts will be allowed to query data. BEWARE: NSClient++ will not resolve the IP address of DNS entries if the service is set to startup automatically. Use an IP address instead.
use_file 0 Has to be set to 1 if you want the file to be read (if set to 0, and the use_reg is set to 1 the registry will be used instead)
Advanced options:
Option Default value Description
master_key ... The secret "key" used when (de)obfuscating passwords.
cache_allowed_hosts 1 Used to cache looked up hosts if you check dynamic/changing hosts set this to 0.
Log
This section has options for how logging is performed. First off notice that for logging to make sense you need to enable the “FileLogger.dll” module that logs all log data to a text file in the same directory as the NSClient++ binary if you don’t enable any logging module nothing will be logged.
The options you have available here are
Option Default value Description
debug 0 A Boolean value that toggles if debug information should be logged or not. This can be either 1 or 0.
file nsclient.log The file to write log data to. If no directory is used this is relative to the NSClient++ binary.
date_mask %Y-%m-%d %H:%M:%S The date format used when logging to a file
NSClient
This is the NSClient module configuration options.
Option Default value Description
port 12489 The port to listen to
obfuscated_password An obfuscated version of password. For more details refer to the password option below.
password The password that incoming client needs to authorize themselves by. This option will replace the one found under Settings for NSClient. If this is blank the option found under Settings will be used. If both are blank everyone will be granted access.
allowed_hosts A list (coma separated) with hosts that are allowed to poll information from NSClient++. This will replace the one found under Setting for NSClient if present. If not present the same option found under Settings will be used. If both are blank all hosts will be allowed to access the system. BEWARE: NSClient++ will not resolve the IP address of DNS entries if the service is set to startup automatically. Use an IP address instead or set cache_allowed_hosts=0 see above.
bind_to_address The address to bind to when listening to sockets, useful if you have more then one NIC/IP address and want the agent to answer on a specific one.
socket_timeout 30 The timeout when reading packets on incoming sockets. If the data has not arrived within this time we will bail out. and discard the connection.
version auto The version number to return for the CLIENTVERSION check (useful to "simulate" an old/different version of the client, auto will be generated from the compiled version string inside NSClient++
Advanced options:
Option Default value Description
socket_back_log Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts. This is an advanced option and should not be used.
NRPE
This is configuration for the NRPE module that controls how the NRPE listener operates.
Option Default value Description
port 5666 The port to listen to
allowed_hosts A list (coma separated) with hosts that are allowed to poll information from NRPE. This will replace the one found under Setting for NRPE if present. If not present the same option found under Settings will be used. If both are blank all hosts will be allowed to access the system
use_ssl 1 Boolean value to toggle SSL encryption on the socket connection
bind_to_address The address to bind to when listening to sockets.
command_timeout 60 The maximum time in seconds that a command can execute. (if more then this execution will be aborted). NOTICE this only affects external commands not internal ones.
allow_arguments 0 A Boolean flag to determine if arguments are accepted on the incoming socket. If arguments are not accepted you can still use external commands that need arguments but you have to define them in the NRPE handlers below. This is similar to the NRPE "dont_blame_nrpe" option.
allow_nasty_meta_chars 0 Allow NRPE execution to have “nasty” meta characters that might affect execution of external commands (things like > “ etc).
socket_timeout 30 The timeout when reading packets on incoming sockets. If the data has not arrived within this time we will bail out. and discard the connection.
script_dir Load all scripts in a directory and use them as commands. Probably dangerous but usefull if you have loads of scripts :)
Advanced options:
Option Default value Description
performance_data 1 Send performance data back to nagios (set this to 0 to remove all performance data)
socket_back_log Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts. This is an advanced option and should not be used.
string_length 1024 Length of payload to/from the NRPE agent. This is a hard specific value so you have to "configure" (read recompile) your NRPE agent to use the same value for it to work.
Check System
Here you can set various options to configure the System Check module.
Option Default value Description
CPUBufferSize 1h The time to store CPU load data.
CheckResolution?
10 Time between checks in 1/10 of seconds.
Advanced options:
Option Default value Description
auto_detect_pdh 1 Set this to 0 to disable auto detect (counters.defs) PDH language and OS version.
dont_use_pdh_index 0 Set this to 1 if you dont want to use indexes for finding PDH counters.
force_language Set this to a locale ID if you want to force auto-detection of counters from that locale.
ProcessEnumerationMethod?
auto Set the method to use when enumerating processes PSAPI, TOOLHELP or auto
check_all_services[SERVICE_BOOT_START] ignored Set how to handle services set to SERVICE_BOOT_START state when checking all services
check_all_services[SERVICE_SYSTEM_START] ignored Set how to handle services set to SERVICE_SYSTEM_START state when checking all services
check_all_services[SERVICE_AUTO_START] started Set how to handle services set to SERVICE_AUTO_START state when checking all services
check_all_services[SERVICE_DEMAND_START] ignored Set how to handle services set to SERVICE_DEMAND_START state when checking all services
check_all_services[SERVICE_DISABLED] stopped Set how to handle services set to SERVICE_DISABLED state when checking all services
MemoryCommitLimit?
\Memory\Commit Limit Counter to use to check upper memory limit.
MemoryCommitByte?
\Memory\Committed Bytes Counter to use to check current memory usage.
SystemSystemUpTime?
\System\System Up Time Counter to use to check the uptime of the system.
SystemTotalProcessorTime?
\Processor(_total)\% Processor Time Counter to use for CPU load.
ProcessEnumerationMethod?
auto Set the PROCESS enumeration method (auto or TOOLHELP or PSAPI)
External Script
Configure how the External Scripts module works (not to be confused with the "External Scripts" section below that holds scripts that can be run.
Option Default value Description
command_timeout 60 The maximum time in seconds that a command can execute. (if more then this execution will be aborted). NOTICE this only affects external commands not internal ones.
allow_arguments 0 A Boolean flag to determine if arguments are accepted on the incoming socket. If arguments are not accepted you can still use external commands that need arguments but you have to define them in the NRPE handlers below. This is similar to the NRPE "dont_blame_nrpe" option.
allow_nasty_meta_chars 0 Allow NRPE execution to have “nasty” meta characters that might affect execution of external commands (things like > “ etc).
script_dir When set all files in this directory will be available as scripts. This is pretty dangerous but can be a bit useful if you use many scripts and you are sure no one else can add files there.
External Scripts
A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments> for instance:
check_es_long=scripts\long.bat
check_es_ok=scripts\ok.bat
check_es_nok=scripts\nok.bat
check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs
External Alias
Works like the "inject" concept of NRPE scripts module. But in short a list of aliases available. An alias is an internal command that has been "wrapped" (to add arguments). Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_service=checkServiceState CheckAll
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=physical
Eventlog
Some options for the EventLog? module.
Option Default value Description
syntax Set this to use a specific syntax string for all commands (that don't specify one)
Advanced options:
Option Default value Description
debug 0 Log all "hits" and "misses" on the eventlog filter chain, useful for debugging eventlog checks but very very very noisy so you don't want to accidentally set this on a real machine.
includes
A list of other configuration files to include when reading this file. Might be useful if you have a very complex setup or want to have setting split up in segments.
NSCA Agent
Options to configure the new NSCA module.
Option Default value Description
interval 60 Time in seconds between each report back to the server (cant as of yet be set individually so this is for all "checks")
nsca_host ... The NSCA/Nagios(?) server to report results to.
nsca_port 5667 The NSCA server port
encryption_method 1 Number corresponding to the various encryption algorithms (see below). Has to be the same as the server or it wont work at all.
password The password to use. Again has to be the same as the server or it wont work at all.
Advanced options:
Option Default value Description
hostname The host name of this host if set to blank (default) the windows name of the computer will be used.
debug_threads 1 Number of threads to run, no reason to change this really (unless you want to stress test something)
Supported encryption methods:
# Algorithm
0 None (Do NOT use this option)
1 Simple XOR (No security, just obfuscation, but very fast)
2 DES
3 3DES (Triple DES)
4 CAST-128
6 xTEA
8 BLOWFISH
9 TWOFISH
11 RC2
14 RIJNDAEL-128 (AES)
20 SERPENT
NSCA Commands
A list of commands to run and submit each time we report back to the NSCA server. A command starting with host_ will be submitted as a host command. For an example see below: This will report back one service check (called my_cpu_check) and one host check (host checks has no service name).
[NSCA Commands]
my_cpu_check=checkCPU warn=80 crit=90 time=20m time=10s time=4
host_check=check_ok
LUA Scripts
A list of LUA script to load at startup. In difference to "external checks" all LUA scripts are loaded at startup. Names have no meaning since the script (on boot) submit which commands are available and tie that to various functions.
[LUA Scripts]
scripts\test.lua
NRPE Handlers
This is a list of handlers for NRPE execution this can of course be used by any module (such as NSClient) but for historical reasons they are located in this section especially as NRPE plug-in is the one that does the actual execution.
The handlers can have two different syntaxes:
• command[my_command]=/some/executable
• my_command=/some/executable
The latter is the preferred way as it is shorter.
About NSClient++
NSClient++ (or nscp as I tend to call it nowadays) aims to be a simple yet powerful and secure monitoring daemon for Windows operating systems. It is built for Nagios, but nothing in the daemon is actually Nagios specific and could probably, with little or no change, be integrated into any monitoring software that supports running user tools for polling.
The structure of the daemon is a simple NT service that loads plug-ins to an internal stack. The plug-ins can then request data (poll performance data) from the other plug-ins through the internal stack. As of now there are a few plug-ins for basic performance data collection. For details of supplied modules, see CheckCommands.
NSClient++ can be extended in two ways: you can either write your own plug-in or you can execute an external script (as of now batch/exe/*). Writing your own plug-in is, of course, the most powerful way but requires knowledge of C++ or other languages which can produce DLLs and interface with regular C programs (generally, every other language available, but there is some simple API helpers for C/C++ as well as descriptions).
As for checking with NSClient++, I would recommend NRPE as it is a lot more flexible than check_nt. But NSClient has full support for check_nt, and if there is an interest, I could probably add support for check_nt from nc_net.
Supported OS/Platform
NSClient++ should run on the following operating systems:
• NT4 (SP5?)
• Windows 2000 W2K
• Windows XP
• Windows 2003
• Windows Vista
• ...
...as well as the following platforms:
• Win32
• x64 (AMT64/EMT64)
• IA64 (Itanium)
Whats in a name?
Since I have noticed some ppl. use other names for the client I decided to list them here to make it simpler (ie. Goggle might find it) for people to find it.
• NSClient++ (the "real" name)
• NSCP (what I sometimes use)
• NSClientpp (version of NSCLient++)
• NSClient (?)
• Saw a French (Spanish) site use: NSC++
Again I myself as stated before prefer NSClient++ or NSCP.
Installation
NSClient++ comes with simple command line option for registering (and deregistering) the service but it does not have a GUI installer.
Thus to install the Client you only need to copy the files to a directory of your choice and then run “NSClient++ /install”.
Before you start NSClient++ you need to configure it by editing the configuration file (NSC.ini). The configuration file is a simple text file and is explained in detail under Configuration. The files needed by NSClient++ varies but mainly the exe and DLL's in the NSClient++ root are required as well as all the modules you plan to use from the modules subdirectory (/modules/*).
The configuration file (NSC.ini) NEEDS to be configured as for security reasons all plug-ins are disabled by default. The reason for this is so no one will accidentally install this and get potential security issues, I believe that things should be "off" by default. Also notice that by default allowed_hosts are 127.0.0.1 so you need to modify this as well.
If you plan to use the SystemTray module (that shows a system tray icon on the desktop you need to install the SystemTray module as well as NSClient++. To install NSClient++ execute the following command:
NSClient++ /install
NSClient++ SysTray install
To uninstall NSClient++ execute the following command:
NSClient++ SysTray uninstall
NSClient++ /uninstall
To start NSClient++ execute the following command:
NSClient++ /start
To stop NSClient++ execute the following command:
NSClient++ /stop
If you only wish to test it or debug the client you can use the following without installing it first.
NSClient++ /test
Firewall
Firewall configuration should be pretty straight forward:
If you use NRPEListener (check_nrpe) you need the NRPE port open (usually 5666) from the nagios server towards the client.
nagios:* -> client:5666
If you use the NSClientListener (check_nt) you need the (modified) NSClient port open (usually 12489) from the nagios server towards the client.
nagios:* -> client:12489
If you use the NSCA Module (passive checks) you need the NSCA port open from the client towards the nagios server.
client:* -> nagios:5667
If you use the NRPEClient module to check any remote systems (use NSClient++ as a proxy) you need to have NRPE port (usually 5666) open from NSClient++ (the proxy) to the remote-client in addition to the method you use to submit the results to the server.
nsclient-proxy:* -> remote-client:5666
All these ports can be changed so check your nsc.ini.
NT4
NT4 does not come with the PDH library and you need to install that before using NSClient++. PDH can be downloaded from Microsoft: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q284996 and the simplest way to install it is to uncompress it directly into the NSClient++ directory.
NT4 also (sometimes) lack the PSAPI helper which is available in the "Platform SDK Redistributable: PSAPI for Windows NT" from Microsoft. http://www.microsoft.com/downloads/details.aspx?FamilyID=3d1fbaed-d122-45cf-9d46-1cae384097ac as with the PDH either install in system32 or local NSClient++ directory.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值