aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tg16/munin
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tg16/munin')
-rw-r--r--examples/tg16/munin/dhcp_usage80
-rw-r--r--examples/tg16/munin/dhcp_usage_ipv685
-rw-r--r--examples/tg16/munin/dhcp_usage_total78
-rw-r--r--examples/tg16/munin/dhcp_usage_total_ipv674
4 files changed, 317 insertions, 0 deletions
diff --git a/examples/tg16/munin/dhcp_usage b/examples/tg16/munin/dhcp_usage
new file mode 100644
index 0000000..f8d29a5
--- /dev/null
+++ b/examples/tg16/munin/dhcp_usage
@@ -0,0 +1,80 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use POSIX;
+
+my $dhcpd_cmd="/usr/local/bin/dhcpd-pools";
+my $dhcpd_lf="/var/lib/dhcp/dhcpd.leases";
+my $dhcpd_cf="/etc/dhcp/dhcpd.conf";
+
+my @output = `$dhcpd_cmd -c $dhcpd_cf -l $dhcpd_lf`;
+
+my $line;
+my $subnet;
+my $subnet2;
+
+for $line (@output) {
+
+ next if ($line =~ /^(shared net name|Ranges|name|Shared networks|Sum of all)/) or (length $line <= 1);
+
+ if ($line =~ /([\d]+\.[\d]+\.[\d]+\.[\d]+)\s+\-\s+([\d]+\.[\d]+\.[\d]+\.[\d]+)\s+([\d]+)\s+([\d]+)\s+([\d]+\.[\d]+)/) {
+
+ my $first_ip=$1;
+ my $last_ip=$2;
+ my $max=$3;
+ my $current=$4;
+ my $percent=ceil($5);
+
+ my $octet;
+ my @octets;
+
+ my $octet_count=0;
+ for $octet (@octets=(split('\.',$first_ip))) {
+ if ($octet_count == 3) {
+ $octet_count=0;
+ $subnet = $first_ip;
+ substr($subnet,-length($octet)) = ($octet-4);
+ $subnet =~ s/\./_/g;
+
+ if (defined $ARGV[0] && $ARGV[0] eq "config") {
+ print_config($subnet);
+ } else {
+ print "dhcp_pool_${subnet}.value $percent\n";
+ }
+
+ }
+
+ $octet_count++;
+
+ }
+
+ }
+
+}
+
+sub print_config {
+
+my $graph_name;
+
+$graph_name = shift;
+
+print <<EOF;
+graph_args --upper-limit 100 -l 0
+graph_title DHCP IPv4 Pools Status
+graph_vlabel %
+graph_category DHCP
+dhcp_pool_${graph_name}.label $graph_name
+EOF
+
+}
+
+# print_config;
+
+#shared net name first ip last ip max cur percent touch t+c t+c perc
+# All networks 88.92.0.4 - 88.92.0.62 59 26 44.068 2 28 47.458
+
+#}
+
+
+
diff --git a/examples/tg16/munin/dhcp_usage_ipv6 b/examples/tg16/munin/dhcp_usage_ipv6
new file mode 100644
index 0000000..920650d
--- /dev/null
+++ b/examples/tg16/munin/dhcp_usage_ipv6
@@ -0,0 +1,85 @@
+#!/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 $subnet;
+
+for $line (@output) {
+
+#All networks 2a06:5840:65::1000 - 2a06:5840:65::9999 35226 25 0.071 1 26 0.074
+#All networks 2a06:5840:66::1000 - 2a06:5840:66::9999 35226 44 0.125 0 44 0.125
+
+
+ next if ($line =~ /^(shared net name|Ranges|name|Shared networks|Sum of all)/) or (length $line <= 1);
+
+ if ($line =~ /([a-zA-Z0-9]+\:[a-zA-Z0-9]+\:[a-zA-Z0-9]+\::[a-zA-Z0-9]+)\s+\-\s([a-zA-Z0-9]+\:[a-zA-Z0-9]+\:[a-zA-Z0-9]+\::[a-zA-Z0-9]+)\s+([\d]+)\s+([\d]+)\s+([\d]+\.[\d]+)/) {
+
+ my $first_ip=$1;
+ my $last_ip=$2;
+ my $max=$3;
+ my $current=$4;
+ my $percent=ceil($5);
+
+ my $octet;
+ my @octets;
+
+ print "IP: $percent\n";
+
+ my $octet_count=0;
+ for $octet (@octets=(split('\::',$first_ip))) {
+ if ($octet_count == 2) {
+ $octet_count=0;
+ $subnet = $first_ip;
+ substr($subnet,-length($octet)) = ($octet-4);
+ $subnet =~ s/\./_/g;
+
+ if (defined $ARGV[0] && $ARGV[0] eq "config") {
+ print_config($subnet);
+ } else {
+ print "dhcp_pool_${subnet}.value $percent\n";
+ }
+
+ }
+
+ $octet_count++;
+
+ }
+
+ }
+
+}
+
+sub print_config {
+
+my $graph_name;
+
+$graph_name = shift;
+
+print <<EOF;
+graph_args --upper-limit 100 -l 0
+graph_title DHCP IPv4 Pools Status
+graph_vlabel %
+graph_category DHCP
+dhcp_pool_${graph_name}.label $graph_name
+EOF
+
+}
+
+# print_config;
+
+#shared net name first ip last ip max cur percent touch t+c t+c perc
+# All networks 88.92.0.4 - 88.92.0.62 59 26 44.068 2 28 47.458
+
+#}
+
+
+
diff --git a/examples/tg16/munin/dhcp_usage_total b/examples/tg16/munin/dhcp_usage_total
new file mode 100644
index 0000000..6abc9de
--- /dev/null
+++ b/examples/tg16/munin/dhcp_usage_total
@@ -0,0 +1,78 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use POSIX;
+
+my $dhcpd_cmd="/usr/local/bin/dhcpd-pools";
+my $dhcpd_lf="/var/lib/dhcp/dhcpd.leases";
+my $dhcpd_cf="/etc/dhcp/dhcpd.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";
+ print "dhcp_lease_total_current_max.value $max\n";
+ }
+
+ }
+$count++;
+ }
+
+}
+
+sub print_config {
+
+print <<EOF;
+graph_title DHCP Total leases
+graph_vlabel Total leases
+graph_category DHCP
+dhcp_lease_total_current.label Currently used IPv4 Leases
+dhcp_lease_total_current.min 0
+dhcp_lease_total_current.draw AREASTACK
+dhcp_lease_total_current_max.label IPv4 leases
+dhcp_lease_total_current_max.draw AREASTACK
+dhcp_lease_total_current_max.label Total available IPv4 Leases
+EOF
+
+}
+
+# print_config;
+
+#shared net name first ip last ip max cur percent touch t+c t+c perc
+# All networks 88.92.0.4 - 88.92.0.62 59 26 44.068 2 28 47.458
+
+#}
+
+#
+# dhcp_lease_total_current_max.colour #ff0000
+# dhcp_lease_total_current_max.label Totalt IPv4 Leases
+# dhcp_lease_total_current.colour #ff7000
+# pts.draw AREASTACK
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 <<EOF;
+graph_title DHCP Total leases
+graph_vlabel Total leases
+graph_category DHCP
+dhcp_lease_total_current.label Currently used IPv6 Leases
+dhcp_lease_total_current.min 0
+dhcp_lease_total_current.draw AREASTACK
+EOF
+
+}
+
+# print_config;
+
+#shared net name first ip last ip max cur percent touch t+c t+c perc
+# All networks 88.92.0.4 - 88.92.0.62 59 26 44.068 2 28 47.458
+
+#}
+
+#
+# dhcp_lease_total_current_max.colour #ff0000
+# dhcp_lease_total_current_max.label Totalt IPv4 Leases
+# dhcp_lease_total_current.colour #ff7000
+# pts.draw AREASTACK