Setting up Website monitoring in Check_MK

This post assumes you are happy configuring your Check_MK monitoring through the /etc/check_mk/main.mk configuration file..

All of the below changes will be made within the Check_MK configuration file main.mk. Open up this file and create (or add to) the following sections – If you do not have the sections already you can simply include the whole of the below, if you do – simply include the commands within the appropriate groupings.

I will be running these Web checks from my Nagios server as it already has the check-http script in the below location (Based on a default Nagios installation). This may differ so first find it on your server (find / -name “check-http”). I will be using the server tag “webmon” to idenfity my nagios server “hvm-nagios” as the server to run these checks from:

nano /etc/check_mk/main.mk

The first

all_hosts = [
"hvm-nagios|webmon"
]

Now, define the checks below. We will be creating two separate checks, one for ensuring the root of a website (Eg https://tjth.co) is online, and the other for checking a particular page.

extra_nagios_conf += r"""

define command {
command_name check-http
command_line /usr/lib64/nagios/plugins/check_http -H $ARG1$
}

define command {
command_name check-http-page
command_line /usr/lib64/nagios/plugins/check_http -H $ARG1$ -u /$ARG2$
}
"""

Now, Set up the checks as below in the legacy_checks Section – I will include one of each checks so you can see the formatting for both:

legacy_checks = [
( ( "check-http!wp.tjth.co", "Website - TJTH Ltd", True), [ 'webmon' ], ALL_HOSTS ),
( ( "check-http-page!wp.tjth.co!setting-up-website-monitoring-in-check_mk/", "Webpage - This guide", True), [ 'webmon' ], ALL_HOSTS )
]

Once you have added all of the above, reload Check_MK and check for your new checks on your Agent. Any issues with the above config will error here and cmk will not reload successfully.

cmk -O

Any comments or questions? Get in touch here or Email me at [email protected]