-   Linux - Server (
-   -   Extend SNMP Agent to launch command with variable parameters (

jdani 11-07-2012 05:41 PM

Extend SNMP Agent to launch command with variable parameters

I'm trying to launch a command with variables arguments through SNMP, I think extending the SNMP Agent is best option, but I'm not quite sure...

The situation is this: I have to look for the AP a host (using as search criteria its mac) is connected, and every AP are in the same network. I think I could send an SNMP request to broadcast and wait for the AP with the host associated response... but I need to send the host mac in the SNMP request and use it in the command as argument. Is this possible??

Habitual 11-08-2012 08:07 AM

jdani 11-16-2012 05:33 AM

Solved! I used SNMP Traps like this:
In the (Debian) server:


# This file controls the activity of snmpd and snmptrapd

# Don't load any MIBs by default.
# You might comment this lines once you have the MIBs downloaded.
export MIBS=/usr/share/mibs

# snmpd control (yes means start daemon).

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-x -Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/'

# snmptrapd control (yes means start daemon).  As of net-snmp version
# 5.0, master agentx support must be enabled in snmpd before snmptrapd
# can be run.  See snmpd.conf(5) for how to do this.

# snmptrapd options (use syslog).
TRAPDOPTS='-On -Lsd -p /var/run/'

# create symlink on Debian legacy location to official RFC path


authCommunity execute public

traphandle . /root/



read host
read info
read OID
read otherInfo
read mac

echo $mac > /root/log.txt

The MAC will be stored at "/root/log.txt", now you only have to write the script to do what ever you need...

In the client:

snmptrap -v 2c -c public [SERVER_IP_OR_HOSTNAME] '' NOTIFICATION-TEST-MIB::demo-notif SNMPv2-MIB::sysLocation.0 s "aa:bb:cc:dd:ee:ff"
After launching this, the file "/root/log.txt" in the server will contain "aa:bb:cc:dd:ee:ff".

1. The OID and MIB I used in this example aren't the correct ones, but it's working for my testing purposes.
2. The security in this example is TOO POOR.
I have to change this to port it to production environment.

All times are GMT -5. The time now is 06:00 PM.