[완료]net-snmp로 private MIB compile하기

bakdorazi의 이미지

안녕하세요.
net-snmp-5.3.3버젼을 깔았습니다

net-snmp tutorial대로 snmptranslate를 먼저했는데요.
http://www.net-snmp.org/tutorial/tutorial-5/commands/mib-options.html

일단 NEXCOMM-SMI-MIB.txt와 NEXCOMM-CONFIG-MIB.txt 2가지를 컴파일 하려고 했습니다.

1. 일단 NEXCOMM-SMI-MIB.my, NEXCOMM-COMFIG-MIB.my 를 /usr/local/share/snmp/mibs에 복사했습니다.

[root@localhost local]# snmptranslate -m +NEXCOMM-SMI -IR -On TCbootconfig
Unknown object identifier: TCbootconfig
[root@localhost local]# snmptranslate -m +NEXCOMM-SMI -IR -On n5000
.1.3.6.1.4.1.30000.1
[root@localhost local]# snmptranslate -m +NEXCOMM-SMI -IR -On nexcomm
.1.3.6.1.4.1.30000

[root@localhost local]# ./mib2c -c mib2c.scalar.conf n5000
writing to n5000.h
writing to n5000.c
running indent on n5000.c
running indent on n5000.h

[root@localhost local]# ./mib2c -c mib2c.scalar.conf nexn5000

You didn't give mib2c a valid OID to start with. IE, I could not find
any information about the mib node "nexn5000". This could be caused
because you supplied an incorrectly node, or by the MIB that you're
trying to generate code from isn't loaded. To make sure your mib is
loaded, run mib2c using this as an example:

env MIBS="+MY-PERSONAL-MIB" mib2c -c mib2c.scalar.conf nexn5000

You might wish to start by reading the MIB loading tutorial at:

http://www.net-snmp.org/tutorial-5/commands/mib-options.html

And making sure you can get snmptranslate to display information about
your MIB node. Once snmptranslate works, then come back and try mib2c
again.

[root@localhost local]# MIBS=./NEXCOMM-CONFIG-MIB.txt
[root@localhost local]# snmptranslate -m +NEXCOMM-CONFIG-MIB -IR -On config
No log handling enabled - turning on stderr logging
Cannot find module (NEXCOMM-CONFIG-MIB): At line 0 in (none)
Unknown object identifier: config
[root@localhost local]# snmptranslate -m +NEXCOMM-CONFIG-MIB -IR -On writeconfig
No log handling enabled - turning on stderr logging
Cannot find module (NEXCOMM-CONFIG-MIB): At line 0 in (none)
Unknown object identifier: writeconfig

제가 MIB을 같이 올리겠는데요. MIB을 보시면 아시겠지만 config, TCbootimage, writeconfig 같은 것은 MIB에 정의되어 있는 것입니다.
왜 snmptranslate를 했을 때 에러가 나는 지 모르겠구요...

두번째 위와 같이 snmptranslate를 해서 MIB파일의 identifier 하나 하나를 다 snmptranlate를 하고 그래서 OID를 얻고...그런 건 좋다 이거에요..근데 mib2c로 컴파일 할 때 snmptranslate로 OID를 얻어낸 거 아니면 mib2c 컴파일에도 실패하고 실제로 mib2c로 컴파일해서 얻어낸 *.c, *.h 파일에는 아무것도 없다는 거죠... 컴파일 해서 얻어낸 파일도 같이 올리겠습니다.
제가 찾아본 자료에 의하면 private MIB을 컴파일 할때 아래와 같이 하면 된다고 하더라구요..

=====================================================================================
net-snmp-5.1.2$ cd local

net-snmp-5.1.2$ mkdir joohong

net-snmp-5.1.2$ cp /home/ischl/JOOHONG-MIB.txt . (JOOHONG-MIB.txt가 /home/ischl/ 디렉토리에 존재한다고 가정)

net-snmp-5.1.2$ export MIBS=ALL (MIB 컴파일을 위한 환경 설정)

net-snmp-5.1.2$ MIBS=./JOOHONG-MIB.txt

net-snmp-5.1.2$ ./mib2c -c mib2c.scalar.conf joohongnet

위의 명령에서 joohongnet.c와 joohongnet.h가 생성되면 위에서 생성한 joohong 디렉토리에 복사한다.

그 후 joohong 디렉토리 전체를 ../agent/mibgroup/에 복사한다. (ex> cp -r joohong ../agent/mibgroup/.)

/agent/mibgroup/joohong 디렉토리에 있는 joohongnet.c 코드를 알맞게 수정한다.

다시 net-snmp-5.1.2의 처음으로 와서 환경설정을 해준다.

./configure --with-mib-modules="joohong/joohongnet"

net-snmp-5.1.2$ make; make test; make install

net-snmp-5.1.2$ cd agent

net-snmp-5.1.2$ make를 수행하여 snmpd를 생성한다.

net-snmp-5.1.2$ 해당 private MIB부분이 잘 동작하는지 테스트를 해보면 된다.

==========================================================================================
그러나 실제로 해보면 MIB파일 전체를 컴파일 할 수 없으며 MIB에 있는 identifier를 하나하나 분리해서 translate해서 하도록 되어 있어요..
저는 제가 뭘 잘못 알고 있는 지 다른 방법이 있는 지 궁금합니다.
그리고 위의 방법대로 하면 절대로 안되더군요..적어도 저는

