#!/usr/bin/perl # # bb-pageinfo.pl # # A perl script which displays the current paging info for a BB display server # # Japheth Cleaver # http://www-rohan.sdsu.edu/~cleaver/software/ # # A heavily modified version of "bb-warnconfig.pl" v0.4, by # Author : Pierre Journel (journel@yahoo.com) # Web page : www.geocities.com/Paris/1070 # ######################################################################## # # INSTALL # # 1 - Put the script in your cgi-bin directory. # - rename to "bb-pageinfo.cgi" if desired # 2 - Modify the $BBHOME to reflect your setup. # 3 - Add the following hyperlink to one of your web pages: # http://your.web.server/cgi-bin/bb-pageinfo.pl(cgi) # # 4 - Click the link you just added! # ######################################################################## # # My changes # -Bug fixes # -Cleaner output/background # -Ignore most of bb-warnsetup.cfg, since I only care about the paging # -Add red background for negative rules # -Add separate tables for host and paging groups # # CHANGES (original) # # Version 0.4 - 15/05/00: # Added an embedded table to list the svcerrlist token in bbwarnstup.cfg. # # Version 0.3 - 11/05/00: # Links to host/service web page added in Services column. # Changed the name of the script from showrules.pl to bb-warnconfig.pl. # Added basic visualization of bbwarnsetup.cfg (not sure if more is needed). # Made it look more like a standard BB page (suggestion from Stephen Bates). # # Version 0.2 - 10/05/00: # First working version. # # Version 0.1 - 10/05/00: # Very early alpha version, not released ;-). # ######################################################################### ######################################################################### # # You SHOULD modify the following line to adjust it to your setup: # $BBHOME="/usr/home/bb/bb18"; $BBWEB="/bb"; $BBSKIN="/bb/gifs"; # ######################################################################### $BBWARNRULES = "$BBHOME/etc/bbwarnrules.cfg"; $BBWARNSETUP = "$BBHOME/etc/bbwarnsetup.cfg"; print ("Content-Type: text/html\n\n"); print qq! <\!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> Big Brother - Notification Rules and Setup
Get Big Brother
Contact Condensed view Report Help
help
Help

Big Brother - Notification Rules

  = DO NOT notify this recipient (reverse the rule)


!; # # Read bbwarnrules.cfg and discard all the lines beginning with a # # open(IN, $BBWARNRULES); while ($line = ) { $car = substr($line,0,1); if ($car ne "#") { push(@list, $line); } } close(IN); $delaytemp=`grep pagedelay: $BBWARNSETUP`; ($pagedelaydummy, $pagedelay) = split(/ /, $delaytemp); print ""; print ""; foreach $_ (@list) { @fields = split(/;/, $_); if ($#fields != 0) { $firstchar = substr($fields[0],0,1); if ($firstchar ne "!") { print ""; } else { print ""; $fields[0] = substr($fields[0],1); } $field_num = 0; foreach $str (@fields) { $field_num++; if ($str eq "") { print ""; } else { print ""; } } print ""; } } print "
Hosts monitored Hosts excluded Services Services excluded Days Time Recipients:delay-frequency
default frequency = $pagedelay min
(^ = Always notify after delay min,
~ = Notify if un-ack'd for delay min)
  "; @parts = split(/\s+/, $str); if (($field_num == 3) || ($field_num ==4)) { # # This is the Services or Services Excluded column # So we include the html link to the host/service page. # if ( (($fields[0] ne "notify-admin") && ($fields[0] ne "unmatched-*")) && ($str ne "*")) { foreach $part (@parts) { print qq! $part
!; } } else { # # Exception for the notify-admin and unmatched-* # special hostname # print $str; } } elsif ($field_num == 1) { # # This is the host name so we put it in bold # print "",$str,""; } elsif ($field_num == 5) { # # This is days-of-week, so change from numeric to abbreviation # foreach $part (@parts) { $part =~ y/135/MWF/; $part =~ s/0/Su/g; $part =~ s/2/Tu/g; $part =~ s/4/Th/g; $part =~ s/6/Sa/g; print "",$part,"
"; } } else { # # Rest of the column # foreach $part (@parts) { print "
",$part,"
"; } } print "

"; print ""; # # Read bbwarnsetup.cfg and discard all the lines beginning with a # # open(IN, $BBWARNSETUP); while ($line = ) { $car = substr($line,0,2); # print ""; if ($car eq "hg") { push(@host_setup, $line); } elsif ($car eq "pg") { push(@page_setup, $line); } } close(IN); print ""; foreach $myline (@host_setup) { ($hgname,$hgdata) = split(':', $myline); print ""; } print ""; foreach $myline (@page_setup) { ($pgname,$pgdata) = split(':', $myline); print ""; } print "
$line$car
Host Groups
"; print $hgname; print "   $hgdata

Paging Groups
"; print $pgname; print "   $pgdata



"; print "


"; # # Read bbwarnsetup.cfg and discard all the lines beginning with a # # open(IN, $BBWARNSETUP); while ($line = ) { $car = substr($line,0,1); if ($car ne "#") { push(@list_setup, $line); } } close(IN); print "- Generated by bb-warnconfig.pl Version 0.4 written by journel\@yahoo.com -
"; print "- Appreciably altered by cleaver\@rohan.sdsu.edu -"; print "
"; print ""; print "";