Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?
  3. // exit;
  4. // Check if we have the required parameters
  5. if (strlen($argv[3]) == 0) {
  6. echo "Syntax: " . $argv[0] . " <recipient> <subject> <message>\n";
  7. exit();
  8. }
  9. require("/home/zabbix/bin/class.jabber.php");
  10. require("/home/zabbix/bin/jabber.functions.php");
  11.  
  12. // EXCLUDED USER LIST
  13. $excluded_users = array(
  14. "bj@asmallorange.com",
  15. "pyload@asmallorange.com",
  16. "doug@asmallorange.com",
  17. "updates@asmallorange.com",
  18. "yammer@chat.yammer.com",
  19. "drizztadmin@asmallorange.com",
  20. "paula@asmallorange.com",
  21. "cheryl@asmallorange.com",
  22. "jessica@asmallorange.com",
  23. "ryanafdahl@asmallorange.com",
  24. );
  25.  
  26. $message = $argv[2];
  27.  
  28. // Send alerts to a fifo for other notification processing
  29.  
  30. $fifo = '/tmp/zabbix-jab.fifo';
  31. $mode = 0644;
  32. if (!file_exists($fifo)) {
  33. posix_mkfifo($fifo, $mode);
  34. }
  35. $f = fopen($fifo, 'w');
  36. fwrite($f, $message."\n");
  37. fclose($f);
  38.  
  39.  
  40. //$message = "Testing jabber";
  41. //$user = "bj";
  42.  
  43. if (strlen($message) == 0 ) exit;
  44. //if (strlen($user) == 0 ) exit;
  45. $online = array();
  46.  
  47. $JABBER = connectJabber("asoserver", "ch33s321", "asmallorange.com");
  48. $JABBER->CruiseControl(1);
  49.  
  50. $JABBER->RosterUpdate();
  51. foreach ($JABBER->roster as $user) {
  52. $to = $user['jid'];
  53. if ((!strstr($to, "aim.asmallorange.com")) && (array_search($to, $excluded_users) === false)) {
  54. if ($online[$to] == 1) {
  55. print "$to is online, sending message\n";
  56. $JABBER->SendMessage("$to","normal", NULL, array("body" => htmlspecialchars($message)),$payload);
  57. $JABBER->CruiseControl(1);
  58.  
  59. $JABBER->RosterUpdate();
  60. foreach ($JABBER->roster as $user) {
  61. $to = $user['jid'];
  62. if ((!strstr($to, "aim.asmallorange.com")) && (array_search($to, $excluded_users) === false)) {
  63. if ($online[$to] == 1) {
  64. print "$to is online, sending message\n";
  65. $JABBER->SendMessage("$to","normal", NULL, array("body" => htmlspecialchars($message)),$payload);
  66. $JABBER->CruiseControl(1);
  67. } else {
  68. print "$to is offline\n";
  69. }
  70. } else {
  71. print "excluding $to\n";
  72. }
  73.  
  74. }
  75.  
  76. $JABBER->Disconnect();
  77.  
  78. exit;
  79.  
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement