RE: Experimenta OIDs usage

"Robson, Alan" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <2228BF4A620F664B97F85AF2B5E7507CE9337718@wdc1exchmbxp02.hq.corp.viasat.com>
When you run the script from the command line it needs two arguments, like this…

/usr/local/bin/snmp_extender.py -g .1.3.6.1.3.55

When the snmp agent runs the script it will supply those arguments.

Alan

From: M.AMJAD [mailto:[email protected]]
Sent: Monday, May 12, 2014 10:16 PM
To: Robson, Alan; [email protected]
Subject: Re: Experimenta OIDs usage

Hello,,,
            i tried the procedure u told, but it generates the following error, can anybody resolve, please.

[amjid@localhost ~]$ /usr/local/bin/snmp_extender.py
Traceback (most recent call last):
  File "/usr/local/bin/snmp_extender.py", line 4, in <module>
    OID = sys.argv[2].strip()
IndexError: list index out of range



M.AMJAD
+92-345-9208119

On Friday, 9 May 2014, 21:45, "Robson, Alan" <[email protected]<mailto:[email protected]>> wrote:
This page: http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html#lbAZ<https://urldefense.proofpoint.com/v1/url?u=http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html%23lbAZ&k=OWT%2FB14AE7ysJN06F7d2nQ%3D%3D%0A&r=OzuJgNYWNrY%2F3yqABVDsLpgwbUfST3hTZUuwDEyrkFA%3D%0A&m=njqjmabrqkPEw4WY2xVXzr0fH6JSXb5P6MUH1cQ71%2F8%3D%0A&s=669e8058281502889968602a0e2c52c3061425753b6e78bbb1d25447f8fba0b3> describes how the snmp agent can be extended with a simple script.

Here is a very bad example of a script that I saved in the file /usr/local/bin/snmp_extender.py …

#! /usr/bin/python -u
import sys

# OID is passed with a -g command line switch
OID = sys.argv[2].strip()

if OID == ".1.3.6.1.3.55":
        print OID + ".0"
        print "counter"
        print 1234

The snmp agent will run the script whenever anything in the .1.3.6.1.3.55 subtree is fetched.

To tell the SNMP agent to run the script and to allow users to read that part of the MIB tree I added the following lines in snmpd.conf…

#
#  "Pass-through" MIB extension command
#
pass .1.3.6.1.3.55  /usr/local/bin/snmp_extender.py

and

###############################################################################
#
#  ACCESS CONTROL
#

                                                 #  system + hrSystem groups only
view   systemonly  included   .1.3.6.1.3.55


I tested my script by running it manually to simulate what the snmp agent will do when it gets a request…

alanr@pug:~$ /usr/local/bin/snmp_extender.py -g .1.3.6.1.3.55
.1.3.6.1.3.55.0
counter
1234

And then I restarted the snmp agent and tried it with snmpwalk…

alanr@pug:~$ snmpwalk -v 1 -O n -c public localhost .1.3.6.1.3.55
.1.3.6.1.3.55.0 = Counter32: 1234
End of MIB

And again without expressing the result numerically:

alanr@pug:~$ snmpwalk -v 1 -c public localhost .1.3.6.1.3.55
SNMPv2-SMI::experimental.55.0 = Counter32: 1234
End of MIB

Obviously the script is no good for anything other than an example. I hope it helps, I’m not sure you’re going in the right direction though.

Good luck

Alan


From: M.AMJAD [mailto:[email protected]]
Sent: Thursday, May 08, 2014 11:55 PM
To: [email protected]<mailto:[email protected]>
Subject: Experimenta OIDs usage

Hi,
    i am trying to use experimental , but how to use (add) a personal OID or another one, please.....
for example i want to use 1.3.6.1.3.55 , so how to add & use 55 accessible,

output is as follows,

[root@localhost amjid]# snmpwalk -v 1 -c public localhost 1.3.6.1.3
End of MIB
[root@localhost amjid]# snmpget -v 1 -c public localhost 1.3.6.1.3.55
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: SNMPv2-SMI::experimental


M.AMJAD
+92-345-9208119
[Image removed by sender. Please consider the environment before  printing]

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
image001.jpg (image/jpeg, 823 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.