Force check exit code

I am migrating over to use the native icinga2 agent (from nrpe), but there is one trick i have not been able to replicate. In nrpe I would configure the following command on the agent.

command[check_apt]=/usr/lib/nagios/plugins/check_apt || true

this forced the check to always have return code 0, meaning i get the check results but it never goes crit or warn (and without having to have it in downtime/ack’ed)

I tried setting up a parameters in the CheckCommand object

“–no-alert” = { set_if = “$check_apt_no_alert$”
key = “|| true”
order = 99
}

but this does not produce the desired behaviour.
If there any way to do this using the icinga2 agent and check commands?
or do I have to modify the actual check script?

Thanks

Hello,
I’m not sure you can force a check exit code outside of a dummy check or process-check-result, however you could create a wrapper script that exit 0 whatever command you use if you dont want to edit the actual check script, but it requires you to write new checkcommands.

I used a wrapper script

prog=/usr/lib/nagios/plugins/check_apt
"$prog" "$@"
exit 0