Script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
peter19x
Posts: 119
Joined: Tue Dec 08, 2015 10:16 am

Script

Post by peter19x »

Hello,

Apologies if my question is too detailed to ask. But I was wondering if there is some kind of script or fast way for post-transfer bulk renames?

For example : build a delimited file that has hostnameX that should be renamed to hostnameY, along with IPaddressX replaced with IPaddressY in the config files.

Best Regards,
Peter
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Script

Post by rkennedy »

I don't believe so. You could probably script something out accordingly, and use it to replace strings before importing them into XI.

What exactly are you looking to accomplish?
Former Nagios Employee
peter19x
Posts: 119
Joined: Tue Dec 08, 2015 10:16 am

Re: Script

Post by peter19x »

Hello,

What I am trying to do is , I want to mirror all my config(Hosts/Services/IPs) from my Nagios XI Server on to my Lab Nagios XI Server so I can replicate what I have in live.

Once that is done, obviously the IP addresses of the devices Nagios is monitoring in live are different from the ones Nagios is monitoring In lab (we have a replication of all our live nodes in lab too).

So once I have imported all live config in the lab , I will have to change the IP addresses to the lab nodes and instead of entering them manually(200+IP) I was looking for a script where I could enter all live IP 'X' and all lab IP 'Y' and the script will replace them.

I know this is a bit specific but I wanted to check if someone had that issue and have a solution before I create my own script.

If not, I will share what I come up with.

Thanks,
Peter
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Script

Post by gormank »

I've done this between sites by copying config files from for example the hosts dir to the import dir on another Nagios installation, then searching and replacing hostname/IP in the config files and then running reconfig to import.

I've read that the recommended import order is:
commands
timeperiods
contacttemplates
contacts
contactgroups ->hosttemplates
hosts
hostgroups
servicetemplates
services
servicegroups

Have a look under /usr/local/nagios/etc/ at the various .cfg files.

Another idea is to generate hosts from a list of host,IP,etc. values in a .csv file. Then a reconfig would import them.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Script

Post by hsmith »

Thanks, @gormank !
Former Nagios Employee.
me.
peter19x
Posts: 119
Joined: Tue Dec 08, 2015 10:16 am

Re: Script

Post by peter19x »

Apologies for the late reply. I have forgotten this post.

I successfully imported my config following the guides and as advised.

I am fine with closing this post.

Best Regards,
Peter
Locked