Page 2 of 4

Re: Configuring Notifications in Nagios Core

Posted: Wed Feb 26, 2014 12:56 pm
by mkot
hmm, at

Code: Select all

/usr/local/nagios/etc/nagios.cfg
i've got:

Code: Select all

# This determines whether or not Nagios will accept passive
# Values: 1 = accept passive checks, 0 = reject passive checks
accept_passive_service_checks=1
# This determines whether or not Nagios will accept passive
# Values: 1 = accept passive checks, 0 = reject passive checks
accept_passive_host_checks=1
At my host definition I've got (for my laptop):

Code: Select all

define host{
        #use            windows-server  ; Inherit default values from a template
        host_name       WA-MKOT2        ; The name we're giving to this host
        alias           WA-MKOT2        ; A longer name associated with the host
        address         172.17.24.188   ; IP address of the host
        max_check_attempts 3
        contact_groups  admins
        icon_image      notebook.gif
        statusmap_image notebook.gd2
        parents         MK Switch
        passive_checks_enabled 1
        }

At my

Code: Select all

nsclient.ini
I've got:

Code: Select all

# If you want to fill this file with all avalible 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


; Undocumented section
[/modules]

; CheckDisk - CheckDisk can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckDisk = 1

; Event log Checker. - Check for errors and warnings in the event log. This is only supported through NRPE so if you plan to use only NSClient this wont help you at all.
CheckEventLog = 1

; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1

; Helper function - Various helper function to extend other checks. This is also only supported through NRPE.
CheckHelpers = 1

; Check NSCP - Checkes the state of the agent
CheckNSCP = 1

; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1

; CheckWMI - CheckWMI can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckWMI = 1

; NRPE server - A simple server that listens for incoming NRPE connection and handles them.
NRPEServer = 1

; NSClient server - A simple server that listens for incoming NSClient (check_nt) connection and handles them. Although NRPE is the preferred method NSClient is fully supported and can be used for simplicity or for compatibility.
NSClientServer = 1


; Undocumented section
[/settings/default]

; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 172.17.24.182

; PASSWORD - Password used to authenticate againast server
password =


; 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)
[/settings/external scripts/alias]

; alias_cpu - Alias for alias_cpu. To configure this item add a section called: /settings/external scripts/alias/alias_cpu
alias_cpu = checkCPU warn=80 crit=90 time=5m time=1m time=30s

; alias_cpu_ex - Alias for alias_cpu_ex. To configure this item add a section called: /settings/external scripts/alias/alias_cpu_ex
alias_cpu_ex = checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s

; alias_disk - Alias for alias_disk. To configure this item add a section called: /settings/external scripts/alias/alias_disk
alias_disk = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED

; alias_disk_loose - Alias for alias_disk_loose. To configure this item add a section called: /settings/external scripts/alias/alias_disk_loose
alias_disk_loose = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable

; alias_event_log - Alias for alias_event_log. To configure this item add a section called: /settings/external scripts/alias/alias_event_log
alias_event_log = CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"

; alias_file_age - Alias for alias_file_age. To configure this item add a section called: /settings/external scripts/alias/alias_file_age
alias_file_age = checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"

; alias_file_size - Alias for alias_file_size. To configure this item add a section called: /settings/external scripts/alias/alias_file_size
alias_file_size = CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10

; alias_mem - Alias for alias_mem. To configure this item add a section called: /settings/external scripts/alias/alias_mem
alias_mem = checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page

; alias_process - Alias for alias_process. To configure this item add a section called: /settings/external scripts/alias/alias_process
alias_process = checkProcState "$ARG1$=started"

; alias_process_count - Alias for alias_process_count. To configure this item add a section called: /settings/external scripts/alias/alias_process_count
alias_process_count = checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"

; alias_process_hung - Alias for alias_process_hung. To configure this item add a section called: /settings/external scripts/alias/alias_process_hung
alias_process_hung = checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"

