Skip to main content

Nagios Plugin

A bash-based Nagios plugin that integrates with the Generator Labs API. The plugin makes an HTTPS request to the Generator Labs API and maps the numeric response to standard Nagios exit codes.

Source: https://github.com/generator-labs/nagios-plugin

Supported Products

  • RBL Monitoring (rbl) — monitors IP/domain blacklist status
  • Certificate Monitoring (cert) — monitors SSL/TLS certificate errors

Return Values

The API returns a plain integer: 0 when no issues are detected, > 0 when issues are found, and -1 on error. The script maps these to Nagios exit codes:

StatusAPI ValueMeaning
OK (0)0No issues detected
CRITICAL (2)> 0Issues detected (count of listings or errors)
UNKNOWN (3)-1 or request failureAPI error or invalid credentials

Requirements

  • Nagios Core or compatible (Icinga, etc.)
  • curl installed on the Nagios server
  • HTTPS connectivity to api.generatorlabs.com

Installation

  1. Copy check_generator.sh into your Nagios plugins directory:
cp check_generator.sh /usr/lib/nagios/plugins/
note

The plugins directory may be /usr/lib64/nagios/plugins depending on your platform.

  1. Make the script executable:
chmod +x /usr/lib/nagios/plugins/check_generator.sh

Usage

./check_generator.sh <check_type> <account_sid> <auth_token>

Where <check_type> is one of:

  • rbl — check RBL monitoring (uses the rbl/listings/count endpoint)
  • cert — check Certificate monitoring (uses the cert/errors/count endpoint)

Nagios Configuration

1. Store Credentials

Add your Generator Labs credentials to your resource.cfg file using $USERn$ macros. These macros are not visible in the Nagios web UI:

$USER10$=ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$USER11$=0000000000000000000000000000000000000000000000000000000000000000

Replace the values with your Account SID and Auth Token from the Generator Labs Portal.

2. Define Commands

Add command entries in your commands.cfg for the products you use:

define command{
command_name check-generator-rbl
command_line $USER1$/check_generator.sh rbl $USER10$ $USER11$
}

define command{
command_name check-generator-cert
command_line $USER1$/check_generator.sh cert $USER10$ $USER11$
}

3. Create a "No Ping" Host Template

Since this is a web service, create a host template that skips the default ping check:

define host{
name noping-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
max_check_attempts 3
check_interval 10
retry_interval 5
notification_interval 0
notification_period 24x7
notification_options d,u,r
contact_groups admins
register 0
}

4. Create the Host

define host {
use noping-host
host_name GeneratorLabs
alias Generator Labs
}

5. Create Service Entries

Add service entries for the products you subscribe to:

define service {
use generic-service
host_name GeneratorLabs
service_description Generator Labs RBL Monitoring
check_command check-generator-rbl
check_interval 10
retry_interval 2
max_check_attempts 3
notification_interval 0
}

define service {
use generic-service
host_name GeneratorLabs
service_description Generator Labs Certificate Monitoring
check_command check-generator-cert
check_interval 10
retry_interval 2
max_check_attempts 3
notification_interval 0
}