Skip to content

Instantly share code, notes, and snippets.

@MarijnKoesen
Created June 6, 2013 07:25
Show Gist options
  • Save MarijnKoesen/5719885 to your computer and use it in GitHub Desktop.
Save MarijnKoesen/5719885 to your computer and use it in GitHub Desktop.
Send Zabbix notification via Pushover
#!/usr/bin/php
<?php
/**
* Zabbix notification script, used to send zabbix notifications via pushover
* to smartphones like an SMS.
*
* Usage: sendPushoverNotification <pushover-user-key> <subject> <message>
* @author Marijn Koesen
* @version 0.1
*/
define('PUSHOVER_APP_TOKEN', 'SET_ME_WITH_YOUR_OWN_APP_TOKEN'); // Your 'Zabbix' app token from Pushover
if ($argc != 4) {
die("Usage: {$argv[0]} <pushover-user-key> <subject> <message>\n");
}
list($program, $to, $subject, $message) = $argv;
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://api.pushover.net/1/messages.json',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => array(
'token' => PUSHOVER_APP_TOKEN, // the pushover app token
'user' => $to, // the pushover user token
'message' => $subject . ': ' . $message,
)
));
$result = json_decode(curl_exec($ch), 1);
curl_close($ch);
if (!isset($result['status']) || $result['status'] != 1) {
echo 'ERROR: could not send message, pushover said: "' . implode(', ', $result['errors']) . '"' . "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment