3

I'm able to do a snmpget/snmpwalk and check_snmp through command line. But, when I do it through Nagios (creating a host & services entry in the config files), I see this error in the "Status Information" of the services under specific host:

External command error: /usr/local/bin/snmpget: error while loading shared libraries: libnetsnmp.so.20: cannot open shared object file: No such file or directory

OS: SLES 11

k1eran
  • 4,492
  • 8
  • 50
  • 73
Enigma
  • 71
  • 1
  • 2
  • 4

3 Answers3

9

The below procedure is helpful, if libnetsnmp.so.XX is in your system.

First search for library libnetsnmp.so.XX

sudo find / -name libnetsnmp.so*

So you will get output like below

/usr/lib/libnetsnmp.so.30
/usr/lib/libnetsnmp.so.15
/usr/lib/libnetsnmp.so.15.1.2
/usr/local/lib/libnetsnmp.so.30
/usr/local/lib/libnetsnmp.so
/usr/local/lib/libnetsnmp.so.30.0.2
/usr/local/lib/libnetsnmp.so.20
...

Now link that libnetsnmp.so.XX to /usr/lib/

sudo ln -s /usr/local/lib/libnetsnmp.so.XX /usr/lib/libnetsnmp.so.XX
gangadhars
  • 2,584
  • 7
  • 41
  • 68
0

The program misses a library. You can find a list of libraries the program needs using ldd:

$ ldd /usr/local/bin/snmpget

You will see not found near the libraries that are missing.

When you where located libraries that snmget needs, and that is a special location (not /usr/lib and so on), you can added to LD_LIBRARY_PATH:

 $ LD_LIBRARY_PATH=/usr/local/path-to/lib ldd /usr/local/bin/snmpget
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
  • ldd /usr/local/bin/snmpget linux-vdso.so.1 => (0x00007fffc33ff000) libnetsnmp.so.20 => /usr/local/lib/libnetsnmp.so.20 (0x00007fefca658000) libm.so.6 => /lib64/libm.so.6 (0x00007fefca402000) libc.so.6 => /lib64/libc.so.6 (0x00007fefca0a4000) /lib64/ld-linux-x86-64.so.2 (0x00007fefca929000) – Enigma Jul 10 '12 at 09:30
  • There ain't any missing lib ! – Enigma Jul 10 '12 at 09:30
  • I have already set LD_LIBRARY_PATH to /usr/local/lib, where all the libraries are. Still not working ! – Enigma Jul 10 '12 at 09:39
  • may be `libnetsnmp.so.20` is a 32bit library. please check it using `file` command. just run `file /path/to/lib.so` – Igor Chubin Jul 10 '12 at 09:39
  • no, when ldd finds all dependency, LD_LIBRARY_PATH will not help you of course. – Igor Chubin Jul 10 '12 at 09:40
  • This is what I get: /usr/local/lib/libnetsnmp.so.20.0.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped It is a 64bit lib only – Enigma Jul 10 '12 at 09:45
  • can you please install `ltrace` and run `ltrace /usr/local/bin/snmpget` and see what happens? – Igor Chubin Jul 10 '12 at 09:47
  • This is what I get at the end... fwrite(" -C APPOPTS\t\tSet various applic"..., 1, 59, 0x7f5d6d51d860 -C APPOPTS Set various application specific behaviours: ) = 59 fwrite("\t\t\t f: do not fix errors and r"..., 1, 49, 0x7f5d6d51d860 f: do not fix errors and retry the request ) = 49 exit(1 +++ exited (status 1) +++ – Enigma Jul 10 '12 at 10:38
0

Even if you add the library path to the environment variable LD_LIBRARY_PATH, your programe cann't figure out the location of desired libraries as they are not yet exported. you can think of it as you draw a map to trace something, and forget to put the map into your bag, so when you begin searching, you don't know where the goddamn thing is located. The clue is to export them (locations). How ? simply, using the keyword export before any changes of the environment variable, like : export LD_LIBRARY_PATH=/your/libraries/location/:$LD_LIBRARY_PATH

and that's it ;-)

Cheers