Hi everyone,
I need to migrate our current single site “img” from one server to two new servers. My goal is to have sites like img-computers, img-printers, img-swithech … The two most important requirements are keep all historical data and especially keep all existing user notification rules(mail and sms) working for our LDAP-authenticated users.
What is the recommended way to split one big site into multiple sites? Has anyone done something similar and can share the steps that worked?
Thanks a lot!
MZa
CheckMK supports central configuration/monitoring & deploying that configuration to multiple sites. First of, familiarize yourself with the documentation how to set up & run distributed monitoring.
Next set up one or two additional sites & create some test hosts & services on each site, just to get a feel for how working with such a setup looks. You can even do that on the same machine as you can run multiple instances (sites) of CheckMK on the same computer — though I suggest you really use different machines, just to see how that setup really works.
Next realize that “moving” a host from one site to another is as easy as setting the “Monitored from” property in the host’s configuration in WATO. You can do that for individual hosts or on whole folders. After such a change in WATO all you need to do is activate the changes as usual & the host is now monitored from somewhere else.
This is where things get a bit tricky, though.
Historical data
Switching the “Monitored from” status does not migrate metrics data or event history to the new site. Unfortunately there’s no easy way to migrate event history at all as that’s stored in a text file, and not one file per host, but one file per site where all host & service events are recorded (or something like this, I’m not 100% on the details here). Therefore I’ve never done that.
What you can do much more easily, though, is migrating the metrics as those are stored in RRDs (going from CheckMK Enterprise & above editions here, I don’t know if/how Raw differs). The RRDs are stored in the following directory:
/opt/omd/sites/<site_id>/var/check_mk/rrd/<hostname>
Therefore the steps to copy over the metrics from the old site to the new one are, ideally:
- create TAR on old site of all hosts you want to migrate
- copy TAR to new machine
- unpack TAR there into new site’s corresponding directory (they’ll be different! each
site_idis unique in a distributed setup!) - change the file/directory owners to the new site’s Linux user which has the same name as the new site’s ID
- in WATO switch the “Monitored from” property to the new site
Notifications
In a distributed setup CheckMK distributed all configuration including installed MKPs, all rules etc., including the notification/event rules to the connected sites. Therefore your notification setups will be set up on the secondary sites in the same way.
However, you need to understand that by default notifications are generated on the site that the host they’re generated for is monitored from. If you did any kind of manual setup in the file system of your primary site (e.g. created a custom script for sending SMS) then these manual steps will not be replicated to the remote sites automatically as CheckMK only knows about stuff configured through WATO. You need to take care of such manual modifications yourself, ideally with automation tools such as Ansible or similar solutions.
Alternatively you can configure the notifications to be sent solely from the main site, even if the host a notification is triggered for is monitored from a remote site. This means, though, that in case of a lost connection between a remote site & the central site (e.g. remote site in a remote network connected via a VPN tunnel and that VPN tunnel goes down) the remote site won’t be able to send out notifications until the connection’s been re-established. Read the docs I’ve linked to earlier for how to set that up; it contains a whole section just about notifications.
How well does this work?
If you read the forum here you’ll often stumble across people who use such setups. We do, too, I’d say a mid-sized one with about 1.850 hosts monitored from roughly 70 sites. There are much smaller setups, there are much larger ones out there. The ratios of hosts per monitored site varies wildly, too. All in all it works very well for various purposes (scaling, having different sites in different network locations/in customers’ networks).
What is your motivation for this?
We have three server rooms and will have three monitoring servers, so we will need three cmk site.
For moving the History and RRD Files you can try Checkmk-Checks/datamover at master · kuhn-ruess/Checkmk-Checks · GitHub
That’s a great tip, thanks! I wasn’t aware of those tools.
Unfortunately it only handles multiple sites on the same host, so you’ll have to do some more manual stuff before & after running it.
Says everything on the subject (added 11 Aug, '22):
https://ideas.checkmk.com/suggestions/321781/support-migration-of-hosts-between-sites-without-any-loss-of-data
In the end, I did it really smart ;-).
I restored the site from a backup onto a new server, renamed it, reconfigured the TCP ports, and deleted the hosts/devices I didn’t want there.
I repeated the whole process 3 times, each time deleting different hosts.
So now I have 3 separate sites with different devices, but each one has the complete history and user settings.