Icinga - Nagios - check_esx3.pl fails while executing - perl

I'm trying to add an check_esx3.pl script to my icinga. But trying to execute the script
./check_esx3.pl
Gives me the following error:
Can't locate Nagios/Plugin.pm in #INC (#INC contains: /etc/perl
/usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
/usr/local/lib/site_perl .) at ./check_esx3.pl line 31. BEGIN
failed--compilation aborted at ./check_esx3.pl line 31.
I've been looking around and googling, but I've not been able to find any solution.

You need to install the Nagios::Plugin Perl module.

When you build the Nagios Plugins package from https://www.nagios-plugins.org, one of the configure options is --enable-perl-modules. It will build the Nagios::Plugin:* modules (since it has several modules included that need them), and install them to your system Perl library directory when you run 'make install' as root.
You can also go directly to the source and install the modules from CPAN, by running the command cpan Nagios::Plugins from the command line, also as root. You could possibly run these as the icinga or nagios user, but there's no guarantee they'll get installed into the proper places unless you've done some work beforehand to define PERL5LIB (which is way out of the scope of this answer) and done a bit of hackery in your startup scripts that define a special PERL5LIB for the icinga/nagios process on startup.

Related

Installing Perl Module in specified directory

I am trying to install one of the Perl module in my server (ubuntu droplet from Digital Ocean). I wanted this module to be installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/ directory which I have already created.
This is specific to one module. I don't want to install it in default path like /usr/bin/perl. I wanted it to be installed in above mentioned path.
Here are the list of commands which I executed to install the Email::Reply perl module.
Downloaded module from metacpan
tar xvfz Email-Reply-1.204.tar.gz
cd Email-Reply-1.204/
perl Makefile.PL PREFIX=/home/vinod/my_test_folder/perl_practice/scripts/lib/
su
<password_for_root>
make
make test
make install
When I execute make install command the following output got displayed on terminal screen
Manifying 1 pod document
Installing /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/Email/Reply.pm
Installing /home/vinod/my_test_folder/perl_practice/scripts/lib/man/man3/Email::Reply.3pm
Appending installation info to /home/vinod/my_test_folder/perl_practice/scripts/lib//lib/x86_64-linux-gnu/perl/5.26.1/perllocal.pod
And I could see the module got installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/Email/Reply.pm path, which is not right path which I mentioned in PREFIX=.
Strange thing here I wrote one small script which uses Email::Reply module by mentioning module path in shebang line
Code below:
#!/usr/bin/perl -I/home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/
use EMail::Reply;
print "Hi\n";
still its throws an error
Can't locate EMail/Reply.pm in #INC (you may need to install the EMail::Reply module) (#INC contains: /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/ /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at test.pl line 3.
BEGIN failed--compilation aborted at test.pl line 3.
I want this module to be installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/
How to achieve this. Please help me.
This is what local::lib can be used for, and cpanm supports it by default:
$ cpanm -l /home/vinod/my_test_folder/perl_practice/scripts Email::Reply
This will install it to /home/vinod/my_test_folder/perl_practice/scripts/lib/perl5.
Alternatively you can recreate the options local::lib sets for this case, the important one for this case is PERL_MM_OPT.
$ env PERL_MM_OPT='INSTALL_BASE=/home/vinod/my_test_folder/perl_practice/scripts' cpanm Email::Reply
Importantly, note that all of this is case sensitive, you must use Email::Reply;.

Can't locate [module] in #INC... but it's there

Context
I'm working in an offline environment, so no CPAN.
My goal is to utilize OAuth.pm
I manually installed Crypt::OpenSSL::RSA.
Problem
Can't locate Crypt/OpenSSL/RSA.pm in #INC (#INC contains: /usr/local/lib64/perl5 .)
#INC is truncated
I can see RSA.pm in /usr/local/lib64/perl5/Crypt/OpenSSL/... so I'm not sure how to troubleshoot this one.
This is after manually running make install
I assume you are trying to run the script OAuth.pl (?).. Then the module OAuth.pm is in the same directory as the script and you need to add the current directory to #INC for the script to see the module:
perl -I. OAuth.pl # I. --> add current directory to #INC
See Doesn't Perl include current directory in #INC by default? for more information.
Note: I tried to run the script but it still failed due to syntax errors. Here is a patch that seems to fix the errors.

CPAN on Ubuntu Can't locate local/lib.pm

I just set up an Ubuntu 16.04 box and am trying to get some Perl modules installed. I launched CPAN, and it went through the automatic config procedure. At the end it dumped a few questionable messages:
Couldn't untar local-lib-2.000019.tar: 'Cannot allocate memory'
'YAML' not installed, will not store persistent state
HAARG/local-lib-2.000019.tar.gz
Had problems unarchiving. Please build manually
Can't locate local/lib.pm in #INC (you may need to install the local::lib module) (#INC contains: /home/steve/perl5/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base /home/steve/waternow) at /usr/share/perl/5.22/CPAN/FirstTime.pm line 1347.
When I restarted it, it came up with the CPAN shell command line like nothing is wrong. Did it get configured correctly, or is there something else I need to do? I'm not a Lunix noob but not an expert either.
Also are there any better options for installing Perl modules on Ubuntu besides CPAN (for example like Activestate Perl Package Manager on Windows)? I've never been too fond of CPAN because of experiences like this.

Bugzilla 5.0 install on OpenShift - Can't locate parent.pm in #INC

Attempting to install Bugzilla on an OpenShift small gear. Using SSH to wget 5.0 tarball, untar-ing and running the checksetup.pl --check-modules script gives me this error:
Can't locate parent.pm in #INC (INC contains: . lib /var/openshift/[app-id]/app-root
/runtime/repo/libs /var/lib/openshift/[app-id]/perl/perl5lib/lib/perl5 /usr/local/lib64
/perl5 /usr/local/share/perl5 /usr/lib/lib64/perl5/vendor-perl /usr/share/perl5/vendor-perl
/usr/lib64/perl5 usr/share/perl5) at Bugzilla/Constants.pm line 14.
BEGIN failed--compilation aborted at Bugzilla/Constants.pm line 14.
Compilation failed in require at ./checksetup.pl line 27.
BEGIN failed--compilation aborted at ./checksetup.pl line 27.
Line 14 of Bugzilla/Constants.pm: `use parent qw(Exporter);`
Line 27 of ./checksetup.pl: `use Bugzilla::Constants;`
[app-id] in the paths is just a random string of hex digits used to identify an OpenShift application.
All help would be greatly appreciated. Thanks in advance!
That means either parent is not installed in your system or it's not a part of #INC.
Try perldoc -l parent to see if it's installed or not.
If it's installed then update PERL5LIB enviroment variable to add path to directory where module is installed.
If it's not installed then run cpan parent to install.
Also see:
How do I 'use' a Perl module in a directory not in #INC?
How to change #INC to find Perl modules in non-standard locations
Apparantly OpenShift has a cpan.txt file in the .openshift folder. Adding parent to that folder installed the required module.
#please install above packages:
[root#rsync ~]# yum install perl-parent -y

Cannot locate a perl module

I am trying to run a topology generation tool (http://informatique.umons.ac.be/networks/igen/) on linux where I need to install plenty of modules of perl.
For now, I have already installed CPAN. This tool requires a Statistics::Basic module which I also installed successfully.
However, after installing this module, the tool requires a package in this Statistics::Basic module. Here are the hints appeared in the command line:
Can't locate Statistics/Basic/CoVariance.pm in #INC (you may need to install the Statistics::Basic::CoVariance module) (#INC contains: /usr/local/share/perl/5.18.2/ /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .)
I get confused on this request since it is already included in the Statistics::Basic module. Even though I tried to install it independently, the cpan responded this:
cpan[1]> install Statistics::Basic::CoVariance
Warning: Cannot install Statistics::Basic::CoVariance, don't know what it is.
Does anyone know how to fix it? I am new to perl so I don't know how to make it work. Thx.
You need to replace the capital V with a small v in a couple of files and you need also some other modifications. You can find here a guide on how to make IGen-0.15 work again.