Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't locate object method "new" via package "Monitoring::Plugin" #147

Closed
tloubaresse opened this issue Sep 2, 2016 · 12 comments
Closed
Labels

Comments

@tloubaresse
Copy link

Hi,

I just downloaded this plugin in order to link it with Eyes of network 4.2 (Nagios Core 3.5.1).

I encountered a few problems concerning libs and such but got it fixed. Now the problem seems like perl don't find the package Monitoring::Plugin which is strange because the use Monitoring::Plugin at the beginning of the check_raid.pl which is supposed to verify it, right? Or it would cancel the script if not found.

I'm just only beginning with perl so please correct me if I'm talking nonsense.

Anyway, I just had to modify the following lines of the check_raid.pl in order to get it to start :

!/usr/bin/perl

use lib '/home/nagios/nagios-plugin-check_raid-master/lib/App';
use Monitoring::Plugin@0.37;
use Monitoring::Plugin::CheckRaid;
use Monitoring::Plugin::CheckRaid::Sudoers;
use Monitoring::Plugin::CheckRaid::Plugin;
use Monitoring::Plugin::CheckRaid::Utils;

It is now starting but I got the following error :

./check_raid.pl -S

Subroutine program_names redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 37.
Subroutine commands redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 42.
Subroutine sudo redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 49.
Subroutine new redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 54.
Subroutine active redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 99.
Subroutine status redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 112.
Subroutine set_critical_as_warning redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 121.
Subroutine warning redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 127.
Subroutine critical redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 135.
Subroutine unknown redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 143.
Subroutine ok redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 150.
Subroutine resync redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 158.
Subroutine check_status redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 166.
Subroutine spare redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 174.
Subroutine bbulearn redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 182.
Subroutine cache_fail redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 190.
Subroutine bbu_monitoring redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 197.
Subroutine message redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 207.
Subroutine perfdata redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 217.
Subroutine longoutput redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 227.
Subroutine join_status redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 243.
Subroutine valid redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 261.
Subroutine format_bytes redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 276.
Subroutine nosudo_cmd redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 296.
Subroutine cmd redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Plugin.pm line 318.
Subroutine which redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Utils.pm line 26.
Subroutine find_sudo redefined at /home/nagios/nagios-plugin-check_raid-master/lib/App/Monitoring/Plugin/CheckRaid/Utils.pm line 36.
Can't locate object method "new" via package "Monitoring::Plugin" (perhaps you forgot to load "Monitoring::Plugin"?) at ./check_raid.pl line 16.

Line 16 corresponding to these :

my $mp = Monitoring::Plugin->new(
usage =>
"Usage: %s [-h] [-V] [-S] [list of devices to ignore]",

    version => $VERSION,
    blurb => join($/,
            "This plugin checks all RAID volumes (hardware and software) that can be identified",
            "",
            "Homepage: $URL",
            "Reporting Bugs: $BUGS_URL",
    ),

    plugin  => $PROGNAME,
    shortname => $PROGNAME,

);

I made sure I had downloaded the right version of Monitoring::Plugin by using the following command : cpanm Monitoring::Plugin@0.37

What did I do wrong?

Thanks a lot for your responses

Thomas

@glensc
Copy link
Owner

glensc commented Sep 2, 2016

how did you download it? exact url please?

seems you did not download release version as described in README:
https://github.com/glensc/nagios-plugin-check_raid#installing

but rather unreleased dev version

neither i can figure out how you ran the code if you used git checkout:
https://github.com/glensc/nagios-plugin-check_raid#development

i.e what command did exactly do you run

the release version of this plugin is self contained, you do not need to modify any file or install dependencies.

glensc added a commit that referenced this issue Sep 2, 2016
a note to users who don't bother to read install doc and expect things to work. #147
@glensc glensc closed this as completed Sep 2, 2016
@glensc glensc added the question label Sep 2, 2016
@tloubaresse
Copy link
Author

Hey,

Thanks for your response, and sorry for mine's almost 3 weeks late, was on vacation...
I checked what you told me and I indeed did download the dev version (with git).

Downloaded the 4.0.2 realease and got the same lib issue, but after updating the path, it seems to work fine :)
Thanks a lot and once again, sorry.

Thomas

@glensc
Copy link
Owner

glensc commented Sep 19, 2016

err. what? what lib issue? what same? don't know what you're talking about if you don't show what was error and what you modified (diff -u)

@tloubaresse
Copy link
Author

yes of course, sorry.

Nothing much, but the plugin couldn't find perl's plugin in lib/App/Monitoring/etc...
had to add use lib '[pathtodir]/lib/ at the beginning of check_raid/pl in order to start it. I also could copy the lib's folder in perl's @inc to get this working i guess.

I ain't a linux expert, so I can be confusing and messy, sorry about that.

@glensc
Copy link
Owner

glensc commented Sep 19, 2016

err, wtf. i think you still downloaded wrong version. exact url please, which i already asked!

and by showing error, i do not need to hear "bla bla, etc" i need exact errors, copy-pasted to comment form here. do not omit anything because you'll likely omit the part i want to see. and use backticks block when pasting:

 ```
 text here
 ```

@tloubaresse
Copy link
Author

tloubaresse commented Sep 19, 2016

Alright, here's the exact info :
link from where I downloaded the script : https://github.com/glensc/nagios-plugin-check_raid/archive/4.0.2.tar.gz

actions done :
tar xvf of the archive into the user's home directory
then

[root@eon nagios-plugin-check_raid-4.0.2]# ./check_raid.sh
Can't locate Monitoring/Plugin.pm in @INC (@INC contains: /home/nagios/nagios-plugin-check_raid-4.0.2/lib /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 /home/nagios/nagios-plugin-check_raid-4.0.2/bin/check_raid.pl line 2.
BEGIN failed--compilation aborted at /home/nagios/nagios-plugin-check_raid-4.0.2/bin/check_raid.pl line 2.

if I verify :

 ls /home/nagios/nagios-plugin-check_raid-4.0.2/lib/App/Monitoring/Plugin/CheckRaid
Plugin.pm  Plugins  SerialLine.pm  Sudoers.pm  Utils.pm

the problem seems to be coming from the script looking for Plugin.pm in:

/home/nagios/nagios-plugin-check_raid-4.0.2/lib

when it's in

/home/nagios/nagios-plugin-check_raid-4.0.2/lib/App/Monitoring/Plugin/CheckRaid

I hope that it's what you wanted from me :)

If you want me to do specific actions, please tell me

@glensc
Copy link
Owner

glensc commented Sep 19, 2016

so, you downloaded Source Code, but you should had downloaded the plugin itself:

image

@tloubaresse
Copy link
Author

Right, that's it :) Will know next time, thx for your patience and advices...

I'll download it right away

@glensc
Copy link
Owner

glensc commented Sep 19, 2016

the error you are getting: Can't locate Monitoring/Plugin.pm in @INC is not part of this program (see CPAN: Monitoring::Plugin), so there's nothing to fix in code. App/Monitoring/Plugin/CheckRaid/Plugin.pm is totally different module (part of this project)

if you wish to run the plugin using source code, you must install dependencies listed in cpanfile manually. easiest is probably just to do it with cpanminus:

$ cpanm --installdeps -n .

@tloubaresse
Copy link
Author

Yes, it makes sense... Oh, all right, it'll be cleaner than what I did haha

thx a lot for all these infos :)

@glensc
Copy link
Owner

glensc commented Sep 20, 2016

oh, and info is uncountable, always spelled as info, never infos or informations

http://dictionary.cambridge.org/grammar/british-grammar/nouns-countable-and-uncountable

:D

@tloubaresse
Copy link
Author

mmmmmmh, damn. I wrote too fast :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants