Nagios
IT-Man avatar
Written by IT-Man
Updated over a week ago

Issues detected by the Nagios monitoring solution can be submitted to Panorama9. We'll then handle notifications using any of the channels you've configured.

Setup only requires a few simple steps:

  1. Install the Panorama9 Agent on the Nagios server

  2. Add the following script to you local bin folder (typical /usr/local/bin) and make it executable (chmod 755 path_to_script)

#!/bin/bash
while getopts "t:a:b:c:d:e:f:g:h:i:j:" optionName; do
case "$optionName" in
    t) eventtype="$OPTARG" ;;
    a) serviceeventid="$OPTARG" ;;
    b) hostalias="$OPTARG" ;;
    c) servicedesc="$OPTARG" ;;
    d) notificationtype="$OPTARG" ;;
    e) hostaddress="$OPTARG" ;;
    f) hostoutput="$OPTARG" ;;
    g) servicestate="$OPTARG" ;;
    h) serviceoutput="$OPTARG" ;;
    i) hoststate="$OPTARG" ;;
    j) hostname="$OPTARG" ;;
   \?) exit 2;;
esac
doneif [ $notificationtype = "RECOVERY" ];
then
    /opt/P9/Agent/issue.pl --type hardware-failure --id $serviceeventid --resolved;
elif [ $eventtype = "service" ];
then
    /opt/P9/Agent/issue.pl --type hardware-failure --id $serviceeventid --issue $hostalias/$servicedesc --description "Notification Type: $notificationtype Service: $servicedesc  Host: $hostalias  Address: $hostaddress  State: $servicestate Additional Info:  $serviceoutput" --ttl 1;
echo /opt/P9/Agent/issue.pl --type hardware-failure --id $serviceeventid --issue $hostalias/$servicedesc --description "Notification Type: $notificationtype Service: $servicedesc  Host: $hostalias  Address: $hostaddress  State: $servicestate Additional Info:  $serviceoutput" --ttl 1;
else
    /opt/P9/Agent/issue.pl --type hardware-failure --id $serviceeventid --issue $hostalias/$servicedesc --description "Notification Type: $notificationtype  Host: $hostname State: $hoststate  Service: $servicedesc  Address: $hostaddress  Info: $hostoutput" --ttl 1;
fi
echo -e
exit 0
  1. Edit commands config file (typical /etc/nagios3/commands.cfg), add the following 2 commands:

define command{
        command_name    notify-service-by-P9
        command_line    /usr/local/bin/notifybyp9.sh -t "service" -a "$SERVICEEVENTID$" -b "$HOSTALIAS$" -c "$SERVICEDESC$" -d "$NOTIFICATIONTYPE$" -e "$HOSTADDRESS$" -f "$HOSTOUTPUT$" -g "$SERVICESTATE$" -h "$SERVICEOUTPUT$" -i "$HOSTSTATE$" -j "$HOSTNAME$"
       }define command{
        command_name    notify-host-by-P9
        command_line    /usr/local/bin/notifybyp9.sh -t "host" -a "$SERVICEEVENTID$" -b "$HOSTALIAS$" -c "$SERVICEDESC$" -d "$NOTIFICATIONTYPE$" -e "$HOSTADDRESS$" -f "$HOSTOUTPUT$" -g "$SERVICESTATE$" -h "$SERVICEOUTPUT$" -i "$HOSTSTATE$" -j "$HOSTNAME$"
        }
  1. Edit your contact file and change your host and service notification command:

define contact{
        contact_name                    root
        alias                           Root
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d
        service_notification_commands   notify-service-by-P9
        host_notification_commands      notify-host-by-P9
        email                           root@localhost
        }

All done...

Did this answer your question?