Ep. 16: Working with Bulk Actions

To load this YouTube video you are required to accept advertising cookies.

Note: All the videos on our website offered in the German language have English subtitles and transcripts, as given below.

[0:00:00] In today's episode, we will address a topic that our users have requested, namely the so-called bulk actions in the WATO host management.
[0:00:22] With the bulk actions, you can perform tasks on a number of hosts in WATO simultaneously, and I will now show you how to do this live in the system.
[0:00:31] Here you can see a very simple checkmk system with only six hosts, but these are enough for us to look at the most important points here.
[0:00:39] I now go to the Hosts administration and then to the 'Servers' folder, in which I have five hosts.
[0:00:48] Here you will find an icon with a checkbox, which is below the list.
[0:00:54] If you have ten or more entries, you will find checkboxes both below and above the list.
[0:00:58] If I now select this checkbox, an additional checkbox appears on the left for each host.
[0:01:05] So what do I need this checkbox for? I can now use this to select individual hosts here.
[0:01:11] You can also use this little icon up here to turn on all of the checkboxes at the same time or turn them all off at the same time.
[0:01:17] If the checkboxes are not activated, it is as if all the checkboxes have been ticked.
[0:01:24] So, I turn this on again, and select, for example, three hosts here, and now you will find a row of buttons at the bottom or, in the case of longer lists, also above the list, here.
[0:01:37] I'm going to fold in the sidebar so that you can see this all better, and now there are a number of actions that I can carry out on this whole list.
[0:01:46] A few of these are relatively simple, so for example with 'Move to:' I could choose to move them all to a specified folder.
[0:01:52] I think that's relatively easy to understand, so now when I do a bulk edit it becomes more interesting.
[0:01:59] So with this button I can in effect edit all three of these hosts simultaneously.
[0:02:04] So we now have three hosts selected, and it is of course important to know that only where I select a checkbox will I be changing that attribute for these hosts.
[0:02:17] You can see that a checkbox has already been selected here – this is because all of these hosts have explicitly been assigned the IP address from the local host, since this is my test system. So, I could say here, for example, that I want to enter a network segment for all of them.
[0:02:37] So I activate this checkbox and choose, for example, the network segment 'WAN'.
[0:02:44] This caption here is also interesting, you should read it carefully, for example it says 'This value differs between the selected hosts'. This means that these three hosts that I have selected currently have differing values.
[0:02:57] At the entry here below for example 'My own tags', 'Webserver', you can see that this value has been inherited from the folder and is currently the same for all three hosts,
[0:03:07] otherwise the same other text would also be displayed here. So, if I now save here, it means that the network segment 'WAN' will be explicitly entered for these three selected hosts.
[0:03:18] As you will probably already know, with Checkmk it makes a difference whether I have explicitly set an attribute or whether I have not defined it.
[0:03:30] So, if I now remove a checkbox somewhere on the host, you can always see that it then gets its value either from its folder
[0:03:36] or the default value, so it makes a difference whether I explicitly enter a value or whether I simply don't specify anything at all.
[0:03:43] If you now use this Bulk Edit, then it will of course be the case that I can only set attributes with it – I cannot remove any others.
[0:03:52] So if I go back in here to Bulk Edit and deactivate a checkbox, this doesn't mean that I am removing this attribute from the three hosts, it simply means that I don't want to edit the attribute in Bulk Edit.
[0:04:05] If I now save here, for example, nothing will have been changed in the IP address for these hosts.
[0:04:10] This is why there is also a reverse action, the so-called Bulk Cleanup.
[0:04:14] It's this button down here. With the cleanup, you can remove attributes from the selected hosts that have been explicitly set, and thus inherit the attributes from the folder again.
[0:04:27] You can see a list here – it is much shorter now.
[0:04:31] This is because, of course, only such attributes that have actually been set on any of these three hosts will now be displayed here. We can see here, for example, that an alias has been set for one of the hosts, the IPv4 address has been set for all of the selected hosts – for example for these three – and also the network segment, because this was what we have just set in this example.
[0:04:53] This means that if I now tick the box here and click 'Save', then I will have removed this explicit attribute. We can take a look at one of the hosts – if I now go into the properties for this host – the checkbox should have been removed again from here at the bottom. And again it says it inherits this value 'Webserver' from its folder. This is a very powerful method to make sure that inheritance works again, after all it is of no use if I now explicitly set all of the attributes on hundreds of hosts, because then I will be unable to inherit any more properties via the folder, and that's why the Cleanup makes sense – to tidy up its configuration again and bring everything back to a satisfactory state.
[0:05:38] Another important action in Checkmk is the Service Discovery, i.e. the automatic addition of missing services to hosts, or possibly also the removal of superfluous ones. And the short cut for this – as you probably know – is this one – the Service Configuration icon, where I can view the services on a host, and if necessary add missing ones, remove superfluous ones, and so on. What we of course want to discuss today are the bulk actions, so the question is: How can I do this for multiple hosts at the same time? Especially with Discovery, there are now two possible methods.
[0:06:17] One option is to use this button, 'Discovery', then I redo the service configuration for the whole list of hosts, or only for the hosts that I select with their checkboxes.
[0:06:30] I can now go in, here, so I go to 'Discovery', and now I have a dialogue where I can decide exactly what I want to do.
[0:06:40] The default setting here is 'Add unmonitored services and new host labels', i.e. only new services are added here – no services that have vanished will be removed, as this can be a potential risk.
[0:06:55] So, let's take an example: you monitor file systems, and a file system has 'vanished', it could have been an error that has caused it to vanish, so you want to see it being monitored, and you want to be alerted. If I now say 'Remove vanished services' it would mean that the service will simply be removed and will fly out of the monitoring altogether – so this is not necessarily without any risk.
[0:07:16] Or the same also applies to switch ports, where the default setting is that the ports currently in use should be monitored.
[0:07:25] So that would mean, of course, that the ports which aren't being used would fly out with that state during a Discovery – and that certainly can't be what you want to have happen.
[0:07:32] So you can choose here, whether you want to have only new services, or conversely when you want to remove the superfluous services. This option is both actions combined, and the fourth option is a complete re-discovery of everything, in other words, to basically throw everything out and redoing it.
[0:07:49] There are a couple of quite interesting additional functions, for example 'Only include hosts that failed on previous discovery'. This means, for example, that when you have added hundreds of hosts through a bulk import via CSV import, for which at the same time you run a discovery, then it can be, for example, that of these hundreds, maybe three or four or ten are not accessible, meaning that the discovery must be performed again.
[0:08:16] So that you do not have the effort of selecting all of these hosts individually, you can select this checkbox, and then only those hosts which failed the previous time will be newly-discovered. A similar option here is the option for when the discovery check has failed, i.e. there is a check that warns you that services on a host are not being monitored. Here you can specify – exactly where this check is posted – that I would like to re-Discover now.
[0:08:45] And once you have made the selection, click Start here, and then a so-called background job runs, that is, the whole process can take a while – there can possibly be thousands of hosts involved – and at some point the process will be finished, and here you will see a list of everything that has happened, for example, 57 services have been added here, 57 removed, because I simply selected the setting: Redo everything.
[0:09:12] So that was effectively the Bulk Discovery in this list.
[0:09:19] There is one more thing however – there is a button up here, which is also called 'Bulk discovery' – and with this you can start this Discovery recursively for the folder and all of its subfolders, the options are the same as here, only if I do this in my main folder – and there are all of the possible subfolders attached to it – then this bulk discovery will automatically include all of the hosts in all subfolders as well, or I can disable this functionality here with this checkbox, which is on by default. If I deselect that now, I will get the same result as if I had selected all hosts in that folder.
[0:09:58] Another operation on a Host is Renaming. This sounds pretty unspectacular at first – renaming a host should not really be a big action – but those who have done this before will see that Checkmk makes a big fuss about it, because the host name is also a key to the host's history, its databases and so on. This means that when renaming a host, Checkmk has to go through all of the host's databases and data collections and rename this host name everywhere so that, for example, its history is correct again, otherwise you could simply delete the host and create a new one.
[0:10:34] But if we want to have an availability, for example, a history of all past notifications and so on, then the rename action works that it also renames all past versions of the host, so that the host acts as if it had always been called by the new name.
[0:10:49] So that is quite a complex operation which also requires that the Checkmk system be stopped so that these database names can be updated in a consistent manner.
[0:10:59] So if you have a number of hosts to be renamed, and the Checkmk system has to be stopped and restarted for every single one – that is quite time-consuming – which is why there is a bulk renaming function here – which I would like to show you now.
[0:11:12] The function to rename multiple hosts all at once can be found by clicking the 'Bulk renaming' button.
[0:11:18] By default, 'include all subfolders' is checked – if you turn this off, the process will only be performed in the current folder.
[0:11:25] Important now here is a host name matching, so that you can use it at this point to decide which hosts should actually be renamed, otherwise it would work for all of them by default.
[0:11:34] This is a regular expression. You can find a special chapter on regular expressions in the manual, in which you can learn about them and all of their features.
[0:11:45] What's important to know here: it matches on the beginning of the host name, I can enter for example: 'dbserver', so that all hosts whose name starts with 'dbserver' will be renamed.
[0:11:57] So, what do they want to be renamed to?
[0:11:59] Well, now of course I can't just specify a new host name, because I don't want them all have the same name. What I really need is an operation, a kind of rule, according to which the renaming will take place, and that is the so-called Renaming.
[0:12:13] Now when you select 'Add renaming' in the dropdown list you will be able to see the various options for the renaming of hosts. A very simple task would be, for example, a 'Case translation', which means, for example, that you could want all of the host's names to be in lower case or in upper case. For example, after an import there may be host names with some combination of mixed characters, but if you want to have them all in lower case, you can specify that here. I'll make them upper case in this example, since here for me they are already in lower case.
[0:12:39] And then I can test it out by clicking on 'Bulk Rename' and before it starts I get a list of the hosts and what they would be renamed to, so for example 'dbserver04' will be called 'DBSERVER04', in upper case.
[0:12:53] If I select 'No' at this point, I can go back and adjust my renaming options again.
[0:12:58] For example, I can also add a second renaming, and both actions will be performed in sequence. For example, I could say here that after converting to upper case, I also want to add a suffix, which will be '.test'.
[0:13:16] When I go back to 'Bulk Rename', you can also see that the suffix is shown here in lower case – i.e. first the name is converted to upper case, and then the suffix '.test' will be added.
[0:13:29] If I want to change the sequence of the actions, I can just drag this operation up to here – so that first the .test suffix will be added, and then the whole name will be converted to upper case, which will look like this.
[0:13:42] The most flexible operation that you will find here, with which you can solve the most problems, is not something like a 'Case translation' or 'Add Suffix' – which is why I am removing these again – instead you can find an operation here called 'Regular expression substitution', which is somewhat more complex, and which is really something, so I am now going to show you a good example.
[0:14:05] I would like the host names to no longer be called dbserver01, 02 and so on, but I would like them to be called 'db-01-server', for example, so I would like to extract a portion from the host name and to reuse this in the new host name. For this I need a so-called subgroup for the regular expressions. I write it like this now – I enter 'dbserver(.*)'.
[0:14:36] With these two brackets, I capture, so to speak, any text that is at this position.
[0:14:42] In this case it is the texts 01, 02 and 03. And I can then insert this text into my new replacement text at any desired position.
[0:14:52] For example, I could now say the new host name should then be: 'db-\1-server'.
[0:15:00] The backslash means that I want to insert the first subgroup here.
[0:15:08] Let's do a check to see if 'dbserver0' will now become 'db-04-server'. So this is a very flexible method with which you can simply cut out any part of a host name and then insert it when constructing a completely new host name.
[0:15:27] When you are satisfied with the list of renames, you just click on 'Yes!', with which the renaming process will begin, and this whole procedure runs as a background job.
[0:15:37] It may actually take a while, because – as I mentioned earlier – the Checkmk system has to be stopped for reasons of consistency, and then in all log files, databases and so on, this host will be renamed, and it will also be made to appear as if the host has always been known by the new name.
[0:15:58] This means that you should not do this if the productive Checkmk operation is currently required.
[0:16:04] The monitoring simply has to be stopped at this point for a short time – which can take seconds or minutes – and then it will be automatically restarted. The whole process runs as a so-called background job, so you can follow its current status here, and as soon as it has finished, it will appear in green here, and the monitoring will restart.
[0:16:25] You can now see a summary below – 'Auto-discovered services of the host', which means that the auto-checks have been renamed, and cached, so you can see where renaming has taken place, and that the whole process was successful, and that the Checkmk is now running again, and that your hosts have been renamed.
[0:16:43] So, that's what I wanted to show you about the bulk actions. I hope you have enjoyed it, and of course I also hope you have subscribed to this channel, so you won't miss our next video.

Want to know more about Checkmk? Join us for our Introduction to Checkmk Webinar

Register now

More Checkmk Videos