Guest User

Untitled

a guest
Jul 18th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #
  3. # jabber.alert - Jabber alert for mon
  4. #
  5. # The first line from STDIN is summary information, adequate to send
  6. # to a pager or email subject line.
  7. #
  8. # Jim Trocki, trockij@transmeta.com
  9. #
  10. # Copyright (C) 1998, Jim Trocki
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program; if not, write to the Free Software
  24. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. #
  26. use Getopt::Std;
  27. use Text::Wrap;
  28.  
  29. getopts ("S:s:g:h:t:l:u");
  30.  
  31. $summary=<STDIN>;
  32. chomp $summary;
  33.  
  34. $summary = $opt_S if (defined $opt_S);
  35.  
  36. $jid = shift;
  37.  
  38. $ALERT = $opt_u ? "UPALERT" : "ALERT";
  39.  
  40. $t = localtime($opt_t);
  41. ($wday,$mon,$day,$tm) = split (/\s+/, $t);
  42.  
  43. open (XMPP, "| /usr/local/bin/xsend $jid") ||
  44. die "could not open pipe to xsend: $!\n";
  45.  
  46. print XMPP <<EOF;
  47. $ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm)
  48.  
  49. EOF
  50.  
  51. print XMPP wrap ("", "", "Summary output : $summary"), "\n";
  52.  
  53. print XMPP <<EOF;
  54.  
  55. Group : $opt_g
  56. Service : $opt_s
  57. Time noticed : $t
  58. Secs until next alert : $opt_l
  59. EOF
  60.  
  61. print XMPP wrap ("", "\t\t\t", "Members : $opt_h"), "\n";
  62.  
  63. print XMPP <<EOF;
  64.  
  65. Detailed text (if any) follows:
  66. -------------------------------
  67. EOF
  68.  
  69. #
  70. # The remaining lines normally contain more detailed information,
  71. # but this is monitor-dependent.
  72. #
  73. while (<STDIN>) {
  74. print XMPP;
  75. }
  76. close (XMPP);
Add Comment
Please, Sign In to add comment