LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



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

Rep: Reputation: Disabled
Extend SNMP Agent to launch command with variable parameters


Hi,

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, 08:07 AM   #2
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,624
Blog Entries: 1

Rep: Reputation: Disabled
http://net-snmp.sourceforge.net/tuto...kit/index.html
 
Old 11-16-2012, 05:33 AM   #3
jdani
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Solved! I used SNMP Traps like this:
In the (Debian) server:

/etc/default/snmpd
Code:
# 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).
SNMPDRUN=no

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

# 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.
TRAPDRUN=yes

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

# create symlink on Debian legacy location to official RFC path
SNMPDCOMPAT=yes

/etc/snmp/snmptrapd.conf
Code:
authCommunity execute public

traphandle .1.3.6.1.4.1.2021.991.17 /root/FindMac.sh

/root/FindMac.sh
Code:
#!/bin/bash

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:
Code:
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".

Notes:
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 05:34 AM.
 
  


Reply


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 10:04 AM
snmp extend genderbender Linux - Software 0 03-22-2011 12:09 PM
Net-SNMP - Run a command as root with "extend" feature gimpy530 Linux - Software 0 07-13-2010 10:03 PM
Net-Snmp: Cannot extend agent to run script from configuration file skatersam0 Linux - Networking 2 06-30-2009 12:11 PM
BASH: run command with parameters from variable Roger Krowiak Programming 3 10-30-2007 04:27 AM


All times are GMT -5. The time now is 08:53 PM.

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