import services

Support requests, bug reports, questions etc.
Locked
ajuntune

import services

Post by ajuntune » Wed Jun 24, 2009 00:31

So far I've imported everything up to the serivces.cfg and it's worked well. When I get to the services.cfg import, I always get the output shown below. I've tried just importing one host. I've even tried importing the initial host that is created by default.

any ideas?

thanks
adam

add_items_from_cfg.pl -c service -n service_description -f services.cfg -x 3
[ Initializing NConf perl-API (library version 0.1, written by A. Gargiulo) ]
[ Copyright (c) 2006-2009 Sunrise Communications AG, Zurich, Switzerland ]

[ DISCLAIMER: This library is BETA and comes with ABSOLUTELY NO WARRANTY of any kind! ]
[ Syntax may be subject to change in the future! ]

[INFO] Started executing /var/www/html/nconf/bin/add_items_from_cfg.pl
[INFO] Adding service 'localhost;;check_local_load'
[WARN] Could not find attribute 'retry_check_interval' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'max_check_attempts' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'check_freshness' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'notifications_enabled' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'notification_options' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'active_checks_enabled' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'normal_check_interval' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'freshness_threshold' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'passive_checks_enabled' belonging to class 'service'. Skipping import of this attribute.
[WARN] Could not find attribute 'notification_interval' belonging to class 'service'. Skipping import of this attribute.
[ERROR] getServiceId(): Missing argument(s). Aborting.

User avatar
agargiulo
NConf developer
NConf developer
Posts: 725
Joined: Fri Mar 06, 2009 17:50
Location: Zurich, Switzerland
Contact:

Re: import services

Post by agargiulo » Wed Jun 24, 2009 09:56

Hi.

This error usually indicates, that the host which owns the service does not exist in the database. In your case it looks like "localhost" could not be found. Try running the same command with "-x 5" and at the very end you should see something like this:

[DEBUG] |NConf::DB::Read::getItemId| Fetching id_item for host 'localhost'
[SQL Query] ...
[TRACE] |NConf::DB::Read::getItemId| Query result: ' '
[TRACE] |NConf::DB::Read::getServiceId| Entered getServiceId()
[ERROR] |NConf::DB::Read::getServiceId| getServiceId(): Missing argument(s). Aborting.

Please consider that with the current version of the importer, the items are not imported in the same order as in your Nagios config files. The whole file is parsed first, and then processed in random order. This is something we will fix in the next release.
So chances are that your services.cfg file contains some services which belong to a host that you have not imported yet...

ajuntune

Re: import services

Post by ajuntune » Thu Jun 25, 2009 01:03

you were right. I have multiple hosts for each service and that was the problem - the importer won't allow commas in the host_name. Somehow you can only have one host_name per service. So I had to take off all hosts except one for every service. For instance, I had.
host_name venus,mercury,mars

and I had to change it to be just

host_name venus

so now i have to figure out how to get multiple hosts for each service since nconf won't let me do this even with the gui? I'm pretty new to nagios, so there must be a different way to do this. With host templates or something? Anyway, I'm looking forward to learning how to config with nconf and I'll read the docs.

adam j

User avatar
agargiulo
NConf developer
NConf developer
Posts: 725
Joined: Fri Mar 06, 2009 17:50
Location: Zurich, Switzerland
Contact:

Re: import services

Post by agargiulo » Thu Jun 25, 2009 16:26

Hi.

In NConf you can assign each service to exactly one (1) host. So yes, you would have to import the same service 3 times, for each host once.
This is not likely to change in the future, since NConf already makes maintaining the config a lot easier. Many of the time-saving tricks that Nagios offers are unnecessary in NConf, because the GUI already makes work easier (bulk changes to a lot of items can be done using the "multi-modify" function).

I believe it would be useful to extend the Importer to automatically recognize services, which are assigned to multiple hosts, and to automatically add multiple services in the background. I will add this as a feature to the list of requests for the next release.

ajuntune

Re: import services

Post by ajuntune » Tue Jun 30, 2009 04:27

Thanks for putting in a request for the next version of the importer. I've got a few hundred unique services spread accross hundreds of hosts, so I've got 1800 more services to create. I like nconf though, so I think it's worth it.

thanks for the great work!

adam

melber
beginner
beginner
Posts: 11
Joined: Tue Jun 30, 2009 16:22

Re: import services

Post by melber » Thu Jul 02, 2009 13:13

Hi,

I had the same problem I think i wrote it somewhere here under my usual nick Melanie__ which this forum doesn't like.

make a copy of the objects.cache file where nagios is doing a cache of the config it uses and writes it in the right style to use it with the script.

next you need to devide it into seperate files so the script can handle the data.

if this is done you can use the script to insert the data into the database. if there are warning it works because you will have things defined that are also defined in other things so don't worry. if you follow the commands listed in the documentation and the order it should be just fine. part of the data will be your configs and part will be from objects cache put together in the database and then when generating a config it should be almost as before.

regards

mel

User avatar
agargiulo
NConf developer
NConf developer
Posts: 725
Joined: Fri Mar 06, 2009 17:50
Location: Zurich, Switzerland
Contact:

Re: import services

Post by agargiulo » Thu Jul 02, 2009 15:15

Thanks mel.

I will add your hint about the objects.cache file to our Import guide.

ajuntune

Re: import services

Post by ajuntune » Tue Jul 07, 2009 15:39

Thanks Melanie,
that worked like a charm. I used all my existing config files, except for the services.cfg. I just cut and pasted the last part of /usr/local/nagios/var/objects.cache into a services.cfg file and I got all 2002 of my service checks imported. The services.cfg file was about 30,000 lines and nconf handled it without any issues!

adam

Locked