NSClient 0.4.2 onwards has implemented filters which allow you to determine what you want.
http://docs.nsclient.org/0.4.2/referenc ... ck-service
check_service
CheckSystemcheck_service
Check the state of one or more of the computer services.
Usage:
Option Default value Description
help N/A Show help screen (this screen)
help-csv N/A Show help screen as a comma separated list.
help-short N/A Show help screen (short format).
debug N/A Show debugging information in the log
show-all N/A Show debugging information in the log
filter N/A Filter which marks interesting items.
warning N/A Filter which marks items which generates a warning state.
warn N/A Short alias for warning
critical N/A Filter which marks items which generates a critical state.
crit N/A Short alias for critical.
ok N/A Filter which marks items which generates an ok state.
empty-syntax OK all services are ok. Message to display when nothing matched filter.
empty-state unknown Return status to use when nothing matched filter.
perf-config N/A Performance data generation configuration
top-syntax ${status}: ${crit_list}, delayed (${warn_list}) Top level syntax.
detail-syntax ${name}=${state} (${start_type}) Detail level syntax.
perf-syntax ${name} Performance alias syntax.
computer N/A THe name of the remote computer to check
service N/A The service to check, set this to * to check all services
exclude N/A A list of services to ignore (mainly usefull in combination with service=*)
type service The types of services to enumerate available types are driver, file-system-driver, kernel-driver, service, service-own-process, service-share-process
state all The types of services to enumerate available states are active, inactive or all
ok (CheckSystem, check_service)
Filter which marks items which generates an ok state.
If anything matches this any previous state for this item will be reset to ok.
Avalible options:
Key Value
delayed If the service is delayed
desc Service description
legacy_state Get legacy state (deprecated and only used by check_nt)
name Service name
pid Process id
start_type The configured start type ()
state The current state ()
state_is_ok() Check if the state is ok, i.e. all running services are runningelayed services are allowed to be stopped)
state_is_perfect() Check if the state is ok, i.e. all running services are running
count Number of items matching the filter
total Total number of items
ok_count Number of items matched the ok criteria
warn_count Number of items matched the warning criteria
crit_count Number of items matched the critical criteria
problem_count Number of items matched either warning or critical criteria
list A list of all items which matched the filter
ok_list A list of all items which matched the ok criteria
warn_list A list of all items which matched the warning criteria
crit_list A list of all items which matched the critical criteria
problem_list A list of all items which matched either the critical or the warning criteria
status The returned status (OK/WARN/CRIT/UNKNOWN)
But honestly versions 0.4.2 and 0.4.3 don't work very well at this point in time. For example:
Code: Select all
check_nrpe -H win2008r2-01 -c check_service -a show-all
OK: , delayed ()
I'm not sure it's supposed to look like that.
Mind you, I haven't checked the newest versions that were released the last couple of weeks.
negate it probably your best bet. It can take the return code and change it from critical, warning or ok, while leaving the message as is.
Using NSClient++ 0.4.1.105, heres the print spooler stopped:
Code: Select all
./check_nrpe -H win2008r2-01 -c check_service -a spooler
CRITICAL: spooler: stopped (critical)
echo $?
2
Now here is using negate:
Code: Select all
/usr/local/nagios/libexec/negate -c OK -w OK -u OK /usr/local/nagios/libexec/check_nrpe -H win2008r2-01 -c check_service -a spooler
CRITICAL: spooler: stopped (critical)
echo $?
0
It still says CRITICAL but the exit code IS OK.