Net-snmp and lmSensors (and Cacti)
by BenV on Sep.29, 2009, under Software
In order to get some disk and sensor stats I decided to recompile Net-SNMP on Xenbro. Since I did this before on my server at home (32 bit slackware-current) I figured it would be a breeze. Was I in for a surprise. Since I use quite a big configure string that slackbuild doesn’t handle yet I have it handy in a ‘bla’ file:
root@xenbro:/usr/src/net-snmp-5.5# cat bla
./configure --prefix=/usr --with-defaults --localstatedir=/var --sysconfdir=/etc --with-sys-contact="Jemoeder" --with-mib-modules="host disman/event-mib mibII/mta_sendmail smux ucd_snmp ucd-snmp/lmSensors ucd-snmp/diskio" --enable-shared --with-perl-modules="PREFIX=$PKG/usr INSTALLDIRS=vendor" --enable-embedded-perl --with-cflags="-O2" --with-libwrap --with-python-modules --with-ldflags=-lsensors --enable-ipv6 --disable-debugging --enable-static=no
However, when compiling like this both v5.5 and v5.4.2.1 of net-snmp gave me:
mkdir ucd-snmp/.libs
gcc -I../../include -I. -I../../agent -I../../agent/mibgroup -I../../snmplib -O2 -Ulinux -Dlinux=linux -I/usr/include/rpm -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/CORE -c ucd-snmp/lmSensors.c -fPIC -DPIC -o ucd-snmp/.libs/lmSensors.o
ucd-snmp/lmSensors.c: In function '_sensor_load':
ucd-snmp/lmSensors.c:943: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
ucd-snmp/lmSensors.c:943: error: 'data' undeclared (first use in this function)
ucd-snmp/lmSensors.c:943: error: (Each undeclared identifier is reported only once
ucd-snmp/lmSensors.c:943: error: for each function it appears in.)
ucd-snmp/lmSensors.c:964: warning: passing argument 1 of 'sensors_get_detected_chips' from incompatible pointer type
ucd-snmp/lmSensors.c:964: error: too few arguments to function 'sensors_get_detected_chips'
ucd-snmp/lmSensors.c:973: error: 'SENSORS_NO_MAPPING' undeclared (first use in this function)
ucd-snmp/lmSensors.c:974: error: incompatible type for argument 1 of 'sensors_get_label'
ucd-snmp/lmSensors.c:974: error: too many arguments to function 'sensors_get_label'
make[2]: *** [ucd-snmp/lmSensors.lo] Error 1
make[2]: Leaving directory `/usr/src/net-snmp-5.4.2.1/agent/mibgroup'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/usr/src/net-snmp-5.4.2.1/agent'
make: *** [subdirs] Error 1
Google was as useless as ever (only 1 thread about this who solved it installing some ancient version of lmsensors or something), so I had to dick around to get this to work.
First I wondered what was different about my server at home and Xenbro. 32 vs 64 bits obviously, but otherwise… not that much.
So I tried upgrading libtool from version 1.5 to 2.2.6a. Recompile wasted another 5 minutes of my life.
Then I read something about ucd-snmp/lmSensors vs ucd-snmp/lmsensorsMib. I have no idea what this is supposed to do, but I’d be better of not having read about it. Both options won’t compile because of the same compilation error above.
Finally after hours of cursing I installed lm_sensors 2.10 to /usr/local and hinted net-snmp to compile using -L/usr/local/lib, doing that made it it compile. You just have to push it a bit when it breaks… (and yes, I found out some older lm_sensors stuff was still lingering around on that home server). It kinda went like this:
# cd net-snmp-5.5/
# bash bla
# make
# cd agent/
# vim Makefile # change LD_FLAGS to include -L/usr/local/lib
# make
# cd ..
# make
# vim apps/Makefile # same edit as above
# make
Amazing enough it even works now. You’d expect it to crash and barf all over the place…. or at least I did.
Now finally back to what I wanted to do: SENSOR GRAPHS in Cacti!!!
A pretty much excellent description on how to do this is here: Eric A. Hall’s on Cacti and lmsensor readings.
His steps summarized:
- Get net-snmp to return sensor readings
- Download Cacti-netsnmp-lmsensors.tar.gz which I mirrored here: [Download not found]
- Untar, put files in right place, import templates in Cacti
- Add data queries and graphs to hosts
For more details check out his page, it has a detailed explanation. Thanks for building it Eric!
Then there’s disk stats. Half the links on the forums are hard to find or dead, so I’ll just take my own downloads. Easier for the next time I need it 😉
This is the original thread for snmpdiskio with the templates in here. Then there’s a missing download for a copy/paste version of this post. I’ll save the copy/pasting for you, just leech it if you need it (only for when your net-snmp fails!):
[Download not found]
Finally there’s a script that fetches the stuff here. Put that script in resource/snmp_queries/partition.xml
Import the two templates from the snmpdiskio-v0.9.4 tarball.
Next add the new snmp query (“Get Device I/O”) to your device (Devices -> $yourdevice -> at bottom select it from the pulldown menu). Create graphs for this device -> have fun.
I was going to add some images, but I’m too tired now. Hope you can get it to work, good luck 🙂
October 30th, 2009 on 18:15
Hi!
I’m trying to do exactly the same thing. Running Slackware 13 x86 and I get the same error as you do, but your instructions in the colored box are hard to understand for me.
I installed lm_sensors 2.10 on top of 3.1 for snmp to compile, but I don’t know get it how to force make file to use the old version.
Could you write a step for step how you did it, or maybe email me at rollese@gmail.com with instructions?
Thanks!
October 30th, 2009 on 20:24
The step for step is pretty much in the purple colored box.
“bash bla” is my way of running configure, so just do ./configure there. Getting it to use the old version is done by altering the LD_FLAGS option in the Makefiles to point to /usr/local (where you installed lm_sensors 2.10).
If you run into any problems please let me know, I’ll try to help, but I do need some more information as to where and how you get stuck 🙂
Good luck! 🙂
January 10th, 2010 on 23:30
found this after hitting the same problem, however the solution is relatively simple, so thought I’d add this here as you’re a bit earlier in google’s results and show up with a subject that’s exactly relevant to what lots of people will be doing (me included!)
lm_sensors 3.1.1, net-snmp-5.5, you probably want to have lm_sensors 2.xx cleaned off the system to ensure the new features get used (including the asus_atk0110 acpi ‘sensor’ that won’t be seen by earlier lm_sensors versions)
patch netsnmp with:
— agent/mibgroup/hardware/sensors.h~ 2009-04-24 08:04:28.000000000 +0100
+++ agent/mibgroup/hardware/sensors.h 2010-01-09 18:06:40.416619563 +0000
@@ -7,7 +7,7 @@
config_require(hardware/sensors/kstat_sensors)
# endif
#else
-config_require(hardware/sensors/lmsensors_v2)
+config_require(hardware/sensors/lmsensors_v3)
#endif
/* config_require(hardware/sensors/dummy_sensors) */
configure with:
–with-mib-modules=”ucd-snmp/lmsensorsMib”
don’t try to use the old ucd-snmp/lmSensors or even the above before you’ve applied the patch.
Compiles and works fine, sensors all available over snmp.
Solution from the net-snmp mailinglist here
http://www.mail-archive.com/net-snmp-users@lists.sourceforge.net/msg22781.html