usolved / check_usolved_vsphere_alarms

Nagios Plugin for getting alarms from VMWare vSphere
7 stars 3 forks source link

Can't call method "type" on an undefined value at /usr/share/perl/5.22/VMware/VICommon.pm line 1663. #1

Closed tobiasneumayer closed 7 years ago

tobiasneumayer commented 7 years ago

Hello,

thanks for the plugin! I´m monitoring our VMware ESX host over the check_vmware_esx.pl plugin with VMware SDK 6.0 and everything is working quite well. Now I found your plugin and want to give it a try but the following error occurs after this command: $./check_usolved_vsphere_alarms.pl -H -U -P Can't call method "type" on an undefined value at /usr/share/perl/5.22/VMware/VICommon.pm line 1663.

I´ve seen, that the plugin is only tested with 5.0 and 5.5 but I hope you can help me with my problem too.

Thanks in advance!

usolved commented 7 years ago

Thanks for trying out this plugin.

At first (in the development progress) I've only tested it with 5.0 and 5.5. But we are now using VMware-vSphere-Perl-SDK-6.0.0-2503617.x86_64 in our infrastructure and the plugin works without problems.

A difference is, that we are using Perl 5.10.1.

It's not easy to track down the error you're getting because it doesn't show which line in the plugin is responsible for calling the error in the VMware SDK.

Since I cant't reproduce the error, you could try to isolate the problem. I don't know if you have any Perl knowledge but at the bottom of the script there are a few function calls:

#---------------------------------------------------------------------------------------
# Call functions

get_options();
connect_vsphere();
get_alarms();
output_nagios();

Try to delete or comment out these function calls and see if the plugin comes up with the same error message. If you don't have any errors try to add again get_options(); then test the plugin for errors, then add connect_vsphere(); and so on.

So hopefully we'll know which routine causes this error.

But it's really strange that you get an error when check_vmware_esx.pl is working for you because this plugin uses the same API calls.

tobiasneumayer commented 7 years ago

Thanks for the fast reply!

after commenting the line "get_alarms();" I get the following output: OK - No alarms found But I think this is the most important method to get the errors from the esx host, isn´t it?

After commenting the others, I don´t get any output from the plugin, not even an error.

My perl version is v5.22.1

usolved commented 7 years ago

Yes, every method is important. That was just to see which function will produce the error. So probably "Vim::get_view(mo_ref => Vim::get_service_content()->alarmManager);" is creating this error.

I tried to search for similiar errors and found some other plugins where the answer was to check if you're using a local and not AD user. A second reason could be that you're trying to connect to a single ESX host and not the vCenter.

I just tried to connect to a ESX host and I got the exact same error that you got. So did you tried to get alarms from a ESX host or vCenter to fetch all alarms?

Edit: Also try just to remove this line:

my $alarmMgr = Vim::get_view(mo_ref => Vim::get_service_content()->alarmManager);

Since this view won't be used and is still there because of early testings.

tobiasneumayer commented 7 years ago

Yes, this was my mistake. I´ve tried to connect to a single esx host instead of the vCenter. Now I want to connect with my AD user (to vCenter). Is it possible or has it to be a local user? If it´s possible with AD user, the username is as follow: domainname\username - correct?

Because I get the message, that either the username or the password is false.

usolved commented 7 years ago

It's also possible to use ad AD account. You just have to escape the backslash:

-U yourdomain\\user -P password

But it's better to create a user that don't has admin rights.

tobiasneumayer commented 7 years ago

Thank you very much, the "\" was my mistake. (But it´s already in the docs I´ve seen)