Re: [Nagios-devel] Nagios 2.0 Event Broker and DB Support

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Nagios 2.0 Event Broker and DB Support

Post by Guest »

--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

> The service struct is an internal Nagios structure definition which=20
> changes between Nagios versions. If the user module is compiled for=20
> use with Nagios 2.0 and it's definition of the service struct, it=20
> will have problems if it is not recompiled for future versions of=20
> Nagios.
>=20
> Off the top of my head, I could overcome this by requiring that the=20
> user modules indicate (by calling a function) what version of Nagios=20
> they are compiled for. If they report anything but the current=20
> version (or do not report at all), unload them so they can do no=20
> harm.

I like the idea a lot, and I can see heaps of potential for some funky
dynamic monitoring stuff..

In the .h file which modules will #include, add this macro:

#define NAGIOS_API_VERSION(x) int __nagios_api_version =3D x;


Each module must insert (near the top) a nice simple line like:
NAGIOS_API_VERSION(3)


Then, when you dlopen() the module, use something like:

#define REQUIRED_API_VERSION 3
if (*((int *)dlsym(dlhandle, "__nagios_api_version")) !=3D REQUIRED_API_VER=
SION)
{
printf("Wrong module version... not loading\n");
return;
}

to get the version number before you call the init function. If the version
number is not exactly right, don't load the module. I think that will
work...

It might be nice in principal to allow multiple versions or some kind of
backward compatibility, but I doubt it's worth it, for the stability you
could potentially lose.

Just make sure that you increase the api version in the core code whenever
you change it, and it'll be sweet.


Also, on second thought, it might be worthwhile putting in some compiler
checking #ifdef blocks, so that an old version of a module won't compile
with the new headers..

--=20
Regards,
David Parrish
0410 586 121

--6TrnltStXW4iwmi0
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/LbjW3t7cw0+u5QwRAvRgAJ9CCxisSePWApsrevo0TpopiI+ZkgCfY1Xg
RtvX3awJXP2Qvnw7oopCFJo=
=Ukmy
-----END PGP SIGNATURE-----

--6TrnltStXW4iwmi0--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked