Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/php
- <?
- // exit;
- // Check if we have the required parameters
- if (strlen($argv[3]) == 0) {
- echo "Syntax: " . $argv[0] . " <recipient> <subject> <message>\n";
- exit();
- }
- require("/home/zabbix/bin/class.jabber.php");
- require("/home/zabbix/bin/jabber.functions.php");
- // EXCLUDED USER LIST
- $excluded_users = array(
- "bj@asmallorange.com",
- "pyload@asmallorange.com",
- "doug@asmallorange.com",
- "updates@asmallorange.com",
- "yammer@chat.yammer.com",
- "drizztadmin@asmallorange.com",
- "paula@asmallorange.com",
- "cheryl@asmallorange.com",
- "jessica@asmallorange.com",
- "ryanafdahl@asmallorange.com",
- );
- $message = $argv[2];
- // Send alerts to a fifo for other notification processing
- $fifo = '/tmp/zabbix-jab.fifo';
- $mode = 0644;
- if (!file_exists($fifo)) {
- posix_mkfifo($fifo, $mode);
- }
- $f = fopen($fifo, 'w');
- fwrite($f, $message."\n");
- fclose($f);
- //$message = "Testing jabber";
- //$user = "bj";
- if (strlen($message) == 0 ) exit;
- //if (strlen($user) == 0 ) exit;
- $online = array();
- $JABBER = connectJabber("asoserver", "ch33s321", "asmallorange.com");
- $JABBER->CruiseControl(1);
- $JABBER->RosterUpdate();
- foreach ($JABBER->roster as $user) {
- $to = $user['jid'];
- if ((!strstr($to, "aim.asmallorange.com")) && (array_search($to, $excluded_users) === false)) {
- if ($online[$to] == 1) {
- print "$to is online, sending message\n";
- $JABBER->SendMessage("$to","normal", NULL, array("body" => htmlspecialchars($message)),$payload);
- $JABBER->CruiseControl(1);
- $JABBER->RosterUpdate();
- foreach ($JABBER->roster as $user) {
- $to = $user['jid'];
- if ((!strstr($to, "aim.asmallorange.com")) && (array_search($to, $excluded_users) === false)) {
- if ($online[$to] == 1) {
- print "$to is online, sending message\n";
- $JABBER->SendMessage("$to","normal", NULL, array("body" => htmlspecialchars($message)),$payload);
- $JABBER->CruiseControl(1);
- } else {
- print "$to is offline\n";
- }
- } else {
- print "excluding $to\n";
- }
- }
- $JABBER->Disconnect();
- exit;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement