RE: Experimenta OIDs usage
"Robson, Alan" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <2228BF4A620F664B97F85AF2B5E7507CE933E3F8@wdc1exchmbxp02.hq.corp.viasat.com> |
I suggest that you at least read rfc 1155 and perhaps also rfc 2578.
The script that we used before can only pass back values of type: "one of the text strings: integer, gauge, counter, timeticks, ipaddress, objectid, or string"
The “simple” approach would be…
1) In your application, represent the float as a string (eg. print it using %f)
2) Fetch the string using the pass script method you used below, expressing the OID as numbers, eg. .1.3.6.1.3.55
3) Convert the string back into a float inside your application.
Here is an example pass script that does that…
#! /usr/bin/python -u
import sys
# OID is passed with a -g command line switch
OID = sys.argv[2].strip()
my_float = 1.23
if OID == ".1.3.6.1.3.55":
print OID + ".0"
print "string"
print "%f"%my_float
And the result when I fetch the value…
snmpwalk -v 1 -c public localhost .1.3.6.1.3.55
SNMPv2-SMI::experimental.55.0 = STRING: "1.230000"
Obviously that is not a very good approach. It is not efficient and it still leaves you using the experimental part of the OID tree,
The more complex approach (the “proper” approach) would be to write a MIB definition file like this one: http://www.mibsearch.com/vendors/RFC/download/RFC1155-SMI, obtain your own enterprise OID and write an agent to extend snmpd. This is obviously not easy, but it starts with writing a MIB definition file, do you have a list of items that you want to include in your MIB ?
Good luck
Alan
From: M.AMJAD [mailto:[email protected]]
Sent: Wednesday, May 21, 2014 1:08 AM
To: Robson, Alan; [email protected]
Subject: Re: Experimenta OIDs usage
Hello,
where can we define our own custom variables, eg int, float etc ? and where counter is defined, please,,, I want to declare my own variables so that I can attach data to that Variable latter,
waiting for your reply, please.
M.AMJAD
+92-345-9208119
[Image removed by sender. Please consider the environment before printing]
On Sunday, 18 May 2014, 22:21, M.AMJAD <[email protected]> wrote:
its work good now dear....
Thanks
M.AMJAD
+92-345-9208119
[Image removed by sender. Please consider the environment before printing]
On Wednesday, 14 May 2014, 19:48, "Robson, Alan" <[email protected]> wrote:
And I should add – are you using SELinux ? what does the command sestatus tell you ?
Alan
From: Robson, Alan [mailto:[email protected]]
Sent: Wednesday, May 14, 2014 7:44 AM
To: M.AMJAD; [email protected]
Subject: RE: Experimenta OIDs usage
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]<mailto:[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]<mailto:[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]<mailto:[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: 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