Discussion:
strange dlopen() problem with ucd-snmp RPM
John P. Looney
2005-12-20 17:03:31 UTC
Permalink
This is a strange one.

I use ucd-snmp a lot here in work. I added three of my own patches to the
RPM (one fixes a simple problem with snmptable, the others are to add some
ID fields so we can tell that it's running our version of ucd-snmp).

I rebuilt it, and it would not load snmpd extensions - I usually have
something like:

dlmod antefacto /usr/share/snmp/modules/antefacto.so

in my snmpd config file. This failed with;

Apr 3 12:19:02 bartender ucd-snmp[492]: /etc/snmp/snmpd.conf: line 24: Warning: Unknown token: dlmod.

So, I investigated, and found that although this was printed by
configure:

....
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... yes
checking whether -lc should be explicitly linked in... no
....

config.h did not have DLOPEN defined;

[***@bartender ucd-snmp-4.2.3]# grep DL config.h |grep -v MIBS
#define HAVE_DLFCN_H 1
/* #undef HAVE_DLOPEN */
#define HAVE_LIBDL 1
/* #undef HAVE_NET_IF_DL_H */
#define HAVE_STDLIB_H 1

I was able to fix this by changing the SPEC file of ucd-snmp from;

--with-ldflags="%{rpmldflags}" \
to
--with-ldflags="-ldl %{rpmldflags}" \

Does anyone know why this could happen ? This change is not required on
RedHat at all. The configure script notes that dlopen does work, and needs
-ldl - but it does not show this in config.log.

John
--
_______________________________________
John Looney Chief Scientist
a n t e f a c t o t: +353 1 8586004
www.antefacto.com f: +353 1 8586014
Tomasz Kłoczko
2005-12-20 17:03:31 UTC
Permalink
Post by John P. Looney
This is a strange one.
I use ucd-snmp a lot here in work. I added three of my own patches to the
RPM (one fixes a simple problem with snmptable, the others are to add some
ID fields so we can tell that it's running our version of ucd-snmp).
I rebuilt it, and it would not load snmpd extensions - I usually have
dlmod antefacto /usr/share/snmp/modules/antefacto.so
in my snmpd config file. This failed with;
Apr 3 12:19:02 bartender ucd-snmp[492]: /etc/snmp/snmpd.conf: line 24: Warning: Unknown token: dlmod.
IIRC ucd-snmp ver 4.2.3 still does not support dynamicaly loadable
modules (IIRC finish this is listed in TODO file).
I dont remember anything from ucd-snmp dok about how to enable using
dynamically loadable modules. Do you know where it is described ?
Post by John P. Looney
So, I investigated, and found that although this was printed by
....
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... yes
checking whether -lc should be explicitly linked in... no
....
config.h did not have DLOPEN defined;
config.h is generated from config.h.in which is generated by autoheader.
You must regenerate config.h.in by run autoheader or if DLOPEN isnt't
defined in configure.in you must add this to acconfih.h and after this
run autoheader.
Post by John P. Looney
#define HAVE_DLFCN_H 1
/* #undef HAVE_DLOPEN */
As you see in HAVE_DLOPEN symbol comes with libtool.m4 .. so probaly
proper solution it will be patch this for change s/DLOPEN/HAVE_DLOPEN/.
Post by John P. Looney
#define HAVE_LIBDL 1
/* #undef HAVE_NET_IF_DL_H */
#define HAVE_STDLIB_H 1
I was able to fix this by changing the SPEC file of ucd-snmp from;
--with-ldflags="%{rpmldflags}" \
to
--with-ldflags="-ldl %{rpmldflags}" \
This probablu icorrect solution. Proper seems will be fix around
HAVE_DLOPEN.
Post by John P. Looney
Does anyone know why this could happen ? This change is not required on
RedHat at all. The configure script notes that dlopen does work, and needs
-ldl - but it does not show this in config.log.
Can you pack all files by "rpm -bs ucd-snmp.spec" and put generated
src.rpm somewhere on ftp/http ? (send me on priv URL if it is possible).

BTW. Do you know anything about other usefull modules for ucd-snmp ?
In current dist ucd-snmp is included ipfwchains/ipfwchains but as
statically linked module and source code seems not so freshen and not
functional [1]. If I will have woking example dynamically loaded modul
probably it will be possible modyfi this as dlopen() module.

[1] - I still cant use this for setup FW rules but partial view is
possible. Probaly it will need more work on extendig MIB file and rewrite
module code.

BTW2. Today I'm prepare mbrowse (simple MIB browser). It is now avalaible
on ftp. Also continue in SNMP subject also on ftp is avalaible gxsnmp
(partialy works) and SMI tools. Do you know anything about other SNMP
tools ? (except scotty)

kloczek
--
-----------------------------------------------------------
*Ludzie nie maj? problem?w, tylko sobie sami je stwarzaj?*
-----------------------------------------------------------
Tomasz K?oczko, sys adm @zie.pg.gda.pl|*e-mail: ***@rudy.mif.pg.gda.pl*
John P. Looney
2005-12-20 17:03:31 UTC
Permalink
Post by Tomasz Kłoczko
Post by John P. Looney
Apr 3 12:19:02 bartender ucd-snmp[492]: /etc/snmp/snmpd.conf: line 24: Warning: Unknown token: dlmod.
IIRC ucd-snmp ver 4.2.3 still does not support dynamicaly loadable
modules (IIRC finish this is listed in TODO file).
I dont remember anything from ucd-snmp dok about how to enable using
dynamically loadable modules. Do you know where it is described ?
No, they work fine. I've been using dynamically loaded modules since
4.1.0. Usually, as long as dlopen is found, they work.
Post by Tomasz Kłoczko
config.h is generated from config.h.in which is generated by autoheader.
You must regenerate config.h.in by run autoheader or if DLOPEN isnt't
defined in configure.in you must add this to acconfih.h and after this
run autoheader.
The rpm build process does do all that. It runs;

+ cd ucd-snmp-4.2.3
+ libtoolize --copy --force
You should add the contents of `/usr/share/aclocal/libtool.m4' to
`aclocal.m4'.
+ aclocal
+ autoheader
+ autoconf
+ ./configure LDFLAGS=-s ....
Post by Tomasz Kłoczko
Post by John P. Looney
#define HAVE_DLFCN_H 1
/* #undef HAVE_DLOPEN */
As you see in HAVE_DLOPEN symbol comes with libtool.m4 .. so probaly
proper solution it will be patch this for change s/DLOPEN/HAVE_DLOPEN/.
Are you sure ? This same SRPM on RedHat does detect dlopen() correctly,
and has

#define HAVE_DLOPEN 1

in it's config.h afterwards - though I had to do some changing to the spec, to
get it to configure, like;

[***@doozer SPECS]# diff ucd-snmp.spec ucd-snmp.spec.changed
2d1
< %include /usr/lib/rpm/macros.perl
50d48
< BuildRequires: libwrap-devel
53d50
< BuildRequires: popt-devel
59,60d55
< BuildRequires: rpm-perlprov >= 3.0.3-16
< BuildRequires: perl-devel >= 5.6.1
393,394d387
< --with-cflags="%{rpmcflags} -I%{_includedir}/rpm" \
< --with-ldflags="%{rpmldflags}" \
Post by Tomasz Kłoczko
Post by John P. Looney
Does anyone know why this could happen ? This change is not required on
RedHat at all. The configure script notes that dlopen does work, and needs
-ldl - but it does not show this in config.log.
Can you pack all files by "rpm -bs ucd-snmp.spec" and put generated
src.rpm somewhere on ftp/http ? (send me on priv URL if it is possible).
This is just the ucd-snmp-4.2.3-4.src.rpm downloaded from ftp.pld.org.pl
Post by Tomasz Kłoczko
BTW. Do you know anything about other usefull modules for ucd-snmp ?
Not really. We use snmp in a product we make (linux based load balancer),
so we have some extensions to let people configure ipvs & our monitoring
and notification software. That is all I use it for.
Post by Tomasz Kłoczko
BTW2. Today I'm prepare mbrowse (simple MIB browser). It is now avalaible
on ftp. Also continue in SNMP subject also on ftp is avalaible gxsnmp
(partialy works) and SMI tools. Do you know anything about other SNMP
tools ? (except scotty)
I was going to write a mib browser in PHP, but never got around to it. It
would be nice if you had a SNMP browser in PHP running on the server too,
so you didn't need an SNMP client.

There are very few good free tools for snmp, as people are willing to pay
for SNMP tools.

John
--
_______________________________________
John Looney Chief Scientist
a n t e f a c t o t: +353 1 8586004
www.antefacto.com f: +353 1 8586014
Tomasz Kłoczko
2005-12-20 17:03:31 UTC
Permalink
On Thu, 4 Apr 2002, John P. Looney wrote:
[..]
Post by John P. Looney
Post by Tomasz Kłoczko
Post by John P. Looney
#define HAVE_DLFCN_H 1
/* #undef HAVE_DLOPEN */
As you see in HAVE_DLOPEN symbol comes with libtool.m4 .. so probaly
proper solution it will be patch this for change s/DLOPEN/HAVE_DLOPEN/.
Are you sure ?
No. You are right this bug exist only in oure ucd-snmp and I'm wrkong on
fix this.

[/.\]
Post by John P. Looney
Post by Tomasz Kłoczko
BTW. Do you know anything about other usefull modules for ucd-snmp ?
Not really. We use snmp in a product we make (linux based load balancer),
so we have some extensions to let people configure ipvs & our monitoring
and notification software. That is all I use it for.
So probably it is not avalaible publicaly (?).
Post by John P. Looney
Post by Tomasz Kłoczko
BTW2. Today I'm prepare mbrowse (simple MIB browser). It is now avalaible
on ftp. Also continue in SNMP subject also on ftp is avalaible gxsnmp
(partialy works) and SMI tools. Do you know anything about other SNMP
tools ? (except scotty)
I was going to write a mib browser in PHP, but never got around to it. It
would be nice if you had a SNMP browser in PHP running on the server too,
so you didn't need an SNMP client.
There are very few good free tools for snmp, as people are willing to pay
for SNMP tools.
IMHO good base is gxsnmp for have good tool but it is in kind "development
freez" :> For examaple now only work storing configuration in SQL table
and exist only one mysql backend (postgresq even not compiles). Probaby it
will be better rewrite this part for manage configuration using libgda or
someting. Have something more similar to HP/OpenView it will be very good
think ;>

kloczek
--
-----------------------------------------------------------
*Ludzie nie maj? problem?w, tylko sobie sami je stwarzaj?*
-----------------------------------------------------------
Tomasz K?oczko, sys adm @zie.pg.gda.pl|*e-mail: ***@rudy.mif.pg.gda.pl*
Loading...