CheckMK v2.2 - custom checks

I wouldn’t modify the original check_mk_agent because the changes won’t survive an update. My suggestion would be to either completely disable the output of the section <<<df_v2>>>. This can be done by creating the file /etc/check_mk/exclude_sections.cfg with the content MK_SKIP_DF=yes. In this case the whole function section_df() is not called. Of course, you must then supply your own version of that function in a separate plugin below /usr/lib/check_mk_agent/plugins/.

The simpler (and preferred) approach is to put an own plugin in /usr/lib/check_mk_agent/plugins/ which simply adds the data that is missing from the built-in section <<<df_v2>>>:

#!/usr/bin/env bash

echo '<<<df_v2>>>'
df -PTlk --type devtmpfs | sed 1d

echo '[df_inodes_start]'
df -PTli --type devtmpfs | sed 1d
echo '[df_inodes_end]'

In this example df will only process filesystems of type devtmpfs (as an example). checkmk will merge the original section df_v2 and your section df_v2 into one big section on the server side. The check plugin won’t even notice.

But be aware that the -l option to the df means local filesystems only. The problem is that df will hang for ages if a remote filesystem is not accessible.

1 Like