; alias_process_stopped - Alias for alias_process_stopped. To configure this item add a section called: /settings/external scripts/alias/alias_process_stopped
alias_process_stopped = checkProcState "$ARG1$=stopped"

; alias_sched_all - Alias for alias_sched_all. To configure this item add a section called: /settings/external scripts/alias/alias_sched_all
alias_sched_all = CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0

; alias_sched_long - Alias for alias_sched_long. To configure this item add a section called: /settings/external scripts/alias/alias_sched_long
alias_sched_long = CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0

; alias_sched_task - Alias for alias_sched_task. To configure this item add a section called: /settings/external scripts/alias/alias_sched_task
alias_sched_task = CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0

; alias_service - Alias for alias_service. To configure this item add a section called: /settings/external scripts/alias/alias_service
alias_service = checkServiceState CheckAll

; alias_service_ex - Alias for alias_service_ex. To configure this item add a section called: /settings/external scripts/alias/alias_service_ex
alias_service_ex = checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc

; alias_up - Alias for alias_up. To configure this item add a section called: /settings/external scripts/alias/alias_up
alias_up = checkUpTime MinWarn=1d MinWarn=1h

; alias_updates - Alias for alias_updates. To configure this item add a section called: /settings/external scripts/alias/alias_updates
alias_updates = check_updates -warning 0 -critical 0

; alias_volumes - Alias for alias_volumes. To configure this item add a section called: /settings/external scripts/alias/alias_volumes
alias_volumes = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED

; alias_volumes_loose - Alias for alias_volumes_loose. To configure this item add a section called: /settings/external scripts/alias/alias_volumes_loose
alias_volumes_loose = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable 

; default - Alias for default. To configure this item add a section called: /settings/external scripts/alias/default
default = 
1. What should I add to .ini file to make it works?
2. Will it be all what I need to do?
3. If answer for 2. is "No", what should I do next?

Re: Configuring Notifications in Nagios Core

Posted: Wed Feb 26, 2014 4:47 pm
by lmiltchev
You should probably run in the DOS Prompt on the windows machine:

Code: Select all

nscp settings --generate --add-defaults --load-all
Note: See the top portion of the nsclient.ini.

You need to have a [NSCA Agent] section. You will have to set up a password, an encryption method, and how often the checks will be run and results, submitted to nagios... Finally, you will need to restart the nsclient++ service, so that changes can take effect.

Re: Configuring Notifications in Nagios Core

Posted: Thu Feb 27, 2014 1:53 am
by mkot
Ok, I did it, and I've got in my nsclient.ini:

Code: Select all

# If you want to fill this file with all avalible 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


; Undocumented section
[/modules]

; CheckDisk - CheckDisk can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckDisk = 1

; Event log Checker. - Check for errors and warnings in the event log. This is only supported through NRPE so if you plan to use only NSClient this wont help you at all.
CheckEventLog = 1

; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1

; Helper function - Various helper function to extend other checks. This is also only supported through NRPE.
CheckHelpers = 1

; Event log Checker. - Check for errors and warnings in the event log. This is only supported through NRPE so if you plan to use only NSClient this wont help you at all.
CheckLogFile = 0

; Check NSCP - Checkes the state of the agent
CheckNSCP = 1

; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1

; CheckTaskSched - CheckTaskSched can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckTaskSched = 0

; CheckTaskSched2 - CheckTaskSched2 can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckTaskSched2 = 0

; CheckWMI - CheckWMI can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckWMI = 1

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

; GraphiteClient - Graphite client
GraphiteClient = 0

; LUAScript - LUAScript...
LUAScript = 0

; NRDPClient - Passive check support over NRDP
NRDPClient = 0

; NRPE client - NRPE client 
NRPEClient = 0

; NRPE server - A simple server that listens for incoming NRPE connection and handles them.
NRPEServer = 1

; NSCAClient - Passive check support over NSCA.
NSCAClient = 0

; NSCA server (no encryption) - A simple server that listens for incoming NSCA connection and handles them.
NSCAServer = 0

