asuknath / Nagios-Status-JSON

Nagios Status JSON
26 stars 19 forks source link

Nagios Status JSON

Nagios Status JSON

This PHP API script reads Nagios status.dat file and return the JSON result. This API is desinged for Nagios Client unofficial Nagios status monitoring app.

Step 1

Upload nath_status.php to your Nagios web root folder.

Nagios Core's 3.5.1 default Web Root folder Web Root Folder - Centos

/usr/share/nagios/html/

Nagios Core's default Web Root folder Web Root Folder - Centos & Ubuntu

/usr/local/nagios/share/

NagiosXI's default Web Root folder Web Root Folder - Centos & Ubuntu

/usr/local/nagiosxi/html/

Step 2

Edit nath_status.php. You can use your favourite text editor

vi /usr/local/nagios/share/nath_status.php

Change status.dat file's path according to your Nagios Server configuration.

$statusFile = '/usr/local/nagios/var/status.dat';

Nagios Core's 3.5.1 status.dat file's location:

/var/log/nagios/status.dat

Use following command to find status.dat location.

find / -name status.dat

Step 3

Download and Configure iPhone or Android Server Alarms Nagios Client

Nagios Client

Go to settings

Settings

Update URL

Nagios Core

(http or https)://nagiosserver_address/nagios/

NagiosXI

(http or https)://nagiosserver_address/nagiosxi/

URL Update

Step 5

Add IOS Push Notification and Android FCM Notification

'sm-service-push-notify' command definition

define command{ command_name sm-service-push-notify command_line /usr/local/nagios/libexec/ServerAlarmNotify.php $HOSTNAME$ YOURGROUPKEY SERVICE $SERVICESTATE$ }

#
- **5** Edit **templates.cfg** file. Modify Contact Templates and add **sm-service-push-notify** as service notification command and **sm-host-push-notify** as host notification command.
   -
```javascript
define contact{
        name                            generic-contact
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email,sm-service-push-notify
        host_notification_commands      notify-host-by-email,sm-host-push-notify
        register                        0                           
        }

#

For support contact support@serveralarms.com