diff options
author | Tobi Oetiker <tobi@oetiker.ch> | 2009-01-05 18:25:57 +0100 |
---|---|---|
committer | Tobi Oetiker <tobi@oetiker.ch> | 2009-01-05 18:25:57 +0100 |
commit | efdba627ad20b396b7c9ce080200ee62bd066f84 (patch) | |
tree | 6d74420a5a5fed194c39d07b22d4d1d6c68279b2 /bin | |
parent | 64ad4077fc99a8476a27ad61c243db1077300286 (diff) | |
download | smokeping-efdba627ad20b396b7c9ce080200ee62bd066f84.tar.gz smokeping-efdba627ad20b396b7c9ce080200ee62bd066f84.tar.xz |
initial checkin
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/smokeinfo | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/bin/smokeinfo b/bin/smokeinfo new file mode 100755 index 0000000..a143abc --- /dev/null +++ b/bin/smokeinfo @@ -0,0 +1,115 @@ +#!/usr/bin/perl -w +use strict; + +use lib qw(/usr/pack/rrdtool-1.3.2-to/lib/perl); +use FindBin; +use lib "$FindBin::Bin/../lib"; +use Smokeping::Info; +use Getopt::Long 2.25 qw(:config no_ignore_case); +use Pod::Usage 1.14; + +'$Revision: 3879 $ ' =~ /Revision: (\S*)/; +my $Revision = $1; + +sub main() +{ + # parse options + my %opt = (mode=>'plain',pattern=>undef,separator=>';',format=>'%le'); + + GetOptions(\%opt, 'help|h', 'man', 'version', 'noaction|no-action|n', + 'start=s','end=s','pattern=s','mode=s','separator=s','format=s') or exit(1); + if($opt{help}) { pod2usage(1) } + if($opt{man}) { pod2usage(-exitstatus => 0, -verbose => 2) } + if($opt{version}) { print "smokeinfo $Revision\n"; exit(0) } + if($opt{noaction}) { die "ERROR: don't know how to \"no-action\".\n" } + my $config = shift @ARGV; + + my $si = Smokeping::Info->new($config); + my $nodes = $si->fetch_nodes(pattern=>$opt{pattern},mode=>$opt{mode}); + my @rows = qw(med_avg med_min med_max med_now loss_avg loss_max loss_now); + print '# ',join $opt{separator}, 'node_path',@rows; + print "\n"; + for my $node (@$nodes) { + my $data = $si->stat_node($node,'end-24h','now'); + print join $opt{separator},$node->{path},map {sprintf($opt{format},$data->{$_})} @rows; + print "\n"; + } +} + +main; + +__END__ + +=head1 NAME + +smokeinfo - poll smokeping site for numeric information + +=head1 SYNOPSIS + +B<smokeinfo> path/to/config.cfg [I<options>] + + --start x rrd graph start time + + --end y rrd graph end time + + --filter filter_pattern search pattern for node selection + + --mode plain (default) how to use the pattern + - plain + - recursive + - regexp + + --separator ; (default) + + --format %le (default) + + --man show man-page and exit + -h, --help display this help and exit + --version output version information and exit + +=head1 DESCRIPTION + +SmokeInfo is a simple frontend to the L<Smokeping::Info> module. It provides +access to numeric data stored in the rrd files. + +=head1 COPYRIGHT + +Copyright (c) 2009 by OETIKER+PARTNER AG. All rights reserved. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +=head1 AUTHOR + +S<Tobi Oetiker E<lt>tobi@oetiker.chE<gt>> + +=head1 HISTORY + + 2009-01-05 to Initial Version + +=cut + +# Emacs Configuration +# +# Local Variables: +# mode: cperl +# eval: (cperl-set-style "PerlStyle") +# mode: flyspell +# mode: flyspell-prog +# End: +# +# vi: sw=4 et + |