; NSClient server - A simple server that listens for incoming NSClient (check_nt) connection and handles them. Although NRPE is the preferred method NSClient is fully supported and can be used for simplicity or for compatibility.
NSClientServer = 1

; SMTPClient - Passive check support via SMTP
SMTPClient = 0

; Scheduler - A scheduler which schedules checks at regular intervals
Scheduler = 0

; SimpleCache module - Caches results for later checking.
SimpleCache = 0

; SimpleFileWriter module - FileWriters results for later checking.
SimpleFileWriter = 0

; SyslogClient - Passive check support via Syslog
SyslogClient = 0


; Undocumented section
[/settings/default]

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

; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 172.17.24.182

; BIND TO ADDRESS - Allows you to bind server to a specific local address. This has to be a dotted ip address not a host name. Leaving this blank will bind to all available IP addresses.
bind to = 

; CACHE ALLOWED HOSTS - If hostnames should be cached, improves speed and security somewhat but wont allow you to have dynamic IPs for your nagios server.
cache allowed hosts = true

; SSL CERTIFICATE - 
certificate = 

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

; PASSWORD - Password used to authenticate againast server
password = 

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

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

; VERIFY MODE - 
verify mode = none


; 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)
[/settings/external scripts/alias]

; alias_cpu - Alias for alias_cpu. To configure this item add a section called: /settings/external scripts/alias/alias_cpu
alias_cpu = checkCPU warn=80 crit=90 time=5m time=1m time=30s

; alias_cpu_ex - Alias for alias_cpu_ex. To configure this item add a section called: /settings/external scripts/alias/alias_cpu_ex
alias_cpu_ex = checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s

; alias_disk - Alias for alias_disk. To configure this item add a section called: /settings/external scripts/alias/alias_disk
alias_disk = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED

; alias_disk_loose - Alias for alias_disk_loose. To configure this item add a section called: /settings/external scripts/alias/alias_disk_loose
alias_disk_loose = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable

; alias_event_log - Alias for alias_event_log. To configure this item add a section called: /settings/external scripts/alias/alias_event_log
alias_event_log = CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"

; alias_file_age - Alias for alias_file_age. To configure this item add a section called: /settings/external scripts/alias/alias_file_age
alias_file_age = checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"

; alias_file_size - Alias for alias_file_size. To configure this item add a section called: /settings/external scripts/alias/alias_file_size
alias_file_size = CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10

; alias_mem - Alias for alias_mem. To configure this item add a section called: /settings/external scripts/alias/alias_mem
alias_mem = checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page

; alias_process - Alias for alias_process. To configure this item add a section called: /settings/external scripts/alias/alias_process
alias_process = checkProcState "$ARG1$=started"

; alias_process_count - Alias for alias_process_count. To configure this item add a section called: /settings/external scripts/alias/alias_process_count
alias_process_count = checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"

; alias_process_hung - Alias for alias_process_hung. To configure this item add a section called: /settings/external scripts/alias/alias_process_hung
alias_process_hung = checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"

; alias_process_stopped - Alias for alias_process_stopped. To configure this item add a section called: /settings/external scripts/alias/alias_process_stopped
alias_process_stopped = checkProcState "$ARG1$=stopped"

; alias_sched_all - Alias for alias_sched_all. To configure this item add a section called: /settings/external scripts/alias/alias_sched_all
alias_sched_all = CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0

; alias_sched_long - Alias for alias_sched_long. To configure this item add a section called: /settings/external scripts/alias/alias_sched_long
alias_sched_long = CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0

; alias_sched_task - Alias for alias_sched_task. To configure this item add a section called: /settings/external scripts/alias/alias_sched_task
alias_sched_task = CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0

; alias_service - Alias for alias_service. To configure this item add a section called: /settings/external scripts/alias/alias_service
alias_service = checkServiceState CheckAll

; alias_service_ex - Alias for alias_service_ex. To configure this item add a section called: /settings/external scripts/alias/alias_service_ex
alias_service_ex = checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc

; alias_up - Alias for alias_up. To configure this item add a section called: /settings/external scripts/alias/alias_up
alias_up = checkUpTime MinWarn=1d MinWarn=1h

