0
votes

Hy! I try to write my own net-snmp MIB modules, but I have some problem... :) I read documents on www.net-snmp.org site. Steps I did:

  • I try to compile the NET-SNMP-EXAMPLES-MIB so.

1.) mib2c -c mib2c.scalar.conf netSnmpExampleScalars - Now I get a .c and a .h file, that I copied to ../agent/mibgroup directory

2.) I wrote a config script:

    ./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 \
    [email protected] \
    --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.) run ./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.) Run make command

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

Still I need edit the mib2c generated c file= Or I need use other .conf file? Also I don't know whether my configure script is correct or incorrect. What can I do with Leaving directory error ?

1
Looks like a syntax error in the generated c file. The compiler doesn't lie... =) Hard to tell what's going on here without seeing either the MIB file or the generated .c and .h files. - Jolta

1 Answers

0
votes

I guess you haven't edited the .c file generated by mib2c. mib2c tranform your mib in C code, but you have to edit the code to return value MIB data (or accept it when processing SETs). E.g. your mib is about health monitoring (heartbeat, ...). mib2c is going to generate everything of the C code, except what is going to return (considering snmp get request). Of course, mib2c doesn't know what should return. How will you read the heartbeats? You are going to read this information from a device, or from a text file or something else? So you need to fill this in the .c code, because mib2c let it blank and not going to compile.