Re: Perl Nagios::Plugin vs Monitoring::Plugin

Florian Lohoff <[email protected]> Fri, 8 Sep 2017 15:16:20 +0200
Newsgroups gmane.network.nagios.devel,gmane.network.monitoring.plugins.devel
Organization rfc822 - pure communication
Message-ID <[email protected]>
--iFRdW5/EC4oqxDHL
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Sep 08, 2017 at 02:24:54PM +0200, Sven Nierlein wrote:
> Hi,
>=20
> you could use Module::Load (which is a perl core module) to do that:
>=20
> use Module::Load qw/load/;
> eval {
> =C2=A0 load Monitoring::Plugin, qw/required exports/;
> };
> if($@) {
> =C2=A0 load Nagios::Plugin, qw/required exports/;
> }

This fails for me - Testcase:

#!/usr/bin/perl -w

use strict;
use Getopt::Long;

use Module::Load qw/autoload/;
my $module=3D"Nagios::Plugin";
eval {
        require Nagios::Plugin;
        1;
} or do {
        $module=3D"Monitoring::Plugin";
};

autoload $module;
my $np=3Dnew $module;

$np->nagios_exit(UNKNOWN, "Unknown");

Returns:

Bareword "UNKNOWN" not allowed while "strict subs" in use at /tmp/f line 18.

$ERRORS{UNKNOWN} is equally not imported. Using qw/UNKNOWN/ with load or au=
toload does not
change anything.

> Or just stay with Nagios::Plugin till the old systems fade out. You can u=
se
> Monitoring::Plugin by the name "Nagios::Plugin" as well. It comes
> with a compatibility module.

The problem here is that Debian/Stretch does not seem to ship it -=20

flo@p3:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.1 (stretch)
Release:	9.1
Codename:	stretch
flo@p3:~$ dpkg -l libmonitoring-plugin-perl
Desired=3DUnknown/Install/Remove/Purge/Hold
| Status=3DNot/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig=
-pend
|/ Err?=3D(none)/Reinst-required (Status,Err: uppercase=3Dbad)
||/ Name                         Version             Architecture        De=
scription
+++-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
ii  libmonitoring-plugin-perl    0.39-1              all                 fa=
mily of perl modules to streamline writing Monitoring plugi
flo@p3:~$ perl -MNagios::Plugin=20
Can't locate Nagios/Plugin.pm in @INC (you may need to install the Nagios::=
Plugin module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/pe=
rl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24=
 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 =
/usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base).
BEGIN failed--compilation aborted.


Flo
--=20
Florian Lohoff                                                 [email protected]
             UTF-8 Test: The =F0=9F=90=88 ran after a =F0=9F=90=81, but the=
 =F0=9F=90=81 ran away

--iFRdW5/EC4oqxDHL
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

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

iQIVAwUBWbKYJJDdQSDLCfIvAQp06Q//TY/AQmPBaOGgbOUBEG2pkioGmiAXFYsA
wyfT2bB4uC9Xz99T7/UyV9ez4GcoMzUinWKUix2DeDxnlKhRCShu5EasIRtmGTDX
XvPDnsEkrdu7b6Edd/1ODwFGvvYAd8Ta9OuO/AdzJv4sh0jPr+RbXv8Sc47fnMVe
tYbeQFMf3/l5riWQ0S9J/BobRtuhzY/Gv+CN+TqxcxoPNMJmwP4BHLbx0/Qt1sBj
Wj704x39dBrkNuxwa6R3OQ3HFNxpXJwXkSssncB4vIE5PSHIK7ep2ApzgH/EIhm6
6Hp220mbRmOzJAnp+DpF3/dZnGJGZ4cUSmeR/VgkKHbGQ1DdKvHuR9Am43TyUzb3
S27f8koGY0HFfOgZ/91U+284MDhq04D/29nvh76Z3g44SX0KQfeAFlgVrHA14OSi
sYyXzBH2Z9B2sFLh/+4sCgrmbh9mrsouq7mXt5UmTBktbxaDoBsjqUJlAwzJ5snl
3qEvsLAnlzkmaaT/iwjzaSUAmho8Ixjb4inLVi1U1mDEV9L8uvTvXa+fQApzWB73
gjHD0GiU27xNAOidco7WE42ubwq7DWZ7UUWRTF+iRr9sQm1UHj74hwMoM4Ds0n6b
04lKPZCb7WZ0nlwOXEPOmePDFVHsntrXbNg8Y88D9hgX8GhxKis2sKBotyY3QHwV
uAI0F/xIUos=
=Df0T
-----END PGP SIGNATURE-----

--iFRdW5/EC4oqxDHL--