Skip to content

Instantly share code, notes, and snippets.

@adzhurinskij
Last active December 1, 2016 10:47
Show Gist options
  • Save adzhurinskij/3076b4a1e7bfd0474cfd87ed30579902 to your computer and use it in GitHub Desktop.
Save adzhurinskij/3076b4a1e7bfd0474cfd87ed30579902 to your computer and use it in GitHub Desktop.
Alert script with telegram @crierbot bot for Zabbix
#!/usr/bin/env php
<?php
if (count($argv) == 4) {
$token = trim($argv[1]);
$subject = trim($argv[2]);
$body = trim($argv[3]);
$subject = str_replace("PROBLEM:", "\xF0\x9F\x93\x9B PROBLEM:", $subject);
$subject = str_replace("OK:", "\xE2\x9C\x85 OK:", $subject);
$msg = "https://zabbix.example.org" . PHP_EOL;
$msg .= "Subj: " . $subject . PHP_EOL . "Message: " . $body;
$msg = urlencode($msg);
$url = "https://crierbot.appspot.com/" . $token . "/send?message=" . $msg;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment