Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 11-07-2012, 04:41 PM   #1
LQ Newbie
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
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??
Old 11-08-2012, 07:07 AM   #2
Senior Member
Registered: Jan 2011
Posts: 4,663
Blog Entries: 7

Rep: Reputation: 1107Reputation: 1107Reputation: 1107Reputation: 1107Reputation: 1107Reputation: 1107Reputation: 1107Reputation: 1107Reputation: 1107
Old 11-16-2012, 04:33 AM   #3
LQ Newbie
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
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.

Last edited by jdani; 11-16-2012 at 04:34 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to associate SNMP OID with specific parameter under SNMP agent? m4rtin Linux - Server 1 09-16-2011 09:04 AM
snmp extend genderbender Linux - Software 0 03-22-2011 11:09 AM
Net-SNMP - Run a command as root with "extend" feature gimpy530 Linux - Software 0 07-13-2010 09:03 PM
Net-Snmp: Cannot extend agent to run script from configuration file skatersam0 Linux - Networking 2 06-30-2009 11:11 AM
BASH: run command with parameters from variable Roger Krowiak Programming 3 10-30-2007 03:27 AM

All times are GMT -5. The time now is 11:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration