Nagios Plugin Script

Using Nagios Monitoring with the API

Though Spam Experts prohibits the use of the NRPE (Nagios Remote Plugin Executor) on the Local Cloud installation, it is still possible to use our API and a custom script to monitor the servers for certain services and statuses.

All that you require is PHP on the Nagios monitoring server and a Software API user with the correct credentials for the specific calls you want to monitor. The example below uses the api_get_json_server_status call.

Steps to install

  1. Download the php script here and save it on the Nagios monitoring server at /usr/local/nagios/libexec/

    This location may be different on your server if defaults have been changed

  2. Add the following code to the commands file found at /usr/local/nagios/etc/objects/commands.cfg

    This location may be different on your server if defaults have been changed

  3. define command{
    command_name check_spamexperts
    command_line php $USER1$/check_spamexperts.php -n $HOSTNAME$ -H api.domain.ext -u apiuser -p apipassword -w load5warninglevel -c load5criticallevel -i max_incoming_queue -o max_outgoing_queue
    }

  4. Create a host.cfg file and save it to /usr/local/nagios/etc/objects/
  5. define host{
    use generic-host ; Name of host template
    host_name node1.domain.ext
    alias Spamexperts spam cluster
    address 1.2.3.4
    check_command check-host-alive
    contact_groups critical-admins
    max_check_attempts 20
    notification_interval 60
    notification_period 24x7
    notification_options d,u,r
    }
    define host{
    use generic-host ; Name of host template
    host_name node2.domain.ext
    alias Spamexperts spam cluster
    address 1.2.3.5
    check_command check-host-alive
    contact_groups critical-admins
    max_check_attempts 20
    notification_interval 60
    notification_period 24x7
    notification_options d,u,r
    }

  6. Create a services.cfg file and save it to /usr/local/nagios/etc/objects/
  7. define service {
    use generic-service
    host_name node1.domain.ext,node2.domain.ext
    service_description spamexperts
    is_volatile 0
    check_period 24x7
    max_check_attempts 3
    normal_check_interval 5
    retry_check_interval 1
    contact_groups critical-admins
    notification_interval 240
    notification_period workhours
    notification_options w,u,c,r
    check_command check_spamexperts
    }

  8. Edit the nagios.cfg file to include these new configuration files
  9. cfg_file=/usr/local/nagios/etc/objects/host.cfg
    cfg_file=/usr/local/nagios/etc/objects/services.cfg

  10. Restart Nagios

Disclaimer: This documentation may contain references to third party software or websites. N-able has no control over third party software or content and is not responsible for the availability, security, or operation, of any third-party software. If you decide to utilize a release involving third-party software, you do so entirely at your own risk and subject to the applicable third party’s terms and conditions of the use of such software. No information obtained by you from N-able or this documentation shall create any warranty for such software.