[질문] net-snmp5.1.1 , mib2c에 대한 궁금증

nidle의 이미지

안녕하세요 점점 공부할수록 궁금증만 커지는것같습니다
private mib를 사용할때 mib파일을 만들어서 net-snmp의 mib2c로 컴파일하면
.c 파일과 .h파일이 나오고 이것을 agent모듈에 추가 하면 된다고 알고있습니다
(아직해보지는 않고 몇몇 문서를 뒤서서,,,^^)

-- This object allows	a configuring system to	obtain a
	  -- unique value for diffServClassifierNumber for purposes of
	  -- configuration
 
	  diffServClassifierUnique OBJECT-TYPE
	      SYNTAX	   TestAndIncr
	      MAX-ACCESS   read-write
	      STATUS	   current
	      DESCRIPTION
		 "The diffServClassifierUnique object yields a unique
		 new value for diffServClassifierNumber	when read and
		 subsequently set. This	value must be tested for
		 uniqueness."
	      ::= { diffServObjects 1 }
 
	  -- The Classifier Table allows us to enumerate the
	  -- relationship between arbitrary classifiers	and
	  -- the meters	which apply to classified streams.
 
                            .
                            .
                            .

위와 같은 mib파일을 만드는 스크립트가 perl인가요? 위의 내용의 mib파일을 컴파일하면 그에 상응하는 정보를 모을수있는지 궁금합니다.제가 잘모르지만 언듯보기에 설명과 mib트리만드는정도의 정보만 있는것같아요(짧은 저의 생각)만약 그렇다면 따로 정보를 모으는 모듈을 언어로 만들어야되는지 궁금합니다.

File attachments: 
첨부파일 크기
Plain text icon make_test.txt24.32 KB
Plain text icon make_test2.txt12.19 KB
nidle의 이미지

이곳저고 돌아다니다 알게 되었습니다 mib형식이 ANS.1이라니.. perl이라고 물어봤던 저의 무지함을 아 ~~~~~이해해주세요
우선 제가 mib2c가 머하는녀석인지 몰랐던거 같습니다. mib파일을 c 템플릿파일로 변형하는 녀석이며 이 템플릿속에 필요한 내용을 코딩하여 agent녀석과 함께 컴파일해주면 되는거였습니다. (아무래도 설명이 이상한듯)저 mib파일에 정보를 모으는 부분이 있다고 생각한것이 실수였나봅니다.
그럼이만.. 혹시 제가 또 잘못생각하고 있다면 알려주세요 ^^

아 그런데 mib2c사용할때 perl 이 필요하다고 해서 분명히 설치했는데 이거 실행할때마다

ERROR: You don't have the SNMP perl module installed.  Please obtain
this by getting the latest source release of the net-snmp toolkit from
http://www.net-snmp.org/download/ .  Once you download the source and
unpack it, the perl module is contained in the perl/SNMP directory.
See the README file there for instructions.

이런글이 나오니 속상합니다.
mib2c안에
#!/usr/bin -w라고 써줬는데 왜글럴가요
wariua의 이미지

오류 메시지 대로 해주시면 되지 않을까요 :oops: 메시지에 나와 있듯 ~net-snmp/perl/SNMP/README 파일의 "Installation"절에 설치 방법이 나와있습니다.

MIB 파일의 형식(ASN.1)이나 mib2c의 사용 방법 등에 대해 말씀하신 내용은 제가 알고 있는 내용과도 일치합니다.
----
$PWD `date`

$PWD `date`

nidle의 이미지

매번 답변 감사히 보구 있습니다.
저의 너무도 미약한 영어 실력이 README파일을보아도 방법을 못찾다니 (흑흑) 대충

This module now relies on many other modules. Do not try to build
it independently, as it won't work. Instead of running "perl
Makefile.PL" in this directory, run it in the net-snmp/perl
directory instead which has a global makefile used to build all the
sub-modules in their proper order.
 
과
 
Unix:
 
cd net-snmp/perl
perl Makefile.PL [-NET-SNMP-CONFIG="sh ../../net-snmp-config"] [-NET-SNMP-IN-SOURCE=true]
make
make test
make install

이것을 보구 유추한결과 /net-snmp(압축푼곳)/perl이곳에서 위의 설명대로 하라고 하는것같은데 리눅스설명은 없어서 그냥 유닉스라고 된것을 해봤습니다. [-NET-SNMP-CONFIG="sh ../../net-snmp-config"] [-NET-SNMP-IN-SOURCE=true] 를 써주면 이상하게도 ../net-snmp-config파일을 못찾습니다.그래서 옵션없이 해주었는데 make test에서 오류가 발생합니다
make 할경우
 
Use of implicit split to @_ is deprecated at ./mib2c line 226.
Unquoted string "conf" may clash with future reserved word at ./mib2c line 528.
"my" variable $e masks earlier declaration in same scope at ./mib2c line 572.
Useless use of a variable in void context at ./mib2c line 52.
Useless use of a variable in void context at ./mib2c line 53.
Name "SNMP::use_long_names" used only once: possible typo at ./mib2c line 41.
Name "SNMP::use_enums" used only once: possible typo at ./mib2c line 42.
Name "SNMP::save_descriptions" used only once: possible typo at ./mib2c line 40.
Name "main::VAL" used only once: possible typo at ./mib2c line 69.
Name "main::emptyoutputs" used only once: possible typo at ./mib2c line 511.
Name "main::children" used only once: possible typo at ./mib2c line 796.
Name "main::accessToIsWritable" used only once: possible typo at ./mib2c line 101.
Name "main::VAR" used only once: possible typo at ./mib2c line 69.