; alias_updates - Alias for alias_updates. To configure this item add a section called: /settings/external scripts/alias/alias_updates
alias_updates = check_updates -warning 0 -critical 0

; alias_volumes - Alias for alias_volumes. To configure this item add a section called: /settings/external scripts/alias/alias_volumes
alias_volumes = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED

; alias_volumes_loose - Alias for alias_volumes_loose. To configure this item add a section called: /settings/external scripts/alias/alias_volumes_loose
alias_volumes_loose = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable

; default - Alias for default. To configure this item add a section called: /settings/external scripts/alias/default
default = 


; List all dot net modules loaded by the DotNetplugins module here
[/modules/dotnet]


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

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

; HOSTNAME - The host name of this host if set to blank (default) the windows name of the computer will be used.
hostname = auto


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

; TARGET ADDRESS - Target host address
address = 

; RECIPIENT - Recipient of email message
recipient = nscp@localhost

; SENDER - Sender of email message
sender = nscp@localhost

; TEMPLATE - Template for message data
template = Hello, this is %source% reporting %message%!

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


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

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


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

; TARGET ADDRESS - Target host address
address = 

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

; SSL CERTIFICATE - 
certificate = 

; 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 = 1024

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

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

; VERIFY MODE - 
verify mode = none


; Section for NRPE (NRPEServer.dll) (check_nrpe) protocol options.
[/settings/NRPE/server]

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = 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 = false

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


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

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

; HOSTNAME - The host name of this host if set to blank (default) the windows name of the computer will be used.
hostname = auto


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

; TARGET ADDRESS - Target host address
address = 

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

; SSL CERTIFICATE - 
certificate = 

; ENCRYPTION METHOD - Number corresponding to the various encryption algorithms (see the wiki). Has to be the same as the server or it wont work at all.
encryption = aes

; PASSWORD - The password to use. Again has to be the same as the server or it wont work at all.
password = 

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

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

; VERIFY MODE - 
verify mode = none


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

; ENCRYPTION - Encryption to use
encryption = aes

; PASSWORD - Password to use
password = 

; 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

; 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 NSCA.
port = 5667

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


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

; 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


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

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


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

; TARGET ADDRESS - Target host address
address = 

; RECIPIENT - Recipient of email message
recipient = nscp@localhost

; SENDER - Sender of email message
sender = nscp@localhost

; TEMPLATE - Template for message data
template = Hello, this is %source% reporting %message%!

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


; 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 (host, command, result,...).
primary index = ${alias-or-command}


; Section for system checks and system settings
[/settings/check/task schedule]

; SYNTAX - Set this to use a specific syntax string for all commands (that don't specify one)
default buffer length = %title% last run: %most-recent-run-time% (%exit-code%)


; Configure crash handling properties.
[/settings/crash]

; ARCHIVE CRASHREPORTS - Archive crash reports in the archive folder
archive = true

; folder - The archive folder for crash dunpes.
archive folder = ${shared-path}/crash-dumps

; RESTART - Submit crash reports to nsclient.org (or your configured submission server)
restart = true

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

; SUBMIT CRASHREPORTS - Submit crash reports to nsclient.org (or your configured submission server)
submit = false

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


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

; 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 (usefull to detect issues with filters) not usefull in production as it is a bit of a resource hog.
debug = false

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

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


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

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

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

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

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


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


; Section for external scripts configuration options (CheckExternalScripts).
[/settings/external scripts]

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = 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 = false

; SCRIPT DIRECTORY - Load all scripts in a directory and use them as commands. Probably dangerous but useful if you have loads of scripts :)
script path = 

; 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


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


; A list of wrappped scripts (ie. using the template mechanism)
[/settings/external scripts/wrapped scripts]


; A list of templates for wrapped scripts
[/settings/external scripts/wrappings]

; BATCH FILE WRAPPING - 
bat = scripts\\%SCRIPT% %ARGS%

; POWERSHELL WRAPPING - 
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

