Import contact users to 200 individual hosts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Import contact users to 200 individual hosts

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Import contact users to 200 individual hosts

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Import contact users to 200 individual hosts

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Import contact users to 200 individual hosts

Post 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?
Former Nagios employee
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Import contact users to 200 individual hosts

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Import contact users to 200 individual hosts

Post 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.
Former Nagios employee
Locked