centreon / nagiosToCentreon

Import your nagios config files into Centreon DB... And it rocks !
Apache License 2.0
9 stars 13 forks source link

Can't call method "register" without a package or object reference at nagios_reader_to_centreon_clapi.pl line 490. #24

Closed KarlisSe closed 7 years ago

KarlisSe commented 7 years ago

When I run perl nagios_reader_to_centreon_clapi.pl --config /usr/local/nagios/etc/nagios.cfg > /tmp/centreon_clapi_import_commands.txt I get these 2 errors:

Use of uninitialized value $name in exists at /usr/local/share/perl/5.14.2/Nagios/Object/Config.pm line 367.

Can't call method "register" without a package or object reference at nagios_reader_to_centreon_clapi.pl line 490.

I tried writing Nagios::Object::Config in front of register method call, which took me a bit further:

Can't call method "registered" without a package or object reference at /usr/local/share/perl/5.14.2/Nagios/Object/Config.pm line 568.

When I try to provide Nagios::Object::registered nothing changes.

Do you have any suggestions? If the module Nagios::Object::Config is loaded why register is not recognized?

KarlisSe commented 7 years ago

It seems that I am getting somewhere - use diagnostics; is the key :)

For my first error:

Use of uninitialized value $name in exists at /usr/local/share/perl/5.14.2/Nagios/Object/Config.pm line 367.

I used solution in #9 after which I used #3. It seems that it all depends on how your nagios config files are configured/structured. If the script encounters an error while reading from cfg files it shows error:

Can't call method "x" without a package or object reference at nagios_reader_to_centreon_clapi.pl line #.

or similar.

By adding use diagnostics in nagios_reader_to_centreon_clapi.pl you can see the last step the script was executing before exiting with an error and from there you can start looking at your nagios cfg files for missing attributes or naming problems etc. use diagnostics gives out quite an output, but most of it is due to missing attributes in cfg files or something with naming or something like that(still troubleshooting).

I got it working by deleting few lines from servicegroups.cfg and most of services.cfg. I restored those files from backup and right now I am troubleshooting what exactly was the problem with those files.

KarlisSe commented 7 years ago

In services.cfgif you have the same service name for different hosts, you will get error:

Can't call method "register" without a package or object reference at nagios_reader_to_centreon_clapi.pl line 490.

It also applies to service and advanced service names.