Moving Icinga configuration between machines

I recently set up an Icinga satellite server for a customer project, but it turned out that the virtual machine I tried to do this on wasn't up to the job (don't misinterpret that as meaning Icinga can't run on a VM, or even that it has particularly heavy requirements - the actual problem was that the hosting provider was crap. I moved from a 4Gb RAM 2 CPU core machine to a 1 Gb RAM 1 CPU core (and still a virtual) machine at another provider, and the problems went away).

I was keeping the hostname the same, just changing IP addresses in DNS, so instead of going through the whole Icinga node setup procedure again, I decided to just move the appropriate bits of Icinga's configuration and save time.

The following should be copied (recursively, where it's a directory) from the old server to the new one:

If you're issuing service check commands over SSH, you should also copy over /var/lib/nagios/.ssh

It's probably a very good idea to shut down Icinga on the old server before restarting it on the new one, since otherwise both will be trying to communicate with the parent server (and the "two way, whichever works first gets things going" nature of Icinga master-slave communications means that the old server would still be perfectly capable of getting updates from, and reporting check results to, the master server even after DNS for the slave has been switched over).

Put it like this: I haven't tried doing it differently…

Once the above files have been copied from the old server to the new one, restart Icinga on the new machine, and it should receive its configuration from the master and start working immediately.

If it's a satellite issuing check commands over SSH, these will be unaffected by the DNS change.

If it's a satellite issuing check commands by connecting to endpoint Icinga instances, you should ensure that either:

PNP4Nagios

If you installed PNP4Nagios on both machines, you probably want to transfer the historical performance data across to the new server.

If both machines are running 32-bit Linux, or if both are running 64-bit Linux, this is easy - just copy /var/lib/pnp4nagios/perfdata (recursively) from the old machine to the new one, as simultaneously as you switch between the two running Icingas as possible.

If the architectures are different, though, you can't copy the data directly; it has to be converted using rrdtool (because rrdtool, for some reason, stores data in different formats depending on whether it's running on a 32-bit or a 64-bit system).

The following will do what you need (run this on the old server, ideally with public-key SSH access to the new server):

cd /var/lib/pnp4nagios/perfdata
for m in *
do
  echo $m
  cd $m
  for r in *.rrd
  do
    echo $r
    rrdtool dump $r | ssh new.ser.ver rrdtool restore -f - /var/lib/pnp4nagios/perfdata/$m/$r
  done
  cd ..
  echo
done

Go up
Return to main index.