Home Directory Addons Notifications Server Push Notifications for Android

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com


Remember Me

Directory Tree

Server Push Notifications for Android

1 vote
Current Version
Last Release Date
Compatible With
  • Nagios 3.x
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Server Push Notifications for Android
This "Addon" (Changes) lets you push all Nagios notifications to your Android device running an App called "Server Push Notifications" that also supports Tasker.
To send push notifications to the Android App you need to apply these changes. Example using PHP but you can also use a shell script etc. In this tutorial i use Debian Squeeze so path and files could be different to your Linux distribution

1) Edit /etc/nagios3/comands.cfg and insert the following code under the "NOTIFICATION COMMANDS" section

# 'server-push-notifications' comannd definition
define command{
command_name server-push-notifications
command_line php /etc/nagios3/send.php $NOTIFICATIONTYPE$ $SERVICEDESC$ "***** Nagios *****nnHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$"

2) Create a new file /etc/nagios3/send.php with the following content

class notify_obj {
public $notification = array();
public function __construct() {
$this->notification = array(

$pushmsg = new notify_obj();
$pushmsg->notification["username"] = "YOUR USERNAME"; // Change this to the username in your app
$pushmsg->notification["password"] = "YOUR PASSWORD"; // Change this to the password set in your app
$pushmsg->notification["category"] = "1";
$pushmsg->notification["encrypted"] = "0";
$pushmsg->notification["flags"] = "0";
$pushmsg->notification["service"] = htmlentities($argv[2], ENT_QUOTES, "UTF-8");
$pushmsg->notification["title"] = htmlentities($argv[1], ENT_QUOTES, "UTF-8");
$pushmsg->notification["message"] = htmlentities($argv[3], ENT_QUOTES, "UTF-8");
$jsonString = json_encode($pushmsg);

// Send JSON Object to Push Server via Curl
$ch = curl_init();

// Replace SERVERNAME with the one mentioned in the settings of the APP.
curl_setopt($ch, CURLOPT_URL, "https://SERVERNAME/pushjson.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // See API docs in forum to activate!
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonString);
curl_setopt($ch, CURLOPT_TIMEOUT, '10'); // wait max 10s to complete
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '8' ); // wait max 8s to connect
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'

$result = curl_exec($ch);
// Check $result for any status codes coming back from the server if you need

3) Save the file and assign correct permissions so Nagios can execute it later

chown nagios:nagios /etc/nagios3/send.php
chmod 755 /etc/nagios3/send.php

4) Edit /etc/nagios3/conf.d/contacts_nagios2.cfg and configure the default contact like below. Please take note for this example I removed any email notification from the default contact for better readability. For more options see the Nagios Manual.

define contact{
contact_name root
alias Root
service_notification_period 24x7
service_notification_options w,u,c,r,f
service_notification_commands server-push-notifications
host_notification_period 24x7
host_notification_options d,u,f,r,s
host_notification_commands server-push-notifications

5) Save the file and restart Nagios

/etc/init.d/nagios3 restart
Reviews (1)
bysujey, April 24, 2018
I performed all the above steps. But I wish to know the further steps I must take in order to get the data in the app.