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;