Page 2 of 2

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 7:53 am
by smetzler
@lmiltchev

To reply to your questions...I changed the executable to explorer, excel, and several other executables to verify the script was returning the correct values. I just did not update the output (echo) command because I was only concerned with the output. That being said the executable name has been correct. The nsclient.ini file was complete so I imported all of the default settings as you suggested. I know receive the following error from the Nagios CLI when running the command:
CHECK_NRPE STATE CRITICAL: Socket timeout after 10 seconds

I am unsure if this is a step in the right direction because I no longer receive the error about not allowing arguments but the new error would seem to indicate the CHECK_NRPE command can no longer connect to the client. The client machine is still communicating with the Nagios server but those services to do not use the CHECK_NRPE service.

Attached is the updated nsclient.ini file:

# If you want to fill this file with all available options run the following command:
# nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
# nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help


; in flight - TODO
[/settings/default]

; Undocumented key
password = XXXXXXXXXXXXX

; Undocumented key
allowed hosts = xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx

; CACHE ALLOWED HOSTS - If host names (DNS entries) should be cached, improves speed and security somewhat but won't allow you to have

dynamic IPs for your Nagios server.
cache allowed hosts = true

; TIMEOUT - Timeout when reading packets on incoming sockets. If the data has not arrived within this time we will bail out.
timeout = 30

; INBOX - The default channel to post incoming messages on
inbox = inbox

; in flight - TODO
[/settings/NRPE/server]

; Undocumented key
ssl options = no-sslv2,no-sslv3

; Undocumented key
verify mode = none

; Undocumented key
insecure = true

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = false

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{})

characters in arguments.
allow nasty characters = true

; EXTENDED RESPONSE - Send more then 1 return packet to allow response to go beyond payload size (requires modified client if legacy is true

this defaults to false).
extended response = false

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are

executed.
allow arguments = true

; PORT NUMBER - Port to use for NRPE.
port = 5666


; in flight - TODO
[/modules]

; Undocumented key
CheckExternalScripts = enabled

; Undocumented key
CheckHelpers = enabled

; Undocumented key
CheckEventLog = enabled

; Undocumented key
CheckNSCP = enabled

; Undocumented key
CheckDisk = enabled

; Undocumented key
CheckSystem = enabled

; Undocumented key
NSClientServer = enabled

; Undocumented key
NRPEServer = enabled

; SyslogClient - Forward information as syslog messages to a syslog server
SyslogClient = true

; SimpleFileWriter - Write status updates to a text file (A bit like the NSCA server does)
SimpleFileWriter = true

; NSCAClient - NSCA client can be used both from command line and from queries to submit passive checks via NSCA
NSCAClient = true

; NRDPClient - NRDP client can be used both from command line and from queries to check remote systes via NRDP
NRDPClient = true

; NRPEClient - NRPE client can be used both from command line and from queries to check remote systes via NRPE as well as configure the NRPE

server
NRPEClient = true

; GraphiteClient - Graphite client can be used to submit graph data to a graphite graphing system
GraphiteClient = true

; WEBServer - A server that listens for incoming HTTP connection and processes incoming requests. It provides both a WEB UI as well as a REST

API in addition to simplifying configuration of WEB Server module.
WEBServer = true

; DotnetPlugin - Plugin to load and manage plugins written in dot net.
DotnetPlugins = true

; CommandClient - A command line client, generally not used except with "nscp test".
CommandClient = true

; CheckWMI - Check status via WMI
CheckWMI = true

; CheckTaskSched - Check status of your scheduled jobs.
CheckTaskSched = true

; CheckNet - Network related check such as check_ping.
CheckNet = true

; SMTPClient - SMTP client can be used both from command line and from queries to check remote systes via SMTP
SMTPClient = true

; LUAScript - Loads and processes internal Lua scripts
LUAScript = true

; PythonScript - Loads and processes internal Python scripts
PythonScript = true

; Op5Client - Client for connecting nativly to the Op5 Nortbound API
Op5Client = true

; Scheduler - Use this to schedule check commands and jobs in conjunction with for instance passive monitoring through NSCA
Scheduler = true

; CheckLogFile - File for checking log files and various other forms of updating text files
CheckLogFile = true

; NSCAServer - A server that listens for incoming NSCA connection and processes incoming requests.
NSCAServer = true

; SimpleCache - Stores status updates and allows for active checks to retrieve them
SimpleCache = true


; TARGET LIST SECTION - A list of available remote target systems
[/settings/targets]


; Realtime process filters - A set of filters to use in real-time mode
[/settings/system/windows/real-time/process]


; Realtime memory filters - A set of filters to use in real-time mode
[/settings/system/windows/real-time/memory]


; COUNTER - Definition for counter: default
[/settings/system/windows/counters/default]

; COUNTER TYPE - The type of counter to use long, large and double
type = UNKNOWN

; COUNTER - The counter to check
counter = UNKNOWN

; COLLECTION STRATEGY - The way to handled values when collecting them: static means we keep the last known value, rrd means we store values

in a buffer from which you can retrieve the average
collection strategy = UNKNOWN

; BUFFER SIZE - Size of buffer (in seconds) larger buffer use more memory
buffer size = UNKNOWN

; FLAGS - Extra flags to configure the counter (nocap100, 1000, noscale)
flags = UNKNOWN

; Interpret instances - IF we shoul interpret instance (default auto). Values: auto, true, false
instances = UNKNOWN


; Windows system - Section for system checks and system settings
[/settings/system/windows]

; Default buffer time - Used to define the default size of range buffer checks (ie. CPU).
default buffer length = 1h


; Op5 passive Commands -
[/settings/op5/checks]


; Op5 Configuration - Section for the Op5 server
[/settings/op5]

; Remove checks on exit - If we should remove all checks when NSClient++ shuts down (for truly elastic scenarios)
remove = false

; Install default checks - Set to false to disable default checks
default checks = true

; Check interval - How often to submit passive check results you can use an optional suffix to denote time (s, m, h)
interval = 5m

; CHANNEL - The channel to listen to.
channel = op5

; HOSTNAME - The host name of this monitored computer. Set this to auto (default) to use the windows name of the computer. auto

Hostname ${host} Hostname ${host_lc} Hostname in lowercase ${host_uc} Hostname in uppercase ${domain} Domainname ${domain_lc}

Domainname in lowercase ${domain_uc} Domainname in uppercase
hostname = auto


; Lua scripts - A list of scripts available to run from the LuaSCript module.
[/settings/lua/scripts]


; Real-time filtering - A set of options to configure the real time checks
[/settings/logfile/real-time]

; Real time - Spawns a background thread which waits for file changes.
enabled = false


; LOG SECTION - Configure log file properties.
[/settings/log/file]

; MAXIMUM FILE SIZE - When file size reaches this it will be truncated to 50% if set to 0 (default) truncation will be disabled
max size = -1


; Python scripts - A list of scripts available to run from the PythonScript module.
[/settings/python/scripts]


; LOG SETTINGS - Section for configuring the log handling.
[/settings/log]

; FILENAME - The file to write log data to. Set this to none to disable log to file.
file name = ${exe-path}/nsclient.log

; DATEMASK - The size of the buffer to use when getting messages this affects the speed and maximum size of messages you can recieve.
date format = %Y-%m-%d %H:%M:%S

; LOG LEVEL - Log level to use. Available levels are error,warning,info,debug,trace
level = info


; REMOTE TARGET DEFINITIONS -
[/settings/graphite/client/targets]


; FILE WRITER - Section for simple file writer module (SimpleFileWriter.dll).
[/settings/writers/file]

; TIME SYNTAX - The date format using strftime format flags. This is the time of writing the message as messages currently does not have a

source time.
time-syntax = %Y-%m-%d %H:%M:%S

; MESSAGE SYNTAX - The syntax of the message to write to the line. Can be any arbitrary string as well as include any of the following

special keywords:${command} = The command name, ${host} the host, ${channel} the recieving channel, ${alias} the alias for the command,

${alias-or-command} = alias if set otherweise command, ${message} = the message data (no escape), ${result} or ${result_number} = The result

status (number), ${epoch} = seconds since unix epoch, ${time} = time using time-format.
syntax = ${alias-or-command} ${result} ${message}

; SERVICE MESSAGE SYNTAX - The syntax of the message to write to the line. Can be any arbitrary string as well as include any of the

following special keywords:${command} = The command name, ${host} the host, ${channel} the recieving channel, ${alias} the alias for the

command, ${alias-or-command} = alias if set otherweise command, ${message} = the message data (no escape), ${result} or ${result_number} =

The result status (number), ${epoch} = seconds since unix epoch, ${time} = time using time-format.
service-syntax = UNKNOWN

; HOST MESSAGE SYNTAX - The syntax of the message to write to the line. Can be any arbitrary string as well as include any of the following

special keywords:${command} = The command name, ${host} the host, ${channel} the recieving channel, ${alias} the alias for the command,

${alias-or-command} = alias if set otherweise command, ${message} = the message data (no escape), ${result} or ${result_number} = The result

status (number), ${epoch} = seconds since unix epoch, ${time} = time using time-format.
host-syntax = UNKNOWN

; FILE TO WRITE TO - The filename to write output to.
file = output.txt

; CHANNEL - The channel to listen to.
channel = FILE


; GRAPHITE CLIENT SECTION - Section for graphite passive check module.
[/settings/graphite/client]

; CHANNEL - The channel to listen to.
channel = GRAPHITE

; HOSTNAME - The host name of the monitored computer. Set this to auto (default) to use the windows name of the computer. auto Hostname

${host} Hostname ${host_lc} Hostname in lowercase ${host_uc} Hostname in uppercase ${domain} Domainname ${domain_lc} Domainname in

lowercase ${domain_uc} Domainname in uppercase
hostname = auto


; Wrapped scripts - A list of wrapped scripts (ie. script using a template mechanism). The template used will be defined by the extension of

the script. Thus a foo.ps1 will use the ps1 wrapping from the wrappings section.
[/settings/external scripts/wrapped scripts]


; External scripts - A list of scripts available to run from the CheckExternalScripts module. Syntax is: `command=script arguments`
[/settings/external scripts/scripts]


; Realtime cpu filters - A set of filters to use in real-time mode
[/settings/system/windows/real-time/cpu]


; Command aliases - A list of aliases for already defined commands (with arguments). An alias is an internal command that has been predefined

to provide a single command without arguments. Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
[/settings/external scripts/alias]

; alias_volumes - To configure this create a section under: /settings/external scripts/alias/alias_volumes
alias_volumes = UNKNOWN

; alias_service - To configure this create a section under: /settings/external scripts/alias/alias_service
alias_service = UNKNOWN

; alias_sched_all - To configure this create a section under: /settings/external scripts/alias/alias_sched_all
alias_sched_all = UNKNOWN

; alias_process_hung - To configure this create a section under: /settings/external scripts/alias/alias_process_hung
alias_process_hung = UNKNOWN

; alias_process_count - To configure this create a section under: /settings/external scripts/alias/alias_process_count
alias_process_count = UNKNOWN

; alias_process - To configure this create a section under: /settings/external scripts/alias/alias_process
alias_process = UNKNOWN

; alias_mem - To configure this create a section under: /settings/external scripts/alias/alias_mem
alias_mem = UNKNOWN

; alias_file_size - To configure this create a section under: /settings/external scripts/alias/alias_file_size
alias_file_size = UNKNOWN

; alias_event_log - To configure this create a section under: /settings/external scripts/alias/alias_event_log
alias_event_log = UNKNOWN

; alias_disk - To configure this create a section under: /settings/external scripts/alias/alias_disk
alias_disk = UNKNOWN

; alias_file_age - To configure this create a section under: /settings/external scripts/alias/alias_file_age
alias_file_age = UNKNOWN

; alias_cpu_ex - To configure this create a section under: /settings/external scripts/alias/alias_cpu_ex
alias_cpu_ex = UNKNOWN

; alias_cpu - To configure this create a section under: /settings/external scripts/alias/alias_cpu
alias_cpu = UNKNOWN

; alias_volumes_loose - To configure this create a section under: /settings/external scripts/alias/alias_volumes_loose
alias_volumes_loose = UNKNOWN

; alias_sched_long - To configure this create a section under: /settings/external scripts/alias/alias_sched_long
alias_sched_long = UNKNOWN

