Wednesday, 31 January 2018

Nagios Plugins: Can’t locate utils.pm in @INC



In nagios plugins written in perl, you got the following error while trying to use a nagios.


Can't locate utils.pm in @INC contains: /usr/local/nagios/libexec /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/lib64/nagios/plugins/check_clamav line 33.

Just install the nagios-plugins-perl package to fix the issue if the package is not installed.

[root@ linuxcnf ~]# yum install nagios-plugins-perl

Then it will be there:

[root@ linuxcnf ~]# find / -name "utils.pm" -type f
/usr/lib64/nagios/plugins/utils.pm

And if the issue still persists, due to a wrong defined library in Perl script. So, the solution of this problem is quite easy. Just change the defined library path as below in script:

use lib "/usr/local/nagios/libexec" ;

To

use lib "/usr/lib/nagios/plugins" ;

Now, it should works.

10 comments:

  1. Hi, what is the installation command for Debian/Ubuntu?

    ReplyDelete
  2. where should the change below be made?

    use lib "/usr/local/nagios/libexec" ;

    To

    use lib "/usr/lib/nagios/plugins" ;

    ReplyDelete
  3. You don't need to change something, just use the standard environment:
    PERL5LIB=/usr/lib/nagios/plugins check_clamav
    or whatever check_* script you want to use

    ReplyDelete
  4. Sorry, but utils.pm IS NOT part of this package.

    I cloned git repo: https://github.com/nagios-plugins/nagios-plugin-perl

    I made it and installed

    Obtaining this:

    # make install
    Manifying 8 pod documents
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/Config.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/Performance.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/Threshold.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/Getopt.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/Functions.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/ExitResult.pm
    Installing /usr/local/share/perl/5.28.1/Nagios/Monitoring/Plugin/Range.pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::Range.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::Functions.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::Threshold.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::Config.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::ExitResult.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::Getopt.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin.3pm
    Installing /usr/local/man/man3/Nagios::Monitoring::Plugin::Performance.3pm


    Exceuting the plugin i get

    Can't locate utils.pm in @INC (you may need to install the utils module) (@INC contains: /usr/lib/nagios/plugins /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at ./check_file_size line 29.

    Please not that in file list there is no track of utils.pm

    Or must I change something in @INC to add specifically the subdir?

    /usr/local/share/perl/5.28.1/Nagios/Monitoring/


    ReplyDelete