; VISUAL BASIC WRAPPING - 
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%


; Section for graphite passive check module.
[/settings/graphite/client]

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

; HOSTNAME - The host name of this host if set to blank (default) the windows name of the computer will be used.
hostname = auto


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

; TARGET ADDRESS - Target host address
address = 

; PATH FOR VALUES - 
path = system.${hostname}.${check_alias}.${perf_alias}


; Section for configuring the log handling.
[/settings/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

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


; 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 = 0


; Section for log file checker
[/settings/logfile]

; DEBUG - Log more information to help diagnose errors and configuration problems.
debug = false

; SYNTAX - Set the default syntax to use
syntax = 


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

; REAL TIME CHECKING - Spawns a backgrounnd thread which waits for file changes.
enabled = false


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


; Section for the LUAScripts module.
[/settings/lua]


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


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

; THREAD COUNT - Number of threads to use.
threads = 5


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


; Section for configuring the shared session.
[/settings/shared session]

; LOG LEVEL - Log level to use
enabled = false


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

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

; HOSTNAME - The host name of this host if set to blank (default) the windows name of the computer will be used.
hostname = 


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

; TARGET ADDRESS - Target host address
address = 

; TODO - 
critical severity = critical

; TODO - 
facility = kernel

; TODO - 
message_syntax = %message%

; TODO - 
ok severity = informational

; TODO - 
severity = error

; TODO - 
tag_syntax = NSCA

; TODO - 
unknown severity = emergency

; TODO - 
warning severity = warning


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

; DEFAULT LENGTH - Used to define the default intervall for range buffer checks (ie. CPU).
default buffer length = 1h


; Confiure which services has to be in which state
[/settings/system/windows/service mapping]


; A list of avalible remote target systems
[/settings/targets]


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

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

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

; PRIMARY CACHE INDEX - Set this to the value you want to use as unique key for the cache (host, command, result,...).
syntax = ${alias-or-command} ${result} ${message}

So if I get it correct, I need to enable NSCAClient changing in line 60:

Code: Select all

; NSCAClient - Passive check support over NSCA.
NSCAClient = 0
to

Code: Select all

; NSCAClient - Passive check support over NSCA.
NSCAClient = 1
Do I need do it for NSCAServer to?

Code: Select all

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

; ENCRYPTION - Encryption to use
encryption = aes

; PASSWORD - Password to use
password = 

; 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

; 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 NSCA.
port = 5667

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = false
What should I put in password= ?? May it be "random" password or should it be password for my nagiosadmin [GUI user] or nagios [ssh user]?
Do I have change aes encryption to other?
Do I have to enable ssl encrytpion?

Sorry but I'm new at Nagios and I don't know everything about Nagios and its features:(

Re: Configuring Notifications in Nagios Core

Posted: Thu Feb 27, 2014 4:37 pm
by lmiltchev
To see how to set up this section, check out this page:

https://nsclient.org/nscp/wiki/doc/usage/nagios/nsca

After modifying the config, you will need to restart nsclient++ service.

You need to match the encryption/description method, and password from the "nsclient.ini" file and the "nsca.cfg" file on the nagios server. You will also have to add the Windows box IP address to the "only_from" line in the "/etc/xinetd.d/nsca", and restart xinetd, so that the changes can take effect.

Re: Configuring Notifications in Nagios Core

Posted: Mon Mar 03, 2014 2:57 am
by mkot
Hi, it's me again ;)

What I did:

At Win 7 machine:
nsclient.ini

Code: Select all

[/settings/NSCA/client/targets/default]

; TARGET ADDRESS - Target host address
address = 172.17.24.182

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

; SSL CERTIFICATE - 
;certificate = 

; ENCRYPTION METHOD - Number corresponding to the various encryption algorithms (see the wiki). Has to be the same as the server or it wont work at all.
;encryption = aes
encryption = des

; PASSWORD - The password to use. Again has to be the same as the server or it wont work at all.
password = passwd

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

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

; VERIFY MODE - 
verify mode = none


; Section for NSCA (NSCAServer) (check_nsca) protocol options.
At Nagios Server:
TAIWA.cfg /like windows.cfg/

Code: Select all

###############################################################################
# TAIWA.CFG - Komputery w oddziale TAIWA
###############################################################################


###############################################################################
###############################################################################
# HOST TEMPLATE
###############################################################################
###############################################################################

define host{
	name 			tpl-windows-srv ;Nazwa templatki
	use			generic-host	 ;Wczytanie podstawowych wartości 
	check_period		24x7		 ;Okres sprawdzania 
	check_interval		5		 ;Interwał sprawdzania w min
	retry_interval		1		 ;Interwał sprawdzania przy problemach z połączeniem w min
	max_check_attemps	10		 ;Maksymalna ilość prób sprawdzenia
	check_command		check-host-alive ;Polecenie sprawdzające
	notification_period	24x7		 ;Interwał sprawdzania powiadomień
	notification_interval	30		 ;Interwał wysyłania powiadomień w min
	notification_options	d, r		 ;Opcje sprawdzania
	contact_groups		admins		 ;Kontakt, do kogo zostaną wysłane powiadomienia
	register		0		 ;Nie rejestrujemy templatki
	}

define host{
	name 			tpl-windows
	use			generic-host
	check_period		workhours
	check_interval		5
	retry_interval		1
	max_check_attemps	10
	check_command		check-host-alive
	notification_period	workhours
	notification_interval	30
	notification_options	d, r
	contact_groups		admins
	register		0
	}

###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation

#define host{
#	use		windows-server		; Inherit default values from a template
#	host_name	winserver		; The name we're giving to this host
#	alias		My Windows Server	; A longer name associated with the host
#	address		192.168.1.2		; IP address of the host
#	}

###############################################################################
# Komputery i laptopy z oddziału TAIWA					      #
###############################################################################

# LAPTOPY
	
define host{
	use		tpl-windows
	#use		windows-server	; Inherit default values from a template
	host_name	WA-MKOT2	; The name we're giving to this host
	alias		WA-MKOT2	; A longer name associated with the host
	address		172.17.24.238	; IP address of the host
	max_check_attempts 3 
	contact_groups	admins
	icon_image	notebook.gif
	statusmap_image	notebook.gd2
	parents 	MK Switch
	passive_checks_enabled 1
	}

;AND OTHERS MACHINES

# grupy główne
# komputery i laptopy TAIWA
define hostgroup{
	hostgroup_name 		TAIWA
	alias			Komputery TAIWA
	members			WA-MKOT2 ;AND OTHERS MACHINES
	}

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	#host_name
	hostgroup_name		Serwery Windows WA
	service_description	Uptime
	check_command		check_nt!UPTIME
	notifications_enabled	0
	notification_period	workhours		
	active_checks_enabled	0
	passive_checks_enabled	1
	}

define service{
	use			generic-service
	hostgroup_name		TAIWA, Serwery Windows WA
	service_description	Host Status
	check_command		check-host-alive
	notifications_enabled	0
	active_checks_enabled	0
	passive_checks_enabled	1
	}

	
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	#host_name
	hostgroup_name		TAIWA, Serwery Windows WA
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	notification_interval	10
	notification_options	w, c, r
	notification_period	workhours		
	active_checks_enabled	0
	passive_checks_enabled	1
	}



# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	#host_name
	hostgroup_name		TAIWA, Serwery Windows WA
	service_description	Memory Usage
	check_command		check_nt!MEMUSE!-w 80 -c 90
	notification_interval	10
	notification_options	w, c, r
	notification_period	workhours		
	active_checks_enabled	0
	passive_checks_enabled	1
	}

	
# PING - do I need it??
define service{
	use			generic-service
	#host_name		
	hostgroup_name		TAIWA, Serwery Windows WA
	service_description	PING
	check_command		check_ping!200.0,20%!600.0,60%
	normal_check_interval	5
	retry_check_interval	1
	notification_interval	30
	notification_options	w,c,r
	notification_period	workhours		
	active_checks_enabled	0
	passive_checks_enabled	1
	}

	
# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	#host_name
	hostgroup_name		TAIWA, Serwery Windows WA
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	notification_interval	60
	notification_options	w, c, r
	notification_period	workhours		
	active_checks_enabled	0
	passive_checks_enabled	1
	}
I've installed nsca -

Code: Select all

apt-get install nsca
nsca.cfg

Code: Select all

####################################################
# Sample NSCA Daemon Config File 
# Written by: Ethan Galstad ([email protected])
# 
# Last Modified: 04-03-2006
####################################################


# PID FILE
# The name of the file in which the NSCA daemon should write it's process ID
# number.  The file is only written if the NSCA daemon is started by the root
# user as a single- or multi-process daemon.

pid_file=/var/run/nsca.pid



# PORT NUMBER
# Port number we should wait for connections on.
# This must be a non-priveledged port (i.e. > 1024).

server_port=5667



# SERVER ADDRESS
# Address that NSCA has to bind to in case there are
# more as one interface and we do not want NSCA to bind
# (thus listen) on all interfaces.

#server_address=192.168.1.1



# NSCA USER
# This determines the effective user that the NSCA daemon should run as.  
# You can either supply a username or a UID.
# 
# NOTE: This option is ignored if NSCA is running under either inetd or xinetd

nsca_user=nagios



# NSCA GROUP
# This determines the effective group that the NSCA daemon should run as.  
# You can either supply a group name or a GID.
# 
# NOTE: This option is ignored if NSCA is running under either inetd or xinetd

nsca_group=nogroup



# NSCA CHROOT
# If specified, determines a directory into which the nsca daemon
# will perform a chroot(2) operation before dropping its privileges.
# for the security conscious this can add a layer of protection in
# the event that the nagios daemon is compromised.  
# 
# NOTE: if you specify this option, the command file will be opened
#       relative to this directory.

#nsca_chroot=/var/run/nagios/rw



# DEBUGGING OPTION
# This option determines whether or not debugging
# messages are logged to the syslog facility. 
# Values: 0 = debugging off, 1 = debugging on

debug=1



# COMMAND FILE
# This is the location of the Nagios command file that the daemon
# should write all service check results that it receives.
# Note to debian users: nagios 1.x and nagios 2.x have
# different default locations for this file.  this is the
# default location for nagios 1.x:
#command_file=/var/run/nagios/nagios.cmd
# and this is the default location for nagios2:
#command_file=/var/lib/nagios2/rw/nagios.cmd
# and this is the default location for nagios3:
command_file=/var/lib/nagios3/rw/nagios.cmd

# ALTERNATE DUMP FILE
# This is used to specify an alternate file the daemon should
# write service check results to in the event the command file
# does not exist.  It is important to note that the command file
# is implemented as a named pipe and only exists when Nagios is
# running.  You may want to modify the startup script for Nagios
# to dump the contents of this file into the command file after
# it starts Nagios.  Or you may simply choose to ignore any
# check results received while Nagios was not running...

alternate_dump_file=/var/run/nagios/nsca.dump


# AGGREGATED WRITES OPTION
# This option determines whether or not the nsca daemon will
# aggregate writes to the external command file for client
# connections that contain multiple check results.  If you
# are queueing service check results on remote hosts and
# sending them to the nsca daemon in bulk, you will probably
# want to enable bulk writes, as this will be a bit more
# efficient.
# Values: 0 = do not aggregate writes, 1 = aggregate writes

aggregate_writes=0



# APPEND TO FILE OPTION
# This option determines whether or not the nsca daemon will
# will open the external command file for writing or appending.
# This option should almost *always* be set to 0!
# Values: 0 = open file for writing, 1 = open file for appending

append_to_file=0



# MAX PACKET AGE OPTION
# This option is used by the nsca daemon to determine when client
# data is too old to be valid.  Keeping this value as small as
# possible is recommended, as it helps prevent the possibility of
# "replay" attacks.  This value needs to be at least as long as
# the time it takes your clients to send their data to the server.
# Values are in seconds.  The max packet age cannot exceed 15
# minutes (900 seconds).  If this variable is set to zero (0), no
# packets will be rejected based on their age.

