Nagios

Parny | Nagios Integration Guide

Parny supports direct integration with Nagios alerts. Nagios is a network and system monitoring tool that can create alarms to detect and prevent potential problems. This documentation explains how to redirect alarms created in Nagios to a webhook using Parny.


Parny Settings


  1. Go to the Parny interface.

  2. Navigate to the "Services" section of your organization.

  3. Click on the "New Services" option in the upper right corner.

  4. Enter the relevant service name.

Service Name Usage: The service name here is independent of the structure and can be chosen according to the preferences of the organization.


  1. Select Nagios from the list of integrations.

  2. Click "Add".

  3. After the service is created, the following screen will appear.


drawing


  • You can now click on the token section of your service and copy your Nagios Webhook URL.


Nagios Configuration


This section discusses an "Adding Alert Notification" and "Redirecting Alarms".​


  1. In order to add an alert notification, the following definition must be made in the /nagios/etc/objects/contacts.cfg file of the nagios path in the machine.


drawing


define contact {
      contact_name                 	        parny
      alias                 	                Parny
      service_notification_period		24x7
      host_notification_period                 	24x7
      service_notification_options             	w,u,c,r
      host_notification_options                	d,r
      service_notification_commands            	notify-service-by-parny
      host_notification_commands               	notify-host-by-parny
}



  1. Then, it is necessary to add Contact group in the same file.


drawing


define contactgroup {
      contactgroup_name		admins
      alias            		Nagios Administrators
      members			nagiosadmin, slack, parny
}



  1. After performing this operation, go to the file in the nagios/etc/objects/commands.cfg path and add the following.


drawing


##############PARNY##################
define command {
      command_name notify-service-by-parny
      command_line /usr/local/bin/parny-new.sh "$HOSTNAME$" "$HOSTOUTPUT$" "$SERVICEDESC$"
}

define command {
      command_name notify-host-by-parny
      command_line /usr/local/bin/parny-new.sh "$HOSTNAME$" "$HOSTOUTPUT$" "$HOSTSTATE$"



  1. After performing this operation, the specified file path of the script below must be added in order to send a healthy alert through the script. If the correct path is not given, it will not work. In the example above, it is defined as /usr/local/bin/parny-new.sh.


drawing


#!/usr/bin/env bash
date=$(date +%Y-%m-%d)
echo "$date"
PARNY_URL=https://nagios.parny.io/alert/******

hosts_total=$(( $NAGIOS_TOTALHOSTSUP + $NAGIOS_TOTALHOSTSDOWN ))
services_total=$(( $NAGIOS_TOTALSERVICESOK + $NAGIOS_TOTALSERVICEPROBLEMS ))

DATA="{
  \"embeds\": 
    {
      \"hostname\": \"($1)\",
      \"description\": \"$2\",
      \"hoststate\": \"$3\",
      \"datetime\": \"$date\"
    }
}"

curl -4 -X POST --data "$DATA" $PARNY_URL

exit $?


drawing


With these settings, your Nagios alarms will be forwarded to Parny, allowing you to manage them alongside your other alerts within your organization's Parny interface.​