Last active
December 1, 2016 10:47
-
-
Save adzhurinskij/3076b4a1e7bfd0474cfd87ed30579902 to your computer and use it in GitHub Desktop.
Alert script with telegram @crierbot bot for Zabbix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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