Skip to content

Instantly share code, notes, and snippets.

@jpawlowski
Last active December 17, 2015 05:49
Show Gist options
  • Save jpawlowski/5560897 to your computer and use it in GitHub Desktop.
Save jpawlowski/5560897 to your computer and use it in GitHub Desktop.
extend FHEM PRESENCE module for TomatoUSB access point compatibility
use Net::SNMP;
sub
snmpCheck($$)
{
my ($accesspoint,$client)= @_;
my $community = "public";
my $host = $accesspoint;
my $oid = ".1.3.6.1.4.1.2021.8.1.101.1";
my ( $session, $error ) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => 161,
-version => 2
);
if( !defined($session) ) {
return 0;
return "Can't connect to host $host.";
}
my $result = $session->get_request($oid);
die "request error: ".$session->error unless (defined $result);
$session->close;
print $result->{$oid}."\n";
my @devicelist = split / /, $result->{$oid};
foreach my $device (values @devicelist) {
return 1 if( $device eq $client )
}
return 0;
}
agentaddress udp:161
syslocation myhome
syscontact admin@localhost <admin@localhost>
rocommunity public
exec wlclientlist /opt/bin/wlclientlist
#!/bin/sh
echo "exec wlclientlist /opt/bin/wlclientlist" >> /etc/snmpd.conf
PID=`ps | grep snmpd | head -1 | cut -d " " -f2`
kill -SIGHUP $PID
#swapon /dev/sda1
modprobe ftdi_sio
modprobe pl2303
sleep 60
/opt/cs/scripts/start_oscam.sh start
/opt/bin/snmpd.sh
#!/bin/sh
wl assoclist |sed 's/assoclist //g' | tr "\n" " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment