Page 1 of 2
How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 1:02 pm
by imran_khan
Hello,
I want to exclude some services from “Automatic Start Services”. How I can do this?
Service define in Nagios system:-
define service{
use generic-service ; Name of service template to use
host_name xyz
service_description Automatic Start Services
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 120
retry_check_interval 1
contact_groups winwsrv
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command CheckAll!5666
}
I have manually tried below command and it is working fine.
./check_nrpe -H win_server_ip -p 5666 -c CheckServiceState -a CheckAll exclude=RemoteRegistry
OK: All services are in their appropriate state.
And when I define check_command as below and getting error “no handler for that command” in Nagios system
check_command check_nrpe!-H!win_server_ip!-p!5666!-c!CheckServiceState!-a!CheckAll!exclude=RemoteRegistry
Please suggest me on this.
Thanks,
Imran Khan.
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 1:22 pm
by abrist
imran_khan wrote:./check_nrpe -H win_server_ip -p 5666 -c CheckServiceState -a CheckAll exclude=RemoteRegistry
imran_khan wrote:check_command check_nrpe!-H!win_server_ip!-p!5666!-c!CheckServiceState!-a!CheckAll!exclude=RemoteRegistry
The full nrpe argument list is: "CheckAll exclude=RemoteRegistry"
You have way too many "!" symbols most likely. What is the command definition? (the one which designates $ARGn$s)?
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 2:38 pm
by imran_khan
Hello,
Thanks, command definition for CheckServiceState are as follow.
# cat commands.cfg | grep CheckServiceState
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a CheckAll exclude=ShellHWDetection exclude=clr_optimization_v4.0.30319_32 exclude=clr_optimization_v4.0.30319_64 exclude=sppsvc
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a CheckAll exclude=ShellHWDetection exclude=clr_optimization_v4.0.30319_32 exclude=clr_optimization_v4.0.30319_64 exclude=sppsvc exclude=stisvc
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a CheckAll exclude=ShellHWDetection exclude=clr_optimization_v4.0.30319_32 exclude=clr_optimization_v4.0.30319_64 exclude=sppsvc exclude=WinHttpAutoProxySvc
command_name CheckServiceStateg
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a ShowAll ShowFail $ARG2$=$ARG3$
command_name CheckServiceState
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckServiceState -a ShowAll ShowFail $ARG1$=$ARG2$
command_name CheckServiceState_wirelessemporium_mssql_agent
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a ShowAll ShowFail SQLAgent'$'WEDB01=$ARG3$
command_name CheckServiceState_wirelessemporium_mssql
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a ShowAll ShowFail MSSQL'$'WEDB01=$ARG3$
command_name CheckServiceState1
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 6666 -c CheckServiceState -a ShowAll ShowFail $ARG1$=$ARG2$
command_name CheckServiceStateG
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a ShowAll ShowFail $ARG2$=$ARG3$
command_name CheckServiceState2
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5660 -c CheckServiceState -a ShowAll ShowFail $ARG1$=$ARG2$
command_name CheckServiceState3
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5660 -c CheckServiceState -a ShowAll ShowFail $ARG1$=$ARG2$
command_name CheckServiceState4
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckServiceState -a ShowAll ShowFail $ARG1$=$ARG2$
command_name CheckServiceState5668
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5668 -c CheckServiceState -a ShowAll ShowFail $ARG1$=$ARG2$
Thanks,
Imran Khan.
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 2:55 pm
by abrist
Which one of these is for the command "CheckAll" as declared in your config:
imran_khan wrote:Service define in Nagios system:-
define service{
use generic-service ; Name of service template to use
host_name xyz
service_description Automatic Start Services
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 120
retry_check_interval 1
contact_groups winwsrv
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command CheckAll!5666
}
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 3:08 pm
by imran_khan
Hello,
Not sure. I have put the below line in nsc.ini file but no luck.
alias_service=checkServiceState CheckAll exclude=RemoteRegistry
Thanks,
Imran Khan.
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 3:15 pm
by slansing
In your command definitions "-a" stands for argument, not alias. You need to define the alias as shown above, and then call it in the "-c" section of your nagios commands. Can you send us your nsc.ini file, please blank out passwords and IP's that are publicly open.
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 3:31 pm
by imran_khan
Hello,
Please find the nsc.ini file content.
Code: Select all
[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
; You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; * *
; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S *
; * *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
;SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
CheckWMI.dll
;
; Script to check external scripts and/or internal aliases.
CheckExternalScripts.dll
;
; NSCA Agent if you enable this NSClient++ will talk to NSCA hosts repeatedly (so dont enable unless you want to use NSCA)
;NSCAAgent.dll
;
; LUA script module used to write your own "check deamon".
;LUAScript.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll
; Extreamly early beta of a task-schedule checker
;CheckTaskSched.dll
[Settings]
;# OBFUSCATED PASSWORD
; This is the same as the password option but here you can store the password in an obfuscated manner.
; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the
; password. Its just a bit harder to do it at first glance.
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB
;
;# PASSWORD
; This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.
;password=secret-password
;
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
; If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
; The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=Nagios_server_ip
;
;# USE THIS FILE
; Use the INI file as opposed to the registry if this is 0 and the use_reg in the registry is set to 1
; the registry will be used instead.
use_file=1
;
; # USE SHARED MEMORY CHANNELS
; This is the "new" way for using the system tray based on an IPC framework on top shared memmory channels and events.
; It is brand new and (probably has bugs) so dont enable this unless for testing!
; If set to 1 shared channels will be created and system tray icons created and such and such...
;shared_session=0
[log]
;# LOG DEBUG
; Set to 1 if you want debug message printed in the log file (debug messages are always printed to stdout when run with -test)
debug=0
;
;# LOG FILE
; The file to print log statements to
file=nsclient.log
;
;# LOG DATE MASK
; The format to for the date/time part of the log entry written to file.
date_mask=%Y-%m-%d %H:%M:%S
;
;# LOG ROOT FOLDER
; The root folder to use for logging.
; exe = the folder where the executable is located
; local-app-data = local application data (probably a better choice then the old default)
root_folder=exe
[NSClient]
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon.
; If you leave this blank the global version will be used instead.
allowed_hosts=Nagios_server_ip
;
;# NSCLIENT PORT NUMBER
; This is the port the NSClientListener.dll will listen to.
;port=12489
;
;# BIND TO ADDRESS
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.
; Leaving this blank will bind to all avalible IP adresses.
;bind_to_address=
;
;# SOCKET TIMEOUT
; Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.
;socket_timeout=30
[NRPE]
;# NRPE PORT NUMBER
; This is the port the NRPEListener.dll will listen to.
port=5666
;
;# COMMAND TIMEOUT
; This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.
command_timeout=60
;
;# COMMAND ARGUMENT PROCESSING
; This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.
allow_arguments=1
;
;# COMMAND ALLOW NASTY META CHARS
; This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow_nasty_meta_chars=1
;
;# USE SSL SOCKET
; This option controls if SSL should be used on the socket.
;use_ssl=1
;
;# BIND TO ADDRESS
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.
; Leaving this blank will bind to all avalible IP adresses.
; bind_to_address=
;
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to NRPE deamon.
; If you leave this blank the global version will be used instead.
allowed_hosts=127.0.0.1/32,Nagios_system_ip
;
;# SCRIPT DIRECTORY
; All files in this directory will become check commands.
; *WARNING* This is undoubtedly dangerous so use with care!
script_dir=scripts\
;
;# SOCKET TIMEOUT
; Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.
socket_timeout=60
checkrahul=echo test
[Check System]
;# CPU BUFFER SIZE
; Can be anything ranging from 1s (for 1 second) to 10w for 10 weeks. Notice that a larger buffer will waste memory
; so don't use a larger buffer then you need (ie. the longest check you do +1).
;CPUBufferSize=1h
;
;# CHECK RESOLUTION
; The resolution to check values (currently only CPU).
; The value is entered in 1/10:th of a second and the default is 10 (which means ones every second)
;CheckResolution=10
;
;# CHECK ALL SERVICES
; Configure how to check services when a CheckAll is performed.
; ...=started means services in that class *has* to be running.
; ...=stopped means services in that class has to be stopped.
; ...=ignored means services in this class will be ignored.
;check_all_services[SERVICE_BOOT_START]=ignored
;check_all_services[SERVICE_SYSTEM_START]=ignored
check_all_services[SERVICE_AUTO_START]=started
;check_all_services[SERVICE_DEMAND_START]=ignored
;check_all_services[SERVICE_DISABLED]=stopped
[External Script]
;# COMMAND TIMEOUT
; This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.
command_timeout=90
;
;# COMMAND ARGUMENT PROCESSING
; This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.
allow_arguments=1
;
;# COMMAND ALLOW NASTY META CHARS
; This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow_nasty_meta_chars=1
;
;# SCRIPT DIRECTORY
; All files in this directory will become check commands.
; *WARNING* This is undoubtedly dangerous so use with care!
script_dir=scripts\
[Script Wrappings]
vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
;ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
;bat=scripts\%SCRIPT% %ARGS%
[External Scripts]
;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
;check_powershell_warn=cmd /c echo scripts\powershell.ps1 | powershell.exe -command -
[External Alias]
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_cpu_ex=checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_service=checkServiceState CheckAll exclude=RemoteRegistry
alias_process=checkProcState $ARG1$=started
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=physical
alias_up=checkUpTime MinWarn=1d MinWarn=1h
alias_file_age=checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"
alias_file_size=checkFile2 filter=out "file=$ARG1$" filter-size=>$ARG2$ MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%"
alias_file_size_in_dir=checkFile2 filter=out pattern=*.txt "file=$ARG1$" filter-size=>$ARG2$ MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%"
alias_event_log_old=CheckEventLog file=application file=system filter=new filter=out MaxWarn=1 MaxCrit=1 filter-generated=>2d filter-severity==success filter-severity==informational truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"
alias_event_log_new=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational')" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"
alias_event_log=alias_event_log_new
check_ok=CheckOK Everything is fine!
[Wrapped Scripts]
;check_test_vbs=check_test.vbs /arg1:1 /arg2:1 /variable:1
;check_test_ps1=check_test.ps1 arg1 arg2
;check_test_bat=check_test.bat arg1 arg2
;check_battery=check_battery.vbs
;check_printer=check_printer.vbs
check_jj=C:\NagiosPlus\scripts\chkwin_service_auto.wsf
; [includes]
;# The order when used is "reversed" thus the last included file will be "first"
;# Included files can include other files (be carefull only do basic recursive checking)
;
; myotherfile.ini
; real.ini
[NSCA Agent]
;# CHECK INTERVALL (in seconds)
; How often we should run the checks and submit the results.
;interval=5
;
;# ENCRYPTION METHOD
; This option determines the method by which the send_nsca client will encrypt the packets it sends
; to the nsca daemon. The encryption method you choose will be a balance between security and
; performance, as strong encryption methods consume more processor resources.
; You should evaluate your security needs when choosing an encryption method.
;
; Note: The encryption method you specify here must match the decryption method the nsca daemon uses
; (as specified in the nsca.cfg file)!!
; Values:
; 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
;encryption_method=14
;
;# ENCRYPTION PASSWORD
; This is the password/passphrase that should be used to encrypt the sent packets.
;password=
;
;# BIND TO ADDRESS
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.
; Leaving this blank will bind to "one" local interface.
; -- not supported as of now --
;bind_to_address=
;
;# LOCAL HOST NAME
; The name of this host (if empty "computername" will be used.
;hostname=
;
;# NAGIOS SERVER ADDRESS
; The address to the nagios server to submit results to.
;nsca_host=192.168.0.1
;
;# NAGIOS SERVER PORT
; The port to the nagios server to submit results to.
;nsca_port=5667
;
;# CHECK COMMAND LIST
; The checks to run everytime we submit results back to nagios
; Any command(alias/key) starting with a host_ is sent as HOST_COMMAND others are sent as SERVICE_COMMANDS
; where the alias/key is used as service name.
;
[NSCA Commands]
;my_cpu_check=checkCPU warn=80 crit=90 time=20m time=10s time=4
;my_mem_check=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=page
;my_svc_check=checkServiceState CheckAll exclude=wampmysqld exclude=MpfService
;host_check=check_ok
;my_svc_check=checkServiceState CheckAll exclude="RemoteRegistry"
;# REMOTE NRPE PROXY COMMANDS
; A list of commands that check other hosts.
; Used by the NRPECLient module
[NRPE Client Handlers]
;check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments
command[ISActiveConnectionCount]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\ISActiveConnectionCount.vbs" -w $ARG1$ -c $ARG2$
command[ISActiveUserCount]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\ISActiveUserCount.vbs" -w $ARG1$ -c $ARG2$
command[ISConnectionCount]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\ISConnectionCount.vbs" -w $ARG1$ -c $ARG2$
command[MTATotalRecipientsQueued]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\MTATotalRecipientsQueued.vbs" -w $ARG1$ -c $ARG2$
command[MTAWorkQueueLength]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\MTAWorkQueueLength.vbs" -w $ARG1$ -c $ARG2$
command[SMTPInboundConnectionsCurrent]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\SMTPInboundConnectionsCurrent.vbs" -w $ARG1$ -c $ARG2$
command[SMTPLocalQueueLength]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\SMTPLocalQueueLength.vbs" -w $ARG1$ -c $ARG2$
command[SMTPLocalRetryQueueLength]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\SMTPLocalRetryQueueLength.vbs" -w $ARG1$ -c $ARG2$
command[SMTPMessagesPendingRouting]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\SMTPMessagesPendingRouting.vbs" -w $ARG1$ -c $ARG2$
command[SMTPRemoteQueueLength]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\SMTPRemoteQueueLength.vbs" -w $ARG1$ -c $ARG2$
command[SMTPRemoteRetryQueueLength]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\SMTPRemoteRetryQueueLength.vbs" -w $ARG1$ -c $ARG2$
command[TSActiveSession]=cscript //nologo "C:\NagiosPlus\scripts\TSActiveSession.vbs" -w $ARG1$ -c $ARG2$
command[httpresponse]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\httpresponse.vbs"
command[check_dell_sensors]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\check_dell_sensors.wsf"
command[check_dell_omreport]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\check_dell_omreport.wsf"
command[CheckAutoService]=cscript //nologo //t:10 "C:\NagiosPlus\scripts\chkwin_service_auto.wsf"
command[checkadaptech]=C:\NagiosPlus\scripts\check_adaptec.exe
command[checkDC]=C:\NagiosPlus\scripts\check_ad.exe -d -v
command[checkrahul]=echo test
command[checkservice]=c:\NagiosPlus\scripts\autoservice.bat
;command [CheckAutoService] = c: \ windows \ system32 \ cscript.exe / nologo / D: 120 C: \ NagiosPlus \ scripts \ chkwin_service_auto.wsf / w: 0 / c: 1
;# LUA SCRIPT SECTION
; A list of all Lua scripts to load.
;[LUA Scripts]
;scripts\test.lua
Re: How to exclude service from “Automatic Start Services”.
Posted: Wed Jul 17, 2013 5:41 pm
by imran_khan
Hello,
Any suggestion or solution.
Thanks,
Imran khan.
Re: How to exclude service from “Automatic Start Services”.
Posted: Fri Jul 19, 2013 10:56 am
by slansing
We need to see the nagios command definition for:
To see how you have defined it.
Re: How to exclude service from “Automatic Start Services”.
Posted: Fri Jul 19, 2013 11:55 am
by imran_khan
Hello,
Thanks.
Command defined as below. I want to exclude RemoteRegistry service for particular server not for all. So please suggest me on the same.
command_name CheckAll
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c CheckServiceState -a CheckAll exclude=ShellHWDetection exclude=clr_optimization_v4.0.30319_32 exclude=clr_optimization_v4.0.30319_64 exclude=sppsvc
Thanks,
Imran Khan.