--- /dev/null
+The Debian Package munin-plugins-local
+----------------------------
+
+This package contains munin plugins for use on michaelhowe.org systems
+
+ -- Michael Howe <michael@michaelhowe.org> Sat, 17 Nov 2012 15:44:25 +0000
--- /dev/null
+munin-plugins-local (0.1) unstable; urgency=low
+
+ * Initial Release.
+ * Single plugin - snmp__networkclients
+
+ -- Michael Howe <michael@michaelhowe.org> Sat, 17 Nov 2012 15:44:25 +0000
--- /dev/null
+Source: munin-plugins-local
+Section: unknown
+Priority: extra
+Maintainer: Michael Howe <michael@michaelhowe.org>
+Build-Depends: debhelper (>= 8.0.0)
+Standards-Version: 3.9.3
+Homepage: <insert the upstream URL, if relevant>
+#Vcs-Git: git://git.debian.org/collab-maint/munin-plugins-local.git
+#Vcs-Browser: http://git.debian.org/?p=collab-maint/munin-plugins-local.git;a=summary
+
+Package: munin-plugins-local
+Architecture: all
+Depends: ${misc:Depends}
+Description: <insert up to 60 chars description>
+ <insert long description, indented with spaces>
--- /dev/null
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: munin-plugins-local
+Source: none
+
+Files: *
+Copyright: 2012 Michael Howe <michael@michaelhowe.org>
+License: GPL-3.0+
+
+Files: debian/*
+Copyright: 2012 Michael Howe <michael@michaelhowe.org>
+License: GPL-3.0+
+
+License: GPL-3.0+
+ 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 3 of the License, or
+ (at your option) any later version.
+ .
+ This package 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, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+ dh $@
--- /dev/null
+3.0 (native)
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+#
+# $HeadURL$
+# $LastChangedRevision$
+# $LastChangedDate$
+# $LastChangedBy$
+#
+
+# Not actually an SNMP plugin, but instead a horrible hack to pretend to be
+use Munin::Plugin;
+use Munin::Plugin::SNMP;
+use Net::Telnet();
+use Regexp::Common qw/net/;
+
+use Getopt::Long;
+
+=head1 NAME
+
+snmp__networkclients - Munin plugin to check the number of clients connected to the gateway
+
+=head1 APPLICABLE SYSTEMS
+
+Only O2-provided Thompson routers.
+
+=head1 CONFIGURATION
+
+None currently available
+
+=head1 MAGIC MARKERS
+
+#%# family=snmpauto
+#%# capabilities=snmpconf
+
+=head1 BUGS
+
+Uses a lot of code from the nagios plugin check_networkclients; this should
+ideally be combined as a module.
+
+=head1 AUTHORS
+
+Michael Howe
+
+=cut
+
+my $macre = $RE{net}{MAC};
+my $ipre = $RE{net}{IPv4};
+
+# All we care about is the host:
+my ( $host ) = Munin::Plugin::SNMP->config_session();
+#my $host = "192.168.1.254";
+
+my ( $verbose );
+GetOptions( "verbose" => \$verbose );
+my $timeout = 15;
+
+if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
+ exit 0;
+}
+
+if (defined $ARGV[0] and $ARGV[0] eq "config") {
+ print "host_name $host\n" unless $host eq 'localhost';
+ print <<"EOC";
+graph_title Number of devices
+graph_args --base 1000 -l 0
+graph_vlabel number of devices
+graph_scale no
+graph_category system
+graph_info This graph shows the number of devices currently connected to the system.
+users.label devices
+users.draw LINE2
+users.info Number of devices
+EOC
+ exit 0;
+}
+
+
+my $t = Net::Telnet->new( Timeout => $timeout );
+
+if( $verbose ){
+ print "Printing entire conversation\n";
+ $t->input_log( *STDOUT );
+}
+$t->open( $host );
+$t->waitfor('/Username :/');
+$t->print("SuperUser");
+$t->waitfor('/Password :/');
+$t->print( "O2Br0ad64nd" );
+
+$t->waitfor( '/{SuperUser}=>/' );
+$t->print( 'hostmgr list' );
+
+my ( $rtn ) = $t->waitfor( '/{SuperUser}=>/' );
+
+$t->close();
+
+my $activecount = 0;
+
+foreach my $line ( split( m{\n}s, $rtn ) ){
+ my( $mac, $ip, $flags ) = $line =~ m{^($macre)\s+(-|$ipre)\s+(\w+)\s+};
+ next unless( defined( $ip ) );
+ next if( $ip eq '-' );
+
+ if( $flags =~ m{C} ){
+ $activecount++;
+# print "Active host: $ip $mac\n";
+ }
+}
+
+print "hosts.value $activecount\n";