RE: Experimenta OIDs usage

"Robson, Alan" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <2228BF4A620F664B97F85AF2B5E7507CE93383DB@wdc1exchmbxp02.hq.corp.viasat.com>
Two questions…


1)      Did you add “Hello world this is testing” to the script ? It won’t work with net-snmp if you do because net-snmp is expecting a word like “counter” it is one of the basic snmp data types.

2)      Did you add the configuration to the snmpd.conf file before you restarted the agent ?, there are two places to add the config…

In the pass through section, the comment should already be in the file…




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





and farther up the file in the access control section, the comment should also already be in the snmpd.conf file (at least it was in mine)





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

                                                 #  system + hrSystem groups only
view   systemonly  included   .1.3.6.1.3.55






Alan


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

Thanks Alan,
                    it works with the -g switch, but when i restart the snmpd service and then tried snmpwalk, it produce the following out put (no data fetched ),,, can you help please.

[root@localhost snmp]# /usr/local/bin/snmp_extender.py -g .1.3.6.1.3.55
.1.3.6.1.3.55.0
Hello world this is testing...
1234
[root@localhost snmp]# snmpwalk -v 1 -O n -c public localhost .1.3.6.1.3.55
End of MIB

M.AMJAD
+92-345-9208119
[Image removed by sender. Please consider the environment before printing]
On Tuesday, 13 May 2014, 20:24, "Robson, Alan" <[email protected]> wrote:
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.