Page 1 of 1

Import contact users to 200 individual hosts

Posted: Mon Jun 29, 2015 6:55 pm
by jkinning
I have 200 remote Offices each having a different email address. Is there a way to construct a file to import all these different contacts which each have a different email address and assign to the appropriate hosts and service check for notifications? Or will I have to manually enter each contact and assign it to the appropriate hosts and service checks?

Re: Import contact users to 200 individual hosts

Posted: Tue Jun 30, 2015 6:52 am
by lmiltchev
The easiest way to do this would be via the Bulk Modifications Tool, with which you can add contacts/contactgroups in bulk to hosts/services. The tool is a part of Nagios XI Enterprise Edition.

https://www.nagios.com/products/nagiosx ... comparison

Re: Import contact users to 200 individual hosts

Posted: Tue Jun 30, 2015 11:08 am
by jkinning
Sorry, I wasn't clear. I am looking for a way to take a list of users with email address and import them into Nagios XI as contacts. Once I get them imported I could use that tool to assign them to the hosts but it would probably be easier to do it onesy twosy since each hosts would be assigned a different contact. Which is why I was trying to take my list of contact names and email address and import them in as contacts and assign them to a particular host all in one swoop. Considering I have 200 of these to do. :o

Re: Import contact users to 200 individual hosts

Posted: Tue Jun 30, 2015 11:21 am
by tmcdonald
In terms of the contact import, take that list and use it to generate a bunch of valid contact definitions in a .cfg file, and put that file under .../nagios/etc/import, then apply config and they will be pulled in to the CCM.

As far as assigning them to hosts, that would take some direct DB modification. How complicated of a setup are you thinking? Just "Contact A goes to Host A" etc?

Re: Import contact users to 200 individual hosts

Posted: Tue Jun 30, 2015 1:11 pm
by jkinning
So I created the 200 cfg files and they look like this

Code: Select all

define contact {
        contact_name                     Office1
        alias                                   Office1
        host_notification_period                xi_timeperiod_24x7
        service_notification_period             xi_timeperiod_24x7
        host_notification_options               d,r,
        service_notification_options            c,r,
        host_notification_commands              xi_host_notification_handler
        service_notification_commands           xi_service_notification_handler
        email                                   office1@@domain.com
        }
Can I merge all these together into one file with all 200 entries or is it better to leave them all separate? Place them in the /usr/local/nagios/etc/import and then apply configuration. Then I'll just need to use the Bulk Modification to add the contact to the host and services?

This sounds easy enough if I am thinking this out right.

Re: Import contact users to 200 individual hosts

Posted: Tue Jun 30, 2015 1:15 pm
by tmcdonald
That's how I would have done it, just make sure you don't actually have "@@" for the email addresses. Some sed magic should be able to remove that. As for keeping them separate or all in one, I don't think it matters. Maybe keeping them separate is easier for maintenance before the import?

Oh, and take a full XI backup before you do this, and make certain that the configs are proper. There isn't a lot of sanity checking when imported this way.