簡體   English   中英

Net-snmp編寫MIB模塊

[英]Net-snmp writing a MIB module

我嘗試編寫自己的net-snmp MIB模塊,但遇到一些問題... :)我在www.net-snmp.org網站上閱讀文檔。 我執行的步驟:

  • 我嘗試這樣編譯NET-SNMP-EXAMPLES-MIB。

1.)mib2c -c mib2c.scalar.conf netSnmpExampleScalars-現在,我得到一個.c和.h文件,並將其復制到../agent/mibgroup目錄中

2.)我寫了一個配置腳本:

    ./configure \
    --with-ldflags="" \
    --with-cflags="-I/usr/src/net-snmp-5.4.4/agent/mibgroup" \
    --enable-mini-agent \
    --with-logfile="/var/log/snmpd.log" \
    --with-default-snmp-version=2 \
    --with-sys-contact=xxx@yyyy.com \
    --with-sys-location=HU/Sze \
    --disable-applications \
    --disable-debugging \
    --disable-manuals \
    --with-mib-modules="netSnmpExampleScalars" \
    --disable-scripts \
    --without-perl-modules \
    --disable-embedded-perl \
    --without-python-modules \
    --without-libwrap \
    --without-openssl \
    --without-rpm \
    --without-zlib

3.)運行./myconfig

  SNMP Versions Supported:    1 2c 3
  Building for:               linux
  Net-SNMP Version:           5.7.3
  Network transport support:  Callback Unix Alias TCP UDP IPv4Base SocketBase TCPBase UDPIPv4Base UDPBase
  SNMPv3 Security Modules:     usm
  Agent MIB code:            default_modules netSnmpExampleScalars =>  snmpv3mibs mibII/snmp_mib mibII/system_mib mibII/sysORTable mibII/vacm_vars mibII/vacm_conf
  MYSQL Trap Logging:         unavailable
  Embedded Perl support:      disabled
  SNMP Perl modules:          disabled
  SNMP Python modules:        disabled
  Crypto support from:
  Authentication support:     MD5
  Encryption support:
  Local DNSSEC validation:    disabled

4.)運行make命令

netSnmpExampleScalars.c: In function 'handle_netSnmpExampleInteger':
netSnmpExampleScalars.c:55:90: error: expected expression before ',' token
netSnmpExampleScalars.c:75:58: error: expected expression before ')' token
netSnmpExampleScalars.c:88:34: error: expected expression before ')' token
netSnmpExampleScalars.c:95:34: error: expected expression before ')' token 
netSnmpExampleScalars.c:103:34: error: expected expression before ')' token
netSnmpExampleScalars.c: In function 'handle_netSnmpExampleSleeper':
netSnmpExampleScalars.c:134:90: error: expected expression before ',' token
netSnmpExampleScalars.c:154:58: error: expected expression before ')' token
netSnmpExampleScalars.c:167:34: error: expected expression before ')' token
netSnmpExampleScalars.c:174:34: error: expected expression before ')' token
netSnmpExampleScalars.c:182:34: error: expected expression before ')' token
netSnmpExampleScalars.c: In function 'handle_netSnmpExampleString':
netSnmpExampleScalars.c:213:90: error: expected expression before ',' token
netSnmpExampleScalars.c:233:58: error: expected expression before ')' token
netSnmpExampleScalars.c:246:34: error: expected expression before ')' token
netSnmpExampleScalars.c:253:34: error: expected expression before ')' token
netSnmpExampleScalars.c:261:34: error: expected expression before ')' token
make[2]: *** [netSnmpExampleScalars.lo] Error 1
make[2]: Leaving directory `/usr/src/net-snmp-5.7.3/agent/mibgroup'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/usr/src/net-snmp-5.7.3/agent
make: *** [subdirs] Error 1

還是需要編輯mib2c生成的c file =還是需要使用其他.conf文件? 另外我也不知道我的配置腳本是正確還是不正確。 離開目錄錯誤怎么辦?

我想您尚未編輯mib2c生成的.c文件。 mib2c用C代碼轉換了mib,但您必須編輯代碼以返回值MIB數據(或在處理SET時接受​​它)。 例如,您的mib關於健康監控(心跳等)。 mib2c將生成所有C代碼,除了要返回的內容(考慮snmp get請求)。 當然,mib2c不知道應該返回什么。 您將如何閱讀心跳? 您將從設備,文本文件或其他內容讀取此信息? 因此,您需要在.c代碼中填寫此內容,因為mib2c使其為空白且不進行編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM