Documentation
NAME
BB - Big Brother Module
SYNOPSYS
use BB;
bb_init(BBHOME => '/my/bb/home');
@status_change = &read_status_change_list([$server]);
%hist = read_hist("$my_server.$my_service");
@events_list = get_events_list( [ $my_server [, $my_service] ]);
%event = read_event_by_path(event => $my_event_with_path,
[all => 1,]
[raw => 1,]
);
%event = read_event(event => $my_event_with_path,
[all => 1,]
[raw => 1,]
[date => ,]
);
%ip = get_ips_by_names(@names);
%names = get_names_by_ips(@ips);
DESCRIPTION
This module define subroutines to access Big Brother data like events,
histlogs, bb-hosts...
I often use the same thing when I work on bb so I put all this stuff in
this module.
ROUTINES
bb_init
bb_init(HOME => '/my/bb/home',
VERSION => 'BB_VERSION');
This package is used to initialize all the paths used in this
module. If you use this module in a program called by bb you don't
need to call function.
All those paths are stored in the hash %ENV.
If you want to override paths defined by the module, you can define
them in the args of init like this:
bb_init(BBHOME => '/my/bb/home',
BBLOGS => '/an/other/path/to/log',
BBHIST => '/an/other/path/to/hist');
The defined keys are :
BBHOSTS the complete bb-hosts path
BBLOGS the complete logs directory path
BBHIST the complete hist directory path
BBHISTLOGS the complete histlogs directory path
BBTMP the complete tmp directory path
BBNOTES the complete notes directory path
If you've made a special installation of BB, you may have to set all
this key.
read_status_change_list
@status_change = &read_status_change_list([$server]);
This routine take no or one argument. if no argument is given it
returns the allevents history else it return the server log event.
It returns an array of hashes. This hashes contains an event.
The hash's keys are : server => the server name service => the
service end => the end time (in seconds from epoch) begin => the
start time (in seconds from epoch) laps => the laps (in seconds)
newcolor => the new color oldcolor => the color of the old event (or
« - » if there's no color) state => 1 if Recovered 2 if Escalation
and 0 if No change
The colors are: - re for red - ye for yellow - gr for green - cl for
clear - pu for purple
The resulting array is sorted by begin time.
read_hist
%hist = read_hist("$my_server.$my_service");
This routine returns the history hash for the given server/service.
The history hash is a hash of hash indexed on the timestamp (from
epoch). The references hashs are indexed on color, laps and date.
get_events_list
@events_list = get_events_list( [ $my_server [, $my_service] ]);
It take 2 args: - the first is the server name for which we want
last events or "" if we want all last events. - the second is the
service name we want or "" if we want all services.
CAUTION : You MUST set the first argument if you want to set the
second argument. For example:
@last_events_list = get_events_list("", $my_service);
This routines return the list of all filenames find in $BBLOGS.
read_event_by_path
%event = read_event_by_path(event => $my_event_with_path,
[all => 1,]
[raw => 1,]
);
This routine is called by read_event. It returns informations on the
given event or histlog
If called with (raw => 1) it just return a string with the text of
the event
else informations are stored in a hash which keys are: color => the
event's color date => the date in all letters message => the message
found on the first line
If called with (all => 1) it return in addition : text => all the
message text find in the event unchanged => the unchanged time as
find in the event text from => what ip sends this event
read_event
%event = read_event(event => $my_event_with_path,
[all => 1,]
[raw => 1,]
[date => ,]
);
It returns same information than read_event plus : expire => the
expiration time (in seconds from epoch) ctime => the creation time
(in seconds from epoch)
If called with [date => ,] it returns the event with this
timestamp
get_ips_by_names
%ip = get_ips_by_names(@names);
This take an array of server's names and return a hash where the
name is the one given and the IP is find in bb-hosts
get_names_by_ips
%names = get_names_by_ips(@ips);
This take an array of server's ip and return a hash where the ip is
the one given and the name is find in bb-hosts
EXAMPLES
1. Calc the percentage of each color for the couple server/service
soda.cpu:
use BB;
bb_init(HOME => "/usr/local/src/bb14h");
my %hist = read_hist("soda.cpu");
my (%color, $total);
for (keys %hist) {
$color{$hist{$_}{color}} += $hist{$_}{laps};
$total += $hist{$_}{laps};
}
for (keys %color) {
print "$_ -> " . $color{$_} / $total ."\n";
}
CHANGES
+ 30 Aug, 2000 Version 0.6
- No longer use a %BB_ENV hash. I directly use %ENV hash
BUGS
No known bugs for the moment but it's only in early stage so... If you
find one, report it to
THANKS
- Christian Perrier
COPYRIGHT
Copyright 2000, Nicolas Chuche
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
AVAILABILITY
The latest version of this module is likely to be available from:
http://www.teaser.fr/~nchuche/bb/
AUTHORS
Nicolas-Baptiste Chuche