The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 11-18-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,854
Something to begin with (it will print any mismatch):

Code:
#! /usr/bin/env perl


use warnings;
use strict;

my ($Thresholds_f, $Queue) = 
  ('/path/to/thresholds_file', '/users/tibprod/scripts/ShowQueues_leaiprod.sh|');
my %Thresholds_h;

open TH, '<', $Thresholds_f  or die "$Thresholds_f: $!\n";
  
while (<TH>) {
  tr/"//d;
  my @Fields = split /\s+/;
  $Thresholds_h{$Fields[0]} = [@Fields[1,2]];
  }

close TH;  

open QUEUE, '<', $Queue or die "$Queue: $!\n";

while (<QUEUE>) {
  my $Flag = 0;
  my @Fields = split /\s+/;
  while (my($Key, $Ref) = each %Thresholds_h) {
    my @Values = @$Ref;
    if ($Fields[0] =~ /^$Key$/) {
      print "\nChecking queue: $Fields[0] ... ";
      if ($Fields[1] != $Values[0]) {
        print "\n\n\t--> queue threshold mismatch: \n\n\tcurrent status: ",
        $Fields[1], "\n\tthreshold:      ", $Values[0], "\n";
        $Flag++
        }
      if ($Fields[2] != $Values[1]) {
         print "\n\t--> listeners threshold mismatch: \n\n\tcurrent status: ",
        $Fields[2], "\n\tthreshold:      ", $Values[1], "\n";
        $Flag++
        }
      print "OK\n\n" unless $Flag;    
      }
    }
  }  
  
close QUEUE;

Last edited by radoulov; 11-18-2008 at 01:00 PM..