Tuesday, June 20, 2006

[MRTG] troubleshooting when using MRTG and snmpv3

I wanted to use MRTG(Multi Router Trafic Grapher) to check my server's resources of CPU,
DiskSpace and network trafic by using snmpv3 protocol, but I failed to setup it because
cfgmaker program didn't work fine even though snmp programs worked fine by using snmpv3.

I faced some problem and I found a workaround to use MRTG by using snmpv3 as follows.
Please let me know if you know other good idea or solutions.

[Programs I'm using]
net-snmp-5.3.0.1
mrtg-2.14.3

[Problem1]
When I compiled the net-snmp program, following error was displayed and stop compiling.
[Error]
/bin/sh ../libtool --mode=link gcc -g -O2 -Dlinux -I/usr/include/rpm -o snmpd snmpd.lo
libnetsnmpmibs.la libnetsnmpagent.la helpers/libnetsnmphelpers.la
../snmplib/libnetsnmp.la -ldl -lrpm -lrpmio -lpopt -lz -lcrypto -lmlibtool:
link: cannot find the library `/usr/lib/libbeecrypt.la' (librpmio.la: /usr/lib/libbeecrypt.la)
make[1]: *** [snmpd] Error 1
make[1]: Leaving directory `[your netsnmp installed directory]/net-snmp-5.3.0.1/agent'
make: *** [subdirs] Error 1

[Solution]
Refer to http://www.mail-archive.com/net-snmp-users@lists.sourceforge.net/msg08236.html.
System needed to install beecrypt-devel before installing net-snmp program.
If you are using Fedora core Linux System, you can install it by using yum as follows.
yum install beecrypt-devel

[Problem2]
When compiling the net-snmp following error was displayed and stop compiling.
[Error]
/usr/bin/ld: cannot find -lelf
collect2: ld returned 1 exit status
make[1]: *** [snmpd] Error 1
make[1]: Leaving directory `[your netsnmp installed directory]/net-snmp-5.3.0.1/agent'

[Solution]
Refer to http://www.net-snmp.org/docs/FAQ.html [On RedHat 8.0 or up I get "/usr/bin/ld: cannot find -lelf"?]
System worked fine after creating symbolic link "ln -s libelf.so.1 /usr/lib/libelf.so"

[Problem3]
When I was running cfgmaker to create a configuration file for MRTG,
cfgmaker program always failed even though all of parameters for snmpv3 were added.
documentation about cfgmaker: http://mrtg.mirror.graemef.net/doc/cfgmaker.en.html

[Error1]
SNMP V3 requires a --username parameter as part of the User Security Model for router
public@[IP Address] at [Installed Directory]/mrtg/bin/cfgmaker line 125.
(or I faced other error messages, but I forgot it.)

[Solution]
I tried following command.
added "--enable-snmpv3" parameter and --snmp-options.
":::::3" means snmp parameter and "3" means snmp version number.
Refer to http://mrtg.mirror.graemef.net/doc/cfgmaker.en.html about this parameter.

/bin/cfgmaker
--global "WorkDir: (MRTG Output Directory)"
--global "Options[_]: bits,growright"
--global "RunAsDaemon:Yes"
--global "Interval:5"
--output "(Configuration File Path)"
--enable-snmpv3 "(IP Address you want to access via snmpv3):(Port)::::3"
--username="(snmpv3 username)"
--authprotocol="md5"
--authpassword="(snmpv3 user password)"
--privprotocol="des"
--privpassword="(priv password)"
--contextengineid="(context engine ID)" --snmp-options "(IP Address):(Port)::::3"

[Error2]
After running the command described above, cfgmakeer failed and same error was occured,
I looked at cfgmaker source code.
I found enablesnmpv3 parameter in cfgmaker program, and system checked the value of
enablesnmpv3 whether it set to yes or not, but program never set this parameter
to "yes"(I think).
I changed the source code of cfgmaker program and I set the value of enablesnmpv3 to "yes"
in cfgmaker program like this.

82 if ($opt{'use-16bit'} == 1) {
83 warn "WARNING: Using 16bit RequestIDs\n";
84 $SNMP_Session::default_use_16bit_request_ids=1;
85 }
86 # Check for SNMP V3
87 #
88 $opt{enablesnmpv3} = "yes"; <--added manually here
89 if (lc($opt{enablesnmpv3}) eq "yes") {
90 if (eval {require Net_SNMP_util;}) {
........

And then, I run cfgmaker program, cfgmaker program works fine.