diff options
author | root <root@frank.tg14.gathering.org> | 2014-04-16 14:53:39 +0200 |
---|---|---|
committer | root <root@frank.tg14.gathering.org> | 2014-04-16 14:53:39 +0200 |
commit | 5285c3630744858393e79c8338b628f5fe546ea3 (patch) | |
tree | 1fc9646bcc1c32131cf22e63600f7ebd38b31ccc | |
parent | a6be668e6a0136466168f5728c6b7e8340270d0a (diff) |
munin clients logging plugin, logging ipv4 and ipv6 stats
-rwxr-xr-x | munin/clients_connected.pl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/munin/clients_connected.pl b/munin/clients_connected.pl new file mode 100755 index 0000000..5301c63 --- /dev/null +++ b/munin/clients_connected.pl @@ -0,0 +1,26 @@ +#! /usr/bin/perl -I/root/tgmanage/include +use strict; +use warnings; +use lib 'include'; +use nms; +use Data::Dumper::Simple; + +my $dbh = nms::db_connect(); +$dbh->{AutoCommit} = 0; + +my $active_clients = $dbh->prepare("select family(address), count(distinct(mac)) from seen_mac where family(address) in (6,4) and seen >= now() - INTERVAL '1 hour' group by family(address);") + or die "Can't prepare query: $!"; + +$active_clients->execute; +print <<EOF; +graph_title Clients seen the last hour +graph_vlabel count +graph_scale no +EOF +while (my $ref = $active_clients->fetchrow_hashref) { + print "clients_".$ref->{'family'}.".label v".$ref->{'family'}." clients\n"; + print "clients_".$ref->{'family'}.".value ".$ref->{'count'}."\n"; +} +$active_clients->finish; +$dbh->disconnect(); +exit 0 |