BBMAP : Hobbit Status Map

Since Hobbit is more and more used, Daniel J McDonald decides to make a small patch to BBMAP in order to enable BBMAP to run with Hobbit.

Here is what Daniel did. I thank him a lot! This is included in the Version V2.5 of BBMAP.

 

I've set up my hobbit installation to work with bbmap.

Changes:
Replace fullstatusreturn.sh with fullstatusreturn.pl in globalmap.php,
initiate.php and initiatesubmap.php

Add fullstatusreturn.pl as this script:


#!/usr/bin/perl -w
# @version $Id: fullstatusreturn.pl,v 1.0 Dan McDonald 22 Nov 2006
# @copyright 2006
# call : fullstatusreturn.pl hostname
# return global status (red,yellow,purple,blue,clear,green) as (1-6)
# follow by each service by status (1-6)
# default : global status = first from red,yellow,purple,blue,clear,green in this order
# change if needed

my %tests;
my %colors = (
        1       =>      'red',
        2       =>      'yellow',
        3       =>      'purple',
        4       =>      'blue'  ,
        5       =>      'clear' ,
        6       =>      'green' ,
);

if (exists($ARGV[0])) {
# mono hosts multi services
        my $host = $ARGV[0];
#       $host =~ s/\./,/g;
        open(STATUS, "bb localhost \"hobbitdboard host=$host fields=color,testname\" |");
        while (my $line=<STATUS>) {
                chomp $line;
                my ($color,$test)=split('\|',$line);
                push @{$tests{$color}}, $test;
        }
} else {
# multi hosts multi services

        open(STATUS, "bb localhost \"hobbitdboard fields=color,testname,hostname\" |");
        while (my $line=<STATUS>) {
                chomp $line;
                my ($color,$test,$hostname) = split('\|',$line);
                push @{$tests{$color}}, $hostname.$test;
        }
}
# status computed after returning the result

my $status;
my @statusreturn;
my $i = 0;
while  ($i++ < 6) {
        $status = $i if not defined($status) and exists($tests{$colors{$i}});
        push @statusreturn, join(" ",@{$tests{$colors{$i}}}) if exists($tests{$colors{$i}});
        push @statusreturn, '' if not exists($tests{$colors{$i}});
}

unshift @statusreturn,$status;
#echo $HOST ${status}:${redservice}:${yellowservice}:${purpleservice}:${blueservice}:${clearservice}:${greenservice} >> error_map_log.txt
print join(":",@statusreturn)."\n";


--
Daniel J McDonald, CCIE # 2495, CISSP # 78281, CNX
Austin Energy
http://www.austinenergy.com