Nagios ( Core & XI )

Some basic usage examples of Nagios Core (XI) monitoring system

Add new user ( cli way)

htpasswd -c /tmp/rouser rouser
cat /tmp/rouser >> /usr/local/nagios/etc/htpasswd.users


Adding new custom check ( e.g. your script) (cli way)

1. Define command


define command {
       command_name                             check_name
       command_line                             /path/to/your/executable/

2. Define service with this command
In /usr/local/nagios/etc/ may be one *.cfg file named just «services» where will be all services
OR there will be a folder «services» with many *.cfg files for each host


define service {
        host_name                       hostname
        service_description             check_description
        use                             local-service
        check_command                   check_name
        check_interval                  5 # min
        retry_interval                  1 # min
        check_period                    24x7 # default name of interval 
        register                        1

3. Define host for service ( if it doesn’t exist yet)
If you still doesn’t add host in monitoring

define host {
        host_name                       hostname
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        register                        1

NSClient custom check (WINDOWS)

Assume that you already have working nsclient and want to add new custom check that will execute in remote host

1. Place executable script in
C:\Program Files\NSClient++\scripts
2. Edit nsclient.ini file ( NSC.ini in old version)
uncomment modules


Define new command

[/settings/external scripts/scripts]

OR fol old versions

[External Scripts]

3. Define new Nagios service

$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c check_tz 

Perfdata handling

If you want visualizations for your custom date in graph format your script must return special perfdata format

for example, your script return string «Server uptime is $(uptime)»
that these data will be graphed, your output string sould be «Server uptime is $(uptime)|uptime=$(uptime)»

i.e. after simple output just set pipe ‘|’ and list perfadta by a space in format «variable=value»

Ask any other questions about custom checks and perfdata handling in comments



AskDevops —>

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *