> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flashduty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Nagios Alert Events

> Sync Nagios alert events to Flashduty via webhook for automated alert noise reduction

<div class="hide">
  ## In Flashduty

  ***

  You can obtain an integration push URL through either of these two methods:

  ### Using Private Integration

  Choose this method when you don't need to route alert events to different channels - it's simpler.

  <details>
    <summary>Expand</summary>

    1. Go to the Flashduty console, select **Channel**, and enter a channel's details page
    2. Select the **Integrations** tab, click **Add Integration** to enter the integration page
    3. Choose **Nagios** integration and click **Save** to generate a card
    4. Click the generated card to view the **Push URL**, copy it for later use, and you're done
  </details>

  ### Using Shared Integration

  Choose this method when you need to route alerts to different channels based on the alert event payload.

  <details>
    <summary>Expand</summary>

    1. Go to the Flashduty console, select **Integration Center=>Alert Events** to enter the integration selection page
    2. Select **Nagios** integration:
       * **Integration Name**: Define a name for this integration
    3. Configure the default route and select the corresponding channel (after the integration is created, you can go to `Route` to configure more routing rules)
    4. Click **Save** and copy the newly generated **push URL** for later use
    5. Done
  </details>
</div>

## In Nagios

***

<div class="md-block">
  Nagios installation paths may vary depending on the system and installation method. Please adjust the paths in the following configuration according to your actual environment.

  ### Step 1: Download Notification Script

  Log in to the Nagios Server host and download the notification script to the Nagios plugin directory:

  * **Debian/Ubuntu systems** (typically `/usr/lib/nagios/plugins/`):

  ```bash theme={null}
  cd /usr/lib/nagios/plugins/
  wget --header="Referer: https://console.flashcat.cloud" https://download.flashcat.cloud/flashduty/integration/nagios/send_to_flashduty.sh
  chmod +x send_to_flashduty.sh
  ```

  * **RHEL/CentOS systems** (typically `/usr/lib64/nagios/plugins/`):

  ```bash theme={null}
  cd /usr/lib64/nagios/plugins/
  wget --header="Referer: https://console.flashcat.cloud" https://download.flashcat.cloud/flashduty/integration/nagios/send_to_flashduty.sh
  chmod +x send_to_flashduty.sh
  ```

  * **Source installation** (typically `/usr/local/nagios/libexec/`):

  ```bash theme={null}
  cd /usr/local/nagios/libexec/
  wget --header="Referer: https://console.flashcat.cloud" https://download.flashcat.cloud/flashduty/integration/nagios/send_to_flashduty.sh
  chmod +x send_to_flashduty.sh
  ```

  > **Note:** The script uses the `curl` command. Please ensure curl is installed on your Nagios Server.

  ### Step 2: Create Flashduty Configuration File

  Download the Flashduty configuration file to the Nagios configuration directory:

  * **Debian/Ubuntu systems** (typically `/etc/nagios3/conf.d/`):

  ```bash theme={null}
  cd /etc/nagios3/conf.d/
  wget --header="Referer: https://console.flashcat.cloud" https://download.flashcat.cloud/flashduty/integration/nagios/flashduty.cfg
  ```

  * **RHEL/CentOS systems** (typically `/etc/nagios/objects/`):

  ```bash theme={null}
  cd /etc/nagios/objects/
  wget --header="Referer: https://console.flashcat.cloud" https://download.flashcat.cloud/flashduty/integration/nagios/flashduty.cfg
  ```

  * **Source installation** (typically `/usr/local/nagios/etc/objects/`):

  ```bash theme={null}
  cd /usr/local/nagios/etc/objects/
  wget --header="Referer: https://console.flashcat.cloud" https://download.flashcat.cloud/flashduty/integration/nagios/flashduty.cfg
  ```

  ### Step 3: Modify Configuration File

  Edit the downloaded `flashduty.cfg` file and modify the following:

  1. Replace the `pager` field value with the integration push URL obtained from the Flashduty console
  2. Modify the script path in `command_line` according to your Nagios installation path

  Configuration file example:

  ```
  define contact {
      contact_name                    Flashduty
      alias                           Flashduty Alert Receiver
      service_notification_commands   notify-service-by-Flashduty
      host_notification_commands      notify-host-by-Flashduty
      service_notification_options    w,u,c,r
      host_notification_options       d,u,r
      service_notification_period     24x7
      host_notification_period        24x7
      pager                           <YOUR_FLASHDUTY_PUSH_URL>
  }

  define command {
      command_name    notify-host-by-Flashduty
      command_line    <NAGIOS_PLUGIN_PATH>/send_to_flashduty.sh type=HOST WEBHOOK_URL="$CONTACTPAGER$" hostname="$HOSTNAME$" state="$HOSTSTATE$" output="$HOSTOUTPUT$" notification_type="$NOTIFICATIONTYPE$" time="$LONGDATETIME$" host_address="$HOSTADDRESS$" host_alias="$HOSTALIAS$" check_command="$HOSTCHECKCOMMAND$"
  }

  define command {
      command_name    notify-service-by-Flashduty
      command_line    <NAGIOS_PLUGIN_PATH>/send_to_flashduty.sh type=SERVICE WEBHOOK_URL="$CONTACTPAGER$" hostname="$HOSTNAME$" state="$SERVICESTATE$" output="$SERVICEOUTPUT$" notification_type="$NOTIFICATIONTYPE$" time="$LONGDATETIME$" host_address="$HOSTADDRESS$" service_desc="$SERVICEDESC$" host_alias="$HOSTALIAS$" max_attempts="$MAXSERVICEATTEMPTS$"
  }
  ```

  Parameter descriptions:

  * `pager`: Flashduty push URL, the integration push URL obtained from the Flashduty console
  * `<NAGIOS_PLUGIN_PATH>`: Replace with the actual script path, such as `/usr/local/nagios/libexec`
  * `service_notification_options`: Service alert notification options, w=warning, u=unknown, c=critical, r=recovery
  * `host_notification_options`: Host alert notification options, d=down, u=unreachable, r=recovery

  > **Tip:** To include additional information in alerts, you can append parameters in `key=value` format at the end of `command_line`, for example: `environment="production" region="$_HOSTREGION$"`. These parameters will be pushed to Flashduty as labels.

  ### Step 4: Include Configuration File

  If you are using **RHEL/CentOS systems** or **source installation**, you need to include the Flashduty configuration file in the Nagios main configuration file.

  * **RHEL/CentOS systems**: Edit `/etc/nagios/nagios.cfg` and add:

  ```
  cfg_file=/etc/nagios/objects/flashduty.cfg
  ```

  * **Source installation**: Edit `/usr/local/nagios/etc/nagios.cfg` and add:

  ```
  cfg_file=/usr/local/nagios/etc/objects/flashduty.cfg
  ```

  > **Note:** Debian/Ubuntu systems typically auto-load all configuration files in the `/etc/nagios3/conf.d/` directory, so manual inclusion is not required.

  ### Step 5: Add Flashduty to Contact Group

  Edit the contacts configuration file to add the Flashduty contact to the `admins` contact group (or another contact group you use):

  * **Debian/Ubuntu systems**: Edit `/etc/nagios3/conf.d/contacts_nagios2.cfg`
  * **RHEL/CentOS systems**: Edit `/etc/nagios/objects/contacts.cfg`
  * **Source installation**: Edit `/usr/local/nagios/etc/objects/contacts.cfg`

  Find the contact group definition and add Flashduty to the members list:

  ```
  define contactgroup {
      contactgroup_name       admins
      alias                   Nagios Administrators
      members                 nagiosadmin,Flashduty
  }
  ```

  ### Step 6: Verify Configuration and Restart Service

  1. Verify the Nagios configuration file:

  * **Debian/Ubuntu systems**:

  ```bash theme={null}
  /usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg
  ```

  * **RHEL/CentOS systems**:

  ```bash theme={null}
  /usr/sbin/nagios -v /etc/nagios/nagios.cfg
  ```

  * **Source installation**:

  ```bash theme={null}
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  ```

  2. If verification passes, restart the Nagios service:

  ```bash theme={null}
  # Debian/Ubuntu
  systemctl restart nagios3

  # RHEL/CentOS/Source installation
  systemctl restart nagios
  ```

  3. After configuration is complete, Nagios will automatically push alerts to Flashduty when detected.
</div>

## Status Mapping

***

<div class="md-block">
  Nagios to Flashduty alert severity mapping:

  | Nagios      | Flashduty | Status    |
  | ----------- | --------- | --------- |
  | CRITICAL    | Critical  | Critical  |
  | DOWN        | Critical  | Critical  |
  | UNREACHABLE | Critical  | Critical  |
  | WARNING     | Warning   | Warning   |
  | OK          | Ok        | Recovered |
  | UP          | Ok        | Recovered |
  | UNKNOWN     | Info      | Info      |
</div>
