Tuesday, September 5, 2017

Nagios Active Checks (check_ncpa.py)

Copy check_ncpa.py  to /usr/local/nagios/libexec (plugin directory)
Change mode and check version

Define new check_ncpa command by adding following lines to /usr/local/nagios/etc/objects/commands.cfg


define command {
    command_name    check_ncpa
    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}

Create ncpa.cfg file  in /usr/local/nagios/etc/objects
touch /usr/local/nagios/etc/objects/ncpa.cfg

Add following lines in ncpa.cfg to define host and monitoring services

define host {
    host_name               NCPA 2 Host
    address                 192.168.1.10
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M system/agent_version
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    contacts                nagiosadmin
    notification_interval   60
    notification_period     24x7
    notifications_enabled   1
    icon_image              ncpa.png
    statusmap_image         ncpa.png
    register                1
}

define service {
    host_name               NCPA 2 Host
    service_description     CPU Usage
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               NCPA 2 Host
    service_description     Memory Usage
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M memory/virtual -w 50 -c 80 -u G
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               NCPA 2 Host
    service_description     Process Count
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M processes -w 150 -c 200
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}


And finaly, tell Nagios to add monitoring from new configuration file by adding new cfg_file line to nagios.cfg file.

Change icon_image and statusmap_image  in ncpa.cfg file by choosing some png files from
/usr/local/nagios/share/images folder.


For example, instead ncpa.png (in ncpa.cfg) choose workstation.png