--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Net::Telnet();
+use Regexp::Common qw/net/;
+
+use Nagios::Plugin;
+
+my $macre = $RE{net}{MAC};
+my $ipre = $RE{net}{IPv4};
+
+use vars qw( $VERSION $PROGNAME $verbose $warn $critical $timeout $result );
+$VERSION = 1.0;
+
+use File::Basename;
+$PROGNAME = basename( $0 );
+
+my $p = Nagios::Plugin->new(
+ usage => "Usage: %s [-H <host>] [-t <timeout>]
+ [ -c|--critical=<critical threshold>]
+ [ -w|--warning=<warning threshold>]",
+ version => $VERSION,
+ blurb => "A plugin to check the number of hosts connected to the router",
+);
+
+$p->add_arg(
+ spec => 'warning|w=i',
+ help =>
+ qq{Number of hosts above which a warning state will be generated},
+);
+
+$p->add_arg(
+ spec => 'critical|c=i',
+ help =>
+ qq{Number of hosts above which critical state will be generated},
+);
+
+$p->add_arg(
+ spec => 'host|H=s',
+ help =>
+ qq{Host to connect to},
+);
+
+$p->getopts;
+
+unless( defined $p->opts->warning || defined $p->opts->critical ){
+ $p->nagios_die( " no threshold (warning/critical) arguments supplied" );
+}
+
+unless( defined $p->opts->host ){
+ $p->nagios_die( " no host was defined" );
+}
+
+my $timeout = defined( $p->opts->timeout ) ? $p->opts->timeout : 10;
+
+my $t = Net::Telnet->new( Timeout => $timeout );
+
+if( $p->opts->verbose ){
+ print "Printing entire conversation\n";
+ $t->input_log( *STDOUT );
+}
+$t->open( $p->opts->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 $rtn2 = " hostmgr list
+MAC-address IP-address Flags Type Intf Hw Intf Hostname
+----------- ---------- ----- ---- ---- ------- --------
+00:1d:68:ef:bf:86 192.168.1.254 CT Generic IP.Intf.LocalNetwork - localhost (null)
+00:02:b3:27:e3:53 - L Generic IP.Intf.LocalNetwork ETH.Phys.ethif2 Unknown-00:02:b3:27:e3:53 (null)
+00:1b:63:c1:0c:31 192.168.1.68 DL Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 bens-macbook (null)
+00:19:db:ca:9e:2a 192.168.1.72 CDL Generic IP.Intf.LocalNetwork ETH.Phys.ethif3 Emily (null)
+00:11:24:07:a1:6e - L Generic - - Unknown-00:11:24:07:a1:6e (null)
+00:21:e9:b7:38:a8 - L Generic - - Unknown-00:21:e9:b7:38:a8 (null)
+00:16:cb:c5:e2:51 - L Generic - - Unknown-00:16:cb:c5:e2:51 (null)
+00:0a:e4:8a:83:24 - L Generic - - Unknown-00:0a:e4:8a:83:24 (null)
+00:16:3e:fd:2c:d6 192.168.1.66 CDL Generic IP.Intf.LocalNetwork ETH.Phys.ethif2 Unknown-00:16:3e:fd:2c:d6 (null)
+38:e7:d8:03:67:0f - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Unknown-38:e7:d8:03:67:0f (null)
+90:27:e4:3a:1d:d0 - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Bens-iPhone-7 (null)
+00:10:b5:11:32:1a 192.168.1.171 CD Generic IP.Intf.LocalNetwork ETH.Phys.ethif2 Unknown-00:10:b5:11:32:1a (null)
+00:27:10:e9:8e:60 - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 BEAMnrc (null)
+58:55:ca:f3:e2:13 - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Unknown-58:55:ca:f3:e2:13 (null)
+e8:06:88:98:8a:8b - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Bens-iPad (null)
+f0:a2:25:12:d8:f4 - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Unknown-f0:a2:25:12:d8:f4 (null)
+00:21:e9:95:ef:fa - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Bens-iPhone (null)
+00:22:48:d3:2b:df - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Unknown-00:22:48:d3:2b:df (null)
+00:1c:b3:b5:42:58 - Generic IP.Intf.LocalNetwork ETH.Phys.wlif1 Macintosh-195 (null) ";
+
+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";
+ }
+}
+
+$p->nagios_exit(
+ return_code => $p->check_threshold( $activecount ),
+ message => "$activecount clients connected|clients=$activecount",
+);