From fefa87ebf2b2e001a18666e0eb160cb84282f5ba Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Tue, 29 Mar 2016 23:57:35 +0200 Subject: TG16-config. --- examples/tg16/munin/dhcp_usage_total_ipv6 | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 examples/tg16/munin/dhcp_usage_total_ipv6 (limited to 'examples/tg16/munin/dhcp_usage_total_ipv6') diff --git a/examples/tg16/munin/dhcp_usage_total_ipv6 b/examples/tg16/munin/dhcp_usage_total_ipv6 new file mode 100644 index 0000000..91e47fc --- /dev/null +++ b/examples/tg16/munin/dhcp_usage_total_ipv6 @@ -0,0 +1,74 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use POSIX; + +my $dhcpd_cmd="/usr/local/bin/dhcpd-pools"; +my $dhcpd_lf="/var/lib/dhcp/dhcpd6.leases"; +my $dhcpd_cf="/etc/dhcp/dhcpd6.conf"; + +my @output = `$dhcpd_cmd -c $dhcpd_cf -l $dhcpd_lf`; + +my $line; +my $max; +my $current; +my $percent; + +#Sum of all ranges: +#name max cur percent touch t+c t+c perc +#All networks 22776 6348 27.871 3973 10321 45.315 + + +my $count=0; + +for $line (@output) { + +$count=1 if ($line =~ /^Sum of all ranges:/); + +if ($count >= 1 and $count <= 3) { + + #print "DEBUG: $line\n"; + + if ($line =~ /\s+([\d]+)\s+([\d]+)\s+([\d]+\.[\d]+)/) { + $max=($1-$2); + $current=$2; + $percent=ceil($3); + + if (defined $ARGV[0] && $ARGV[0] eq "config") { + print_config(); + } else { + print "dhcp_lease_total_current.value $current\n"; + } + + } +$count++; + } + +} + +sub print_config { + +print <