make test는 넘 길어서 원본글에 파일로 업로드했습니다.

윗글에서 mib2c사용시 에러가 위에 더있더군요

Use of implicit split to @_ is deprecated at ./mib2c line 226.
Unquoted string "conf" may clash with future reserved word at ./mib2c line 528.
"my" variable $e masks earlier declaration in same scope at ./mib2c line 572.
Useless use of a variable in void context at ./mib2c line 52.
Useless use of a variable in void context at ./mib2c line 53.
Name "SNMP::use_long_names" used only once: possible typo at ./mib2c line 41.
Name "SNMP::use_enums" used only once: possible typo at ./mib2c line 42.
Name "SNMP::save_descriptions" used only once: possible typo at ./mib2c line 40.
Name "main::VAL" used only once: possible typo at ./mib2c line 69.
Name "main::emptyoutputs" used only once: possible typo at ./mib2c line 511.
Name "main::children" used only once: possible typo at ./mib2c line 796.
Name "main::accessToIsWritable" used only once: possible typo at ./mib2c line 101.
Name "main::VAR" used only once: possible typo at ./mib2c line 69.
 
ERROR: You don't have the SNMP perl module installed.  Please obtain
this by getting the latest source release of the net-snmp toolkit from
http://www.net-snmp.org/download/ .  Once you download the source and
unpack it, the perl module is contained in the perl/SNMP directory.
See the README file there for instructions.

이제는 물어보기도 죄송하네요 ^^ 저의 무지를 이해해주세요

wariua의 이미지

간단한 것부터 가 보자면...

1. mib2c를 실행할 때 잔뜩 나오는 경고 메시지

mib2c 스크립트는 아시다시피 펄 스크립트입니다. 모든 스크립트 파일이 그렇듯 스크립트 상단에 시스템이 스크립트를 실행하는 방법이 적혀 있습니다.

#!/usr/bin/perl
#!/usr/bin/perl -w
 
...

그런데 "/usr/bin/perl"로 실행하는 건 뭐고 "/usr/bin/perl -w"로 실행하는 건 뭘까요? "-w" 옵션의 정체를 알기 위해 "perl --help" 해보면 "-w" 옵션에 대해 "enable many useful warnings (RECOMMENDED)"라고 나옵니다. 유용하건 말건 추천을 하건 말건, 보기 싫으면 그만입니다. 아마도 mib2c 스크립트에서 첫 번째 행을 지우신 것 같은데, 첫 번째 행을 위와 같이 복원해 주시거나 "-w" 옵션을 빼 주시면 경고 메시지 없이 스크립트를 실행해 줍니다.

2. ../../net-snmp-config를 못 찾는다는 오류

뭐, 못 찾을 수도 있겠지요. README 파일에 나와 있듯 "-NET-SNMP-CONFIG" 옵션은 실수로 이미 설치되어 있는 다른 버전의 ucd-snmp/net-snmp의 헤더/라이브러리 파일을 사용하는 경우를 방지하기 위해 써 주는 것입니다. 이미 시스템에 snmp 라이브러리가 설치되어 있는 경우가 아니라면 써 주지 않으셔도 무방하며, 설치되어 있는 경우라면 경고 메시지가 한두 개 나오더라도 그냥 써 주시는 것이 안전합니다.

3. make test에서의 오류

오류의 핵심이 되는 부분을 살펴볼까요?

Quote:
Can't load '../blib/arch/auto/NetSNMP/default_store/default_store.so' for module NetSNMP::default_store: libnetsnmp.so.5:
동적 오브젝트 파일을 열 수없습니다 그런 파일이나 디렉토리가 없음 at /usr/lib/perl5/5.8.6/i386-linux-thread-multi/DynaLoader.pm line 230.
at test.pl line 71

동적 오브젝트 파일(내지는 동적 라이브러리)인 libnetsnmp.so.5 파일을 찾을 수 없다고 하는군요. README에 나와 있듯 SNMP 모듈을 설치하기 위해선 이미 net-snmp 패키지가 설치되어 있어야 합니다. 모듈을 만드는 과정에서 설치한 헤더/라이브러리 파일들을 사용하기 때문이지요.

예상으로는 아마도 configure 실행시 지정해 주신 (혹은 기본값이 쓰인) prefix 경로가 라이브러리 검색 경로에 포함되어 있지 않기 때문이리라 생각합니다. 가령 prefix를 "/home/myname/net-snmp"로 해 주셨다면 /home/myname/net-snmp/lib 디렉터리가 라이브러리 검색 경로에 포함되어 있어야 합니다. 환경 변수 LD_LIBRARY_PATH나 설정 파일 ld.so.conf를 통해 그 경로를 지정해 주시면 됩니다.
----
$PWD `date`

$PWD `date`

nidle의 이미지

많은것을 배워갑니다.
왜안되는지는 모르겠지만 계속하다보면 되겠죠 ^^
성공한다면 글올리겠습니다.

nidle의 이미지

wariua 말씀대로 진작에 했어야 했는데 .. ld.so.conf에 경로명을 넣어주었습니다 그냥 /usr/local/netsnmp/lib 그런데 안되더라구요
그래서 그냥 snmp를 다신 설치했습니다

./configure --prefix=/usr/local/netsnmp --with-perl-modules --enable-embedded-perl --enable-shared

임베디드 부분 넣으면 된다고 해서 그런데도 안되서 고민하다가
환경변수를 넣어주었더니 바로 되는군요.. 첨에는 LD_LIBRARY_PATH가 없어서 conf파일에 써준건데
점점할수록 더많은것을 배워야될거 같은 생각이 드네요,,

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.