; alias_process_stopped - To configure this create a section under: /settings/external scripts/alias/alias_process_stopped
alias_process_stopped = UNKNOWN

; alias_service_ex - To configure this create a section under: /settings/external scripts/alias/alias_service_ex
alias_service_ex = UNKNOWN

; alias_up - To configure this create a section under: /settings/external scripts/alias/alias_up
alias_up = UNKNOWN

; alias_sched_task - To configure this create a section under: /settings/external scripts/alias/alias_sched_task
alias_sched_task = UNKNOWN

; alias_disk_loose - To configure this create a section under: /settings/external scripts/alias/alias_disk_loose
alias_disk_loose = UNKNOWN


; TARGET - Target definition for: default
[/settings/syslog/client/targets/default]

; TIMEOUT - Timeout when reading/writing packets to/from sockets.
timeout = 30

; RETRIES - Number of times to retry sending.
retries = 3

; TARGET ADDRESS - Target host address
address = UNKNOWN


; External script settings - General settings for the external scripts module (CheckExternalScripts).
[/settings/external scripts]

; Command timeout - 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.
timeout = 60

; Script root folder - Root path where all scripts are contained (You can not upload/download scripts outside this folder).
script root = ${scripts}

; Load all scripts in a given folder - Load all scripts in a given directory and use them as commands.
script path = UNKNOWN

; Allow certain potentially dangerous characters in arguments - This option determines whether or not the we will allow clients to specify

nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true

; Allow arguments when executing external scripts - This option determines whether or not the we will allow clients to specify arguments to

commands that are executed.
allow arguments = true


; CLIENT HANDLER SECTION -
[/settings/graphite/client/handlers]


; REMOTE TARGET DEFINITIONS -
[/settings/syslog/client/targets]


; Real time filter: default - Definition for real time filter: default
[/settings/eventlog/real-time/filters/default]

; SYNTAX - Format string for dates
top syntax = UNKNOWN

; SYNTAX - Format string for dates
ok syntax = UNKNOWN

; EMPTY MESSAGE - The message to display if nothing matches the filter (generally considered the ok state).
empty message = eventlog found no records

; DESTINATION - Same as destination
target = UNKNOWN

; CRITICAL FILTER - If any rows match this filter severity will escalated to CRITICAL
critical = UNKNOWN

; FILE - The eventlog record to filter on (if set to 'all' means all enabled logs)
log = UNKNOWN

; SEVERITY - THe severity of this message (OK, WARNING, CRITICAL, UNKNOWN)
severity = UNKNOWN

; MAGIMUM AGE - How long before reporting "ok". If this is set to "false" no periodic ok messages will be reported only errors.
maximum age = 5m

; FILTER - Scan files for matching rows for each matching rows an OK message will be submitted
filter = UNKNOWN

; COMMAND NAME - The name of the command (think nagios service name) to report up stream (defaults to alias if not set)
command = UNKNOWN

; WARNING FILTER - If any rows match this filter severity will escalated to WARNING
warning = UNKNOWN

; OK FILTER - If any rows match this filter severity will escalated down to OK
ok = UNKNOWN

; SYNTAX - Format string for dates
detail syntax = UNKNOWN

; DESTINATION - The destination for intercepted messages
destination = UNKNOWN


; Real-time filters - A set of filters to use in real-time mode
[/settings/eventlog/real-time/filters]


; Real-time monitoring - A set of options to configure the real time checks
[/settings/eventlog/real-time]

; STARTUP AGE - The initial age to scan when starting NSClient++
startup age = 30m

; REAL TIME CHECKING - Spawns a background thread which detects issues and reports them back instantly.
enabled = false

; DEBUG - Log missed records (useful to detect issues with filters) not useful in production as it is a bit of a resource hog.
debug = false

; LOGS TO CHECK - Comma separated list of logs to check
log = application,system


; SYSLOG CLIENT SECTION - Section for SYSLOG passive check module.
[/settings/syslog/client]

; CHANNEL - The channel to listen to.
channel = syslog

; HOSTNAME - The host name of the monitored computer. Set this to auto (default) to use the windows name of the computer. auto Hostname

${host} Hostname ${host_lc} Hostname in lowercase ${host_uc} Hostname in uppercase ${domain} Domainname ${domain_lc} Domainname in

lowercase ${domain_uc} Domainname in uppercase
hostname = auto


; CRASH HANDLER - Section for configuring the crash handler.
[/settings/crash]

; CRASH ARCHIVE LOCATION - The folder to archive crash dumps in
archive folder = ${shared-path}/crash-dumps

; RESTART SERVICE NAME - The url to submit crash reports to
restart target = NSCP

; SUBMISSION URL - The url to submit crash reports to
submit url = https://crash.nsclient.org/post


; Users - Users which can access the REST API
[/settings/WEB/server/users]

; sample - To configure this create a section under: /settings/WEB/server/users/sample
sample = UNKNOWN


; Roles - A list of roles and with coma separated list of access rights.
[/settings/WEB/server/roles]


; REMOTE TARGET DEFINITIONS -
[/settings/SMTP/client/targets]


; CLIENT HANDLER SECTION -
[/settings/SMTP/client/handlers]


;
[/settings/WEB/server/users/sample]

; ROLE - The role which will grant access to this user
role = UNKNOWN

; PASSWORD - The password to use.
password = UNKNOWN


; SMTP CLIENT SECTION - Section for SMTP passive check module.
[/settings/SMTP/client]

; CHANNEL - The channel to listen to.
channel = SMTP


; NSCA SERVER SECTION - Section for NSCA (NSCAServer) (check_nsca) protocol options.
[/settings/NSCA/server]

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = false

; PORT NUMBER - Port to use for NSCA.
port = 5667

; ENCRYPTION - Name of encryption algorithm to use. Has to be the same as your agent i using or it wont work at all.This is also independent

of SSL and generally used instead of SSL. Available encryption algorithms are: none = No Encryption (not safe) xor = XOR des = DES 3des =

DES-EDE3 cast128 = CAST-128 xtea = XTEA blowfish = Blowfish twofish = Twofish rc2 = RC2 aes128 = AES aes192 = AES aes = AES serpent = Serpent

gost = GOST
encryption = aes

; PERFORMANCE DATA - Send performance data back to nagios (set this to false to remove all performance data).
performance data = true

; PAYLOAD LENGTH - Length of payload to/from the NSCA agent. This is a hard specific value so you have to "configure" (read recompile) your

NSCA agent to use the same value for it to work.
payload length = 512


; TARGET - Target definition for: default
[/settings/NSCA/client/targets/default]

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = UNKNOWN

; TIMEOUT - Timeout when reading/writing packets to/from sockets.
timeout = 30

; RETRIES - Number of times to retry sending.
retries = 3

; ENCRYPTION - Name of encryption algorithm to use. Has to be the same as your server i using or it wont work at all.This is also independent

of SSL and generally used instead of SSL. Available encryption algorithms are: none = No Encryption (not safe) xor = XOR des = DES 3des =

DES-EDE3 cast128 = CAST-128 xtea = XTEA blowfish = Blowfish twofish = Twofish rc2 = RC2 aes128 = AES aes192 = AES aes = AES serpent = Serpent

gost = GOST
encryption = aes

; SSL CERTIFICATE -
certificate = UNKNOWN

; ALLOWED CIPHERS - A better value is: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
allowed ciphers = UNKNOWN

; VERIFY MODE -
verify mode = UNKNOWN

; TARGET ADDRESS - Target host address
address = UNKNOWN


; NSCLIENT SERVER SECTION - Section for NSClient (NSClientServer.dll) (check_nt) protocol options.
[/settings/NSClient/server]

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = false

; PERFORMANCE DATA - Send performance data back to Nagios (set this to 0 to remove all performance data).
performance data = true

; PORT NUMBER - Port to use for check_nt.
port = 12489


; CLIENT HANDLER SECTION -
[/settings/NSCA/client/handlers]


; Legacy generic filters - A set of filters to use in real-time mode
[/settings/system/windows/real-time/checks]


; NSCA CLIENT SECTION - Section for NSCA passive check module.
[/settings/NSCA/client]

; CHANNEL - The channel to listen to.
channel = NSCA

