====== Monitor ====== ^ Author | [[ nathanh@manu.com.au | Nathan Hand ]] | ^ Compatibility | Xymon 4.2 | ^ Requirements | Perl, unix, smokeping | ^ Download | None | ^ Last Update | 2007-01-01 | ===== Description ===== This server/ext script walks the FPing targets from your existing Smokeping installation and alerts if the packet loss exceeds a threshold. It's similar in concept to the bbmrtg.pl script. ===== Installation ===== - Make sure your Xymon/BB hostnames and Smokeping hostnames are in agreement, eg. /usr/local/hobbit/server/etc/bb-hosts: 10.20.30.40 myrouter # conn /usr/local/smokeping/etc/config: ++ myrouter menu = myrouter title = This Is My Router host = 10.20.30.40 - Then drop this ext script into /usr/local/hobbit/server/ext and enable it in the launcher, eg add this to /usr/local/hobbit/server/etc/hobbitlaunch.cfg [bbsmokeping] ENVFILE /usr/local/hobbit/server/etc/hobbitserver.cfg NEEDS hobbitd CMD $BBHOME/ext/bbsmokeping.pl LOGFILE $BBSERVERLOGS/bbsmokeping.log INTERVAL 3m ===== Source ===== ==== bbsmokeping.pl ==== #!/usr/bin/perl # # bbsmokeping.pl: Check the packet loss of Smokeping targets and report when loss # exceeds thresholds. # # Author: Nathan Hand # Version: 1.0 # License: GPLv2 # # Make sure your Xymon/BB hostnames and Smokeping hostnames are in agreement, eg. # # /usr/local/hobbit/server/etc/bb-hosts: # 10.20.30.40 myrouter # conn # # /usr/local/smokeping/etc/config: # ++ myrouter # menu = myrouter # title = This Is My Router # host = 10.20.30.40 # # Then drop this ext script into /usr/local/hobbit/server/ext and enable it in the # launcher, eg add this to /usr/local/hobbit/server/etc/hobbitlaunch.cfg # # [bbsmokeping] # ENVFILE /usr/local/hobbit/server/etc/hobbitserver.cfg # NEEDS hobbitd # CMD $BBHOME/ext/bbsmokeping.pl # LOGFILE $BBSERVERLOGS/bbsmokeping.log # INTERVAL 3m # use strict; # Configure location of BB my $BB="/usr/local/hobbit/server/bin/bb"; my $BBDISP="1.2.3.4"; # Adjust the thresholds my $LOSSRED = 3; my $LOSSYELLOW = 1; # Adjust these paths and versions as necessary. use lib qw(/usr/perl5/site_perl/5.005/sun4-solaris/usr/include); use lib qw(/usr/local/rrdtool-1.0.40/lib/perl); use lib qw(/usr/local/smokeping-2.07/lib); # Define the full path to the Smokeping config file. my $SMOKEPINGCFG = '/usr/local/smokeping/etc/config'; # Define the full URL to the smokeping images. my $SMOKEPINGURL = 'https://1.2.3.4/.simg'; ################################## # Nothing to touch below this line ################################## use Smokeping; use Data::Dumper; my $date = localtime(); my $cfg = Smokeping::get_config(Smokeping::get_parser, $SMOKEPINGCFG); sub walktree($$$$); sub walktree($$$$) { my $cfg = shift; my $tree = shift; my $name = shift; my $target = shift; foreach my $prop (keys %{$tree}) { if (ref $tree->{$prop} eq 'HASH') { walktree $cfg, $tree->{$prop}, $name."/$prop", $target."/$prop"; } if ($prop eq 'host' and $tree->{probe} eq 'FPing') { my $last = RRDs::last("$name.rrd"); my ($start, $step, $names, $data) = RRDs::fetch "-s $last", "-e $last", "$name.rrd", 'AVERAGE'; if (@$names[1] eq 'loss') { my $loss = @{@$data[0]}[1]; if ($loss > $LOSSRED) { my $stats = <{menu} missing $loss FPing packets

exceeds threshold of $LOSSRED

ECHO system($BB, $BBDISP, "status $tree->{menu}.smoke red $date $stats"); } elsif ($loss > $LOSSYELLOW) { my $stats = <{menu} missing $loss FPing packets

exceeds threshold of $LOSSYELLOW

ECHO system($BB, $BBDISP, "status $tree->{menu}.smoke yellow $date $stats"); } else { my $stats = <{menu} missing $loss FPing packets

ECHO system($BB, $BBDISP, "status $tree->{menu}.smoke green $date $stats"); } } } } } walktree $cfg, $cfg->{Targets}, $cfg->{General}{datadir}, ""; ===== Known Bugs and Issues ===== No known bugs. ===== To Do ===== ===== Credits ===== ===== Changelog ===== * **2007-01-01** * Initial release