그리고 mib2c를 컴파일 할 때 ./mib2c -c mib2c.scalar.conf "자기가 쓰고 싶은 파일명"이라고 알고 있는데 실제로 컴파일 할 때는 snmptranslate에서 성공한 MIB object identifier만 쓸 수 있더군요..
그건 왜 그런지 궁금합니다.

주절 주절 했는데 질문의 요지를 알아들을셨을 지 궁금하구요...
아시는 분 제발 답글 달아주세요...
저는 정말 모르겠거든요...

snmp를 설치한 경로는 /usr/local/src/net-snmp5.3.3 이며 mib2c 파일은 /usr/local/src/net-snmp5.3.3./local에 설치되어 있습니다.
mib2c 파일의 컴파일은 /usr/local/src/net-snmp5.3.3./local 에서 했습니다.

mib2c로 컴파일한 n5000.c 를 첨부하였는데 확장자가 .c 인 파일이 첨부가 안된다고 해서 .txt로 고쳤습니다.
그리고 리눅스는 페도라10 커널버젼 2.6.27.11 입니다.

File attachments: 
첨부파일 크기
Plain text icon n5000.txt410바이트
Plain text icon NEXCOMM-CONFIG-MIB.txt1.65 KB
Plain text icon NEXCOMM-SMI.txt3.67 KB
bakdorazi의 이미지

인터넷에서 찾은 것입니다.
아래분의 설명대로라면

1. net-snmp를 깝니다.
2. net-snmp의 default mib 디렉토리인 /usr/local/share/snmp/mibs에 자신의 private MIB을 복사해넣습니다.
저의 경우라면 위의 NEXCOMM-SMI.txt와 NEXCOMM-CONFIG-MIB.txt 일 것입니다.
3. # cd /usr/local/share/snmp/mibs
4. # snmptranslate -Tp -IR nexcomm <--nexcomm은 NEXCOMM-SMI.txt에서 맨 앞에 있는 MODULE-IDENTITY의 이름입니다.
5. # snmptranslate -IR nexcomm
6. # snmptranslate -IR nexcomm -On
7. # mib2c nexcomm

이렇게 하면 nexcomm.c, nexcomm.c~, nexcomm.h, nexcomm.h~ 파일이 만들어 집니다.
아랫분은 mib2c에서 에러가 난 모양이던데요...저는 잘 되었습니다.
여러분도 한 번 만들어 보세요.
저는 아랫분이 올리신 글을 참조했습니다.
http://www.mail-archive.com/net-snmp-coders@lists.sourceforge.net/msg08771.html

sam luo wrote:
> > > Dear all,
> > >
> > > I got some problems using mib2c. It seems the mib2c not work well on
> > > my FC5.
> > >
> > > I use net-snmp-5.3.1.tar.gz on FedoraCore5. My operation step by step is:
> > > (as root)
> > > 1. copy the net-snmp-5.3.1.tar.gz to /usr/local/src
> > > 2. tar zxvf net-snmp-5.3.1.tar.gz
> > > 3. cd net-snmp-5.3.1
> > > 4. ./configure (result is ok)
> > > 5. make (result is ok)
> > > 6. make install (result is ok)
> > > 7. cd perl
> > > 8. perl Makefile.PL (result is ok)
> > > 9. make (result is ok)
> > > 10. make install (result is ok)
> > >
> > > It seems the installation of net-snmp-5.3.1 is ok, then I add my own mib
> > > file.
> > > Here is the content of my mib file (OSEE-TEST-MIB.txt)
> > > --my mib file start
> > > OSEE-TEST-MIB DEFINITIONS ::= BEGIN
> > >
> > > IMPORTS
> > > DisplayString
> > > FROM SNMPv2-TC
> > > MODULE-IDENTITY, OBJECT-TYPE, enterprises
> > > FROM SNMPv2-SMI;
> > >
> > > --
> > > osee OBJECT IDENTIFIER ::= { enterprises 27290 }
> > > ustScalarSet OBJECT IDENTIFIER ::= { osee 1 }
> > > ustSSSimpleString OBJECT-TYPE
> > > SYNTAX OCTET STRING
> > > MAX-ACCESS read-write
> > > STATUS current
> > > DESCRIPTION
> > > "This is a simple test string."
> > > ::= { ustScalarSet 1 }
> > >
> > > ustSSSecondsSinceChanged OBJECT-TYPE
> > > SYNTAX OCTET STRING
> > > MAX-ACCESS read-only
> > > STATUS current
> > > DESCRIPTION
> > > "no use."
> > > ::= { ustScalarSet 2 }
> > >
> > > END
> > > --my mib file end
> > > I copy this file to /usr/local/share/snmp/mibs.Then I do the following
> > > opration:
> > >
> > > cd /usr/local/share/snmp/mibs
> > > export MIBS=all
> > >
> > > # snmptranslate -Tp -IR osee
> > > (the result is:)
> > > +--osee(27290)
> > > |
> > > +--ustScalarSet(1)
> > > |
> > > +-- -RW- String ustSSSimpleString(1)
> > > +-- -R-- String ustSSSecondsSinceChanged(2)
> > >
> > > # snmptranslate -IR ustScalarSet
> > > (the result is:)
> > > OSEE-TEST-MIB::ustScalarSet
> > >
> > > # snmptranslate -IR ustScalarSet -On
> > > .1.3.6.1.4.1.27290.1
> > >
> > > It seems snmptranslate work well, so I try to run mib2c to generate .c
> > > and .h files.
> > >
> > > #mib2c ustScalarSet

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.