; HOSTNAME - The host name of the monitored computer. Set this to auto (default) to use the windows name of the computer. auto Hostname

${host} Hostname ${host_lc} Hostname in lowercase ${host_uc} Hostname in uppercase ${domain} Domainname ${domain_lc} Domainname in

lowercase ${domain_uc} Domainname in uppercase
hostname = auto


; alias: default - The configuration section for the default alias
[/settings/external scripts/alias/default]

; COMMAND - Command to execute
command = UNKNOWN


; Schedules - Section for the Scheduler module.
[/settings/scheduler/schedules]


; REMOTE TARGET DEFINITIONS -
[/settings/NRPE/client/targets]


; TARGET - Target definition for: default
[/settings/NRDP/client/targets/default]

; SECURITY TOKEN - The security token
token = UNKNOWN

; RETRIES - Number of times to retry sending.
retries = 3

; SECURITY TOKEN - The security token
key = UNKNOWN

; TARGET ADDRESS - Target host address
address = UNKNOWN

; SECURITY TOKEN - The security token
password = UNKNOWN

; TIMEOUT - Timeout when reading/writing packets to/from sockets.
timeout = 30


; SMTP CLIENT SECTION - Section for SMTP passive check module.
[/settings/NRDP/client]

; HOSTNAME - The host name of the monitored computer. Set this to auto (default) to use the windows name of the computer. auto Hostname

${host} Hostname ${host_lc} Hostname in lowercase ${host_uc} Hostname in uppercase ${domain} Domainname ${domain_lc} Domainname in

lowercase ${domain_uc} Domainname in uppercase
hostname = auto

; CHANNEL - The channel to listen to.
channel = NRDP


; script: default - The configuration section for the default script.
[/settings/external scripts/scripts/default]

; IGNORE PERF DATA - Do not parse performance data from the output
ignore perfdata = UNKNOWN

; COMMAND - Command to execute
command = UNKNOWN


;
[/paths]

; Path for shared-path -
shared-path = C:\Program Files\NSClient++

; Path for scripts -
scripts = ${exe-path}/scripts

; Path for exe-path -
exe-path = C:\Program Files\NSClient++

; Path for certificate-path -
certificate-path = ${shared-path}/security

; Path for module-path -
module-path = ${exe-path}/modules

; Path for base-path -
base-path = C:\Program Files\NSClient++


; Web server - Section for WEB (WEBServer.dll) (check_WEB) protocol options.
[/settings/WEB/server]

; PORT NUMBER - Port to use for WEB server.
port = 8443

; CERTIFICATE - Ssl certificate to use for the ssl server
certificate = ${certificate-path}/certificate.pem

; NUMBER OF THREADS - The number of threads in the sever response pool.
threads = 10


; TARGET - Target definition for: default
[/settings/NRPE/client/targets/default]

; Insecure legacy mode - Use insecure legacy mode to connect to old NRPE server
insecure = UNKNOWN

; TARGET ADDRESS - Target host address
address = UNKNOWN

; PAYLOAD LENGTH - 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.
payload length = UNKNOWN

; VERIFY MODE -
verify mode = UNKNOWN

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = UNKNOWN

; RETRIES - Number of times to retry sending.
retries = 3

; ALLOWED CIPHERS - A better value is: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
allowed ciphers = UNKNOWN

; TIMEOUT - Timeout when reading/writing packets to/from sockets.
timeout = 30

; SSL CERTIFICATE -
certificate = UNKNOWN


; TARGET - Target definition for: default
[/settings/SMTP/client/targets/default]

; RETRIES - Number of times to retry sending.
retries = 3

; TARGET ADDRESS - Target host address
address = UNKNOWN

; TIMEOUT - Timeout when reading/writing packets to/from sockets.
timeout = 30


; CLIENT HANDLER SECTION -
[/settings/NRDP/client/handlers]


; INCLUDED FILES - Files to be included in the configuration
[/includes]


; Eventlog configuration - Section for the EventLog Checker (CheckEventLog.dll).
[/settings/eventlog]

; SYNTAX - Set this to use a specific syntax string for all commands (that don't specify one).
syntax = UNKNOWN

; LOOKUP NAMES - Lookup the names of eventlog files
lookup names = true

; BUFFER_SIZE - The size of the buffer to use when getting messages this affects the speed and maximum size of messages you can recieve.
buffer size = 131072

; DEBUG - Log more information when filtering (useful to detect issues with filters) not useful in production as it is a bit of a resource

hog.
debug = false


; REMOTE TARGET DEFINITIONS -
[/settings/NSCA/client/targets]


; NRPE CLIENT SECTION - Section for NRPE active/passive check module.
[/settings/NRPE/client]

; CHANNEL - The channel to listen to.
channel = NRPE


; DOT NET MODULES - Modules written in dotnet/CLR
[/modules/dotnet]


; CLIENT HANDLER SECTION -
[/settings/syslog/client/handlers]


; TARGET - Target definition for: default
[/settings/graphite/client/targets/default]

; TIMEOUT - Timeout when reading/writing packets to/from sockets.
timeout = 30

; PATH FOR STATUS - Path mapping for status
status path = system.${hostname}.${check_alias}.status

; SEND STATUS - Send status data to this server
send status = true

; RETRIES - Number of times to retry sending.
retries = 3

; PATH FOR METRICS - Path mapping for metrics
path = system.${hostname}.${check_alias}.${perf_alias}

; TARGET ADDRESS - Target host address
address = UNKNOWN

; SEND PERF DATA - Send performance data to this server
send perfdata = true


; PDH Counters - Add counters to check
[/settings/system/windows/counters]

; disk_queue_length - To configure this create a section under: /settings/system/windows/counters/disk_queue_length
disk_queue_length = UNKNOWN


; CLIENT HANDLER SECTION -
[/settings/NRPE/client/handlers]


; CACHE - Section for simple cache module (SimpleCache.dll).
[/settings/cache]

; CHANNEL - The channel to listen to.
channel = CACHE

; PRIMARY CACHE INDEX - Set this to the value you want to use as unique key for the cache. Can be any arbitrary string as well as include any

of the following special keywords:${command} = The command name, ${host} the host, ${channel} the recieving channel, ${alias} the alias for

the command, ${alias-or-command} = alias if set otherweise command, ${message} = the message data (no escape), ${result} = The result status

(number).
primary index = ${alias-or-command}


; REMOTE TARGET DEFINITIONS -
[/settings/NRDP/client/targets]


; Real-time filters - A set of filters to use in real-time mode
[/settings/logfile/real-time/checks]


; Scheduler - Section for the Scheduler module.
[/settings/scheduler]

; Threads - Number of threads to use.
threads = 5


; Script wrappings - A list of templates for defining script commands. Enter any command line here and they will be expanded by scripts

placed under the wrapped scripts section. %SCRIPT% will be replaced by the actual script an %ARGS% will be replaced by any given arguments.
[/settings/external scripts/wrappings]

; Batch file - Command used for executing wrapped batch files
bat = scripts\\%SCRIPT% %ARGS%

; Visual basic script - Command line used for wrapped vbs scripts
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%

; POWERSHELL WRAPPING - Command line used for executing wrapped ps1 (powershell) scripts
ps1 = cmd /c echo If (-Not (Test-Path "scripts\%SCRIPT%") ) { Write-Host "UNKNOWN: Script `"%SCRIPT%`" not found."; exit(3) }; scripts\

%SCRIPT% $ARGS$; exit($lastexitcode) | powershell.exe /noprofile -command -
check_process_memory = cmd /c echo scripts\memory_test.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | powershell.exe - command -


;
[/settings/WEB/server/users/default]

; ROLE - The role which will grant access to this user
role = UNKNOWN

; PASSWORD - The password to use.
password = UNKNOWN

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 9:51 am
by lmiltchev
Let's make some changes to the nsclient.ini file.

1. Under the [/settings/NRPE/server] section, make sure you have:

Code: Select all

# ssl options = no-sslv2,no-sslv3 # this line is commented out
verify mode = none
insecure = true
use ssl = true
allow nasty characters = true
allow arguments = true
port = 5666
extended response = false
allowed ciphers = ALL:!MD5:@STRENGTH
2. Under the [/settings/external scripts] section, comment out these two lines:

Code: Select all

script root = ${scripts}
script path = UNKNOWN
Note: I don't have these lines in my nsclient.ini file. It could be a "version" thing, but the "default" path to the scripts directory shouldn't be "UNKNOWN". If it is not defined at all, it should use the "default". You can leave the rest of the directives as is:

Code: Select all

timeout = 60
# script root = ${scripts}
# script path = UNKNOWN
allow nasty characters = true
allow arguments = true
3. Under the [/settings/external scripts/wrappings] section, remove this line:

Code: Select all

check_process_memory = cmd /c echo scripts\memory_test.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | powershell.exe - command -
and place it under the [/settings/external scripts/scripts] section.

Code: Select all

[/settings/external scripts/scripts]

check_process_memory = cmd /c echo scripts\memory_test.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | powershell.exe - command -
4. Save, exit, and restart NSClient++ service.

5. Test a few commands from the CLI on the Nagios XI server:

Code: Select all

nmap <client ip> -p 5666
/usr/local/nagios/libexec/check_nrpe -H <client ip>
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_process_memory -a 20 40
If these still fail, post the nsclient.log on the forum.

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 10:16 am
by smetzler
@lmiltchev

First off thank you for all of your help. The Nagios CLI nmap shows the client is open and 5666/tcp is open with service nrpe. The ./check_nrpe -H IP returns I (0.5.2.25 2018-01-28) seems to be doing fine...However, the ./check_nrpe -H IP -c check_process_memory -a 20 40 returns: The command (check_process_memory) returned an invalid return code: -196608 so it appears Nagios can not interact with the script. I tested the script and verified $LastExitCode is being set correctly based upon the $cirt, $warn and normal if/elseif statements. Do you have any ideas? Also, I can post the log if you think that will help.

Shane

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 10:36 am
by lmiltchev
Hi Shane,

You can PM me the nsclient.log.

Let's see first if the issue is with this particular script or any PS script. Create a "test" powershell script, named hello-world.ps1, and place it in the NSClient++ scripts directory.

Code: Select all

Write-Host "Hello, World!"
Add the following directive to the nsclient.ini file, under the [/settings/external scripts/scripts] section:

Code: Select all

check_script = cmd /c echo scripts\hello-world.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | powershell.exe -command -
Save, exit, and restart the NSClient++ service.
Test it from the CLI:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_script
Did you see the "Hello, World!" output?

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 10:45 am
by smetzler
@ lmiltchev

The Nagios CLI returned the following when the code was executed:
scripts\hello-world.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | 'powershell.exe' =0 '-' =0 'command'=0 '-'=0

I will be sending you the log file a minute.

Thank you,

Shane

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 10:50 am
by lmiltchev
Can you also PM me the "updated" nsclient.ini file?

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 1:51 pm
by lmiltchev
I believe I found the issue. You had an extra space in both commands. Here: "- command -". Change this:

Code: Select all

[/settings/external scripts/scripts]
check_process_memory = cmd /c echo scripts\memory_test.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | powershell.exe - command -
check_script = cmd /c echo scripts\hello-world.ps1; exit $LastExitCode | powershell.exe - command -
to this:

Code: Select all

[/settings/external scripts/scripts]
check_process_memory = cmd /c echo scripts\memory_test.ps1 "$ARG1$" "$ARG2$"; exit $LastExitCode | powershell.exe -command -
check_script = cmd /c echo scripts\hello-world.ps1; exit $LastExitCode | powershell.exe -command -
Save, exit, and restart the NSClient++ service. Test both commands. BTW, I removed the args from the "test" command. You are not passing any, so they are not needed. I copied/pasted them by mistake when I was giving you the example. :)

Let us know if this helped. Thank you!

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 3:22 pm
by smetzler
@lmiltchev

Thank you so much for finding that error. The script works perfectly! I have added the program_name variable to the script so I am able to pass the executable name from Nagios into the script thus making the script portable for use on any executable. If anyone needs a copy of the finalized script, please let me know.

Shane

Re: Monitor Memory Useage on a single service

Posted: Fri Apr 26, 2019 3:29 pm
by lmiltchev
I am glad I could help, Shane! :)

I am closing this topic now. If you have any further questions, please start a new thread.