max_packet_age=30



# DECRYPTION PASSWORD
# This is the password/passphrase that should be used to descrypt the
# incoming packets.  Note that all clients must encrypt the packets
# they send using the same password!
# IMPORTANT: You don't want all the users on this system to be able
# to read the password you specify here, so make sure to set
# restrictive permissions on this config file!

password=passwd



# DECRYPTION METHOD
# This option determines the method by which the nsca daemon will
# decrypt the packets it receives from the clients.  The decryption
# 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 a decryption
# method.
#
# Note: The decryption method you specify here must match the
#       encryption method the nsca clients use (as specified in
#       the send_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
#	5 = CAST-256
#	6 = xTEA
#	7 = 3WAY
#	8 = BLOWFISH
#	9 = TWOFISH
#	10 = LOKI97
#	11 = RC2
#	12 = ARCFOUR
#
#	14 = RIJNDAEL-128
#	15 = RIJNDAEL-192
#	16 = RIJNDAEL-256
#
#	19 = WAKE
#	20 = SERPENT
#
#	22 = ENIGMA (Unix crypt)
#	23 = GOST
#	24 = SAFER64
#	25 = SAFER128
#	26 = SAFER+
#

decryption_method=2
How do I know if It's working?

EDIT:
my send_nsca.cfg

Code: Select all

password=passwd
encruption_method=2
EDIT2:
I can send manually passive check from GUI and it's working. But I need to know how can I check it for sure...

Re: Configuring Notifications in Nagios Core

Posted: Mon Mar 03, 2014 1:02 pm
by slansing
You can put whatever you like there, it will be displayed as the status information.

Re: Configuring Notifications in Nagios Core

Posted: Tue Mar 04, 2014 12:43 am
by mkot
Hi, I know, I figured it out yesterday.
Now I need to configure that host will send informations to Nagios, but I don't know hot to do it. I've been trying do it as tutorial says, but it doesn't work :(

EDIT:

Code: Select all

root@nagios:~# echo -e "nagios\test\t0\t0" | /usr/sbin/send_nsca -H localhost -c /etc/send_nsca.cfg
Connection refused by host
Error: Could not connect to host localhost on port 5667
root@nagios:~#
:evil: F*, I hope I'll quick resolve this issues with Nagios :/

EDIT2:
I'm trying configure it with xinted (was in one of manual I read). Schould I remove xinted and run nsca as a --daemon (standalone)?


EDIT3:
I had got Connection refused message, I found at /var/log/syslog that there is error at /etc/xinted.d/nsca file, sth like: "Missing { at line 2".
I had got there:

Code: Select all

service nsca{
...
}
It has to be:

Code: Select all

service nsca
{
...
}
Now when I put (for testing):

Code: Select all

root@nagios:~# send_nsca -H localhost -c /etc/send_nsca.cfg
I get
Error: Timeout after 10 seconds

Code: Select all

netstat |grep 5667
shows me nothing :/

Re: Configuring Notifications in Nagios Core

Posted: Tue Mar 04, 2014 11:07 am
by slansing
What is the output of:

Code: Select all

iptables -L
Are you intentionally trying to check nsca against itself locally? If I'm piecing this together properly it looks like you are manually trying to send a passive result from yourself to yourself.

Re: Configuring Notifications in Nagios Core

Posted: Tue Mar 04, 2014 11:21 am
by mkot

Code: Select all

root@nagios:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
root@nagios:~# ^C
root@nagios:~#
You're right, I tried to do this to confirm that it's working...

Is there solution step-by-step where I can find how to configure nsca at Nagios Core and Windows?

Re: Configuring Notifications in Nagios Core

Posted: Tue Mar 04, 2014 5:41 pm
by tmcdonald
Is NPCD running?

Code: Select all

service npcd status
if not, run

Code: Select all

service npcd start
and wait a bit.