Over a million developers have joined DZone.

Monitor The Status Of Luminis Message Broker In Perl

·
// Monitor the status of luminis message broker in perl


#!/bin/perl

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

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

while (){
  $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);
}

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}