Active Checks debugging

Hi,

how active checks can be debugged?
For example an http check is not working and shows this in the Service check command:
check_mk_active-http!'-u' '/health-check' '--onredirect=follow' '--sni' '-p' '80' '$HOSTNAME$' 'www.foobar.com'
How can I manually run this command on the command line with debugging output?

Kind regards
Mathias

all default active checks (i.e. checks that you haven’t placed there yourself) are in ~/lib/nagios/plugins
so in this case, the call you are looking for would be “check_http” and then all the parameters after the ! in the service_check_command

the $HOSTNAME$ would have to be resolved manually as it’s not a bash but a checkmk/nagios variable

~/lib/nagios/plugins/check_http '-u' '/health-check' '--onredirect=follow' '--sni' '-p' '80' '$HOSTNAME$' 'www.foobar.com'

If you catch yourself regularly needing to check active checks, I use the following script to make life easier:

#!/bin/bash
# very simple script to run a livestatus query against the livestatus socket of the local site
# returns: host_name service_description and the expanded (i.e. with resolved variables) check_command that will be run on the command line

# Script understands only 2 parameters, both regex
# ./get_command_expansion.sh [service_description_filter] <optional_host_name_filter>

if [ -z "$1" ] ; then
 echo "Please provide part of a service_description so that we can filter somehow - if you want everything, use \".*\""
 exit 1
fi

if [ -n "$2" ] ; then
 hostfilter="Filter: host_name ~~ $2"
fi

query="GET services
Columns: host_name service_description check_command_expanded
Filter: service_description ~~ $1
$hostfilter"
echo -e "$query" | unixcat ${OMD_ROOT}/tmp/run/live

the check_http script has also a debug (-v) option which you can use during troubleshooting on the command line:

~/lib/nagios/plugins/check_http '-v' '-u' '/health-check' '--onredirect=follow' '--sni' '-p' '80' 'www.foobar.com'
1 Like

@gstolz oh thank you! Last time I was searching for the “onredirect” option I was not finding it. Didn’t see that is it just the scripts in the lib/nagios/plugins… Thought they are only used by “integrate Nagios plugins”. Thank you! Also for the script!

@T.Schmitz thank you too.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.