LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-20-2012, 03:15 AM   #1
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Rep: Reputation: 12
How to get oids form a mib file?


Hi,

I want to read all the objects form the mib file that a manager having ,I have developed one tool to get some data form a snmp enabled agent.I want to enhance that tool by showing all the oids form the manager mib file .I am using net-snmp library .

I saw the following

/usr/local/share/snmp/mibs/

folder and it having many mib files but how I can able to form a list of oid it having,I gone through the mibs and saw the structures but how to know the oids of each and every object mentioned in the mib files.I want to list all the oids as follows

SNMPv2-MIB::sysDescr.0 = .1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysObjectID.0 = .1.3.6.1.2.1.1.2.0

..... etc I want to scan all the mib files and to find out all the oid form that files. How to do this ?? kindly tell me ,any suggestion is highly appreciated.

Thanks
 
Old 09-21-2012, 01:05 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well as I understand the structure of them, very meticulously and painfully. As the oids are never listed explicitly, but built up layer by layer from nothing, you've got a pretty chunky task to piece it all together. I'd try to avoid needing to do this.
 
Old 09-21-2012, 01:56 PM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
I think you can use snmptranslate for what you're seeking. I'm no expert at snmp but had run across this command some months ago. On checking man page today I was able to do:

snmptranslate -Tz -m ./SNMPv2-MIB.txt

That gave output like:
"org" "1.3"
"dod" "1.3.6"
"internet" "1.3.6.1"
"directory" "1.3.6.1.1"
"mgmt" "1.3.6.1.2"
"mib-2" "1.3.6.1.2.1"
"system" "1.3.6.1.2.1.1"
"sysDescr" "1.3.6.1.2.1.1.1"
"sysObjectID" "1.3.6.1.2.1.1.2"
"sysUpTime" "1.3.6.1.2.1.1.3"
"sysContact" "1.3.6.1.2.1.1.4"
"sysName" "1.3.6.1.2.1.1.5"
"sysLocation" "1.3.6.1.2.1.1.6"
etc...

It shouldn't be too hard to use a for loop to act on all the MIBs and concatenate the information together in the format you requested. Something like the following:

Code:
for MIB in $(ls *MIB.txt)
do snmptranslate -Tz -m ./$MIB |awk -v MIB="$MIB" -F\" '{print MIB"::"$2" = "$4}'
done
NB: On my RHEL6 system the MIBs in /usr/share and named *MIB.txt. If yours are named differently you'd modify accordingly.
 
1 members found this post helpful.
Old 09-26-2012, 03:17 AM   #4
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Original Poster
Rep: Reputation: 12
Hi,MensaWater
Thanks for your reply.
 
Old 09-26-2012, 03:41 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
heh, OK so it was easy after all!
 
Old 09-26-2012, 06:20 AM   #6
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Original Poster
Rep: Reputation: 12
HI,acid_kewpie
It is easy if we use the tool other wise it is difficult but possible.
Thanks

Last edited by pradiptart; 09-26-2012 at 06:31 AM.
 
Old 01-29-2018, 09:08 AM   #7
rajanteotia008
LQ Newbie
 
Registered: Jan 2018
Location: Pune
Posts: 1

Rep: Reputation: Disabled
Smile Help

Hi pradiptart,
I'm also developing an application working on SNMP. I need your help to read the MIB files through java code and decode them to OIDs. Do let me know asap
 
Old 01-29-2018, 09:21 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,749

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by rajanteotia008 View Post
Hi pradiptart,
I'm also developing an application working on SNMP. I need your help to read the MIB files through java code and decode them to OIDs. Do let me know asap
Read the LQ Rules and the "Question Guidelines" link in my posting signature. You have re-opened a thread that had been closed for SIX YEARS, hijacked it with your own question, and are asking someone to personally contact you. None of these are good things.

Open your own thread for your own question. This is a community forum, so if you need a one-on-one programmer/consultant, it would be best if you HIRE ONE. Otherwise, provide details along with the code you've written so far, in your own thread, and we can try to help you with things.
 
Old 01-29-2018, 01:18 PM   #9
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
As noted, you have replied to a thread which has been inactive for six years. Please consider opening your own thread for you own problem, and include the details specific to you own situation, in order to attract the attention of current members with relevant knowledge.

Also, please review the Site FAQ for guidance in posting complete and well formed questions and general forum usage.
 
  


Reply



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 do you get snmpwalk to return numeric oids instead of MIB resolutions? jsurles Linux - Software 1 04-05-2011 07:52 PM
[SOLVED] snmp: where are the MIB files for OIDs reported through snmpd? eantoranz Linux - Server 1 03-22-2011 10:15 AM
How to write to a file from a form with perl, and not leave the form page. OldGaf Programming 3 11-12-2008 07:53 PM
How to add MIB's in snmpd.conf file manish_2479 Linux - Networking 0 07-09-2007 03:11 PM
I want Linux source code for FAT file system in user readable form not in binary form ramya272 Linux - Newbie 5 02-05-2004 07:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:05 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
Open Source Consulting | Domain Registration