DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Monitor The Status Of Luminis Message Broker In Perl

02.28.2006
| 731 views |
  • submit to reddit
        // Monitor the status of luminis message broker in perl

#!/bin/perl

open (BROKER, "mbtool list brokerstatus |" );

$count = 0;
$msg = "";
$errflag = false;

while (<BROKER>){
  $count++;
  chop;

  if ($count == 2 && index($_, "running") == -1){
    $msg = $mst."The message broker may not be running\n";
    $errflag = true;
  }

  if ($count == 4) {
    @parts = split(/\s/, $_);
    if ($parts[6] > 50){
      $msg = $msg."There are $parts[6] messages currently in the broker";
      $errflag = true;
    }
  }
}

close BROKER;

if ($errflag){
  open (MAIL, "|/usr/lib/sendmail -t -n") || die ("Could not send mail $_");
  print MAIL "To: jonahlyn\@unm.edu\n";
  print MAIL "From: jonahlyn\@unm.edu\n";
  print MAIL "Subject: Message Broker Alert\n";
  print MAIL "$msg\n";
  print MAIL ".\n";
  close (MAIL);
}