Apt agent plugin conf with unattended-upgrades

Hey!

I am using the apt plugin on Debian based hosts Monitoring system updates with APT plug-in in Checkmk #CMKTutorial - YouTube

I have daily unattended-upgrades for security updates configured.

I cannot set a time when the checkmk plugin is running, only an interval.

/lib/systemd/system/apt-daily-upgrade.timer

[Unit]
Description=Daily apt upgrade and clean activities
After=apt-daily.timer

[Timer]
OnCalendar=--* 6:00
RandomizedDelaySec=60m

Upgrades are installed between 6 and 7.

That means, if there is a new version between the last upgrade and the run of the plugin, the check goes CRIT. e.g.: 06:00-07:00 upgrade, new security update published at 10:00, plugin runs at 14:00

So it would be green the next day if the check runs daily, so a naive solution would be to set the notification trigger to 25h.

However, if it is the same case (new version after upgrade) then the check will still be CRIT even though the upgrade was done successfully.

How to configure the check sensibly to minimize false positives?

Thanks!

Easy solution would be a apt config file like this inside /etc/apt/apt.conf.d/

DPkg::Post-Invoke {"find /var/lib/check_mk_agent/cache/ -name '*mk_apt*' -exec rm {} \;";};

or this if you use the new folder structure

DPkg::Post-Invoke {"find /opt/checkmk/agent/default/runtime/cache/ -name '*mk_apt.cache' -exec rm {} \;";};

These line clear the plugin cache after installing any type of update.

Hi @it-native ,

please have a look. This maybe helps.

“System Updates (Windows)” rule: optional “Start time (HH:MM)”, same as on Linux. The plug-in schedules itself and replays its last result in between…

the apt plugin caches the last result so it will keep reportting the old version until the next run you could clear the cache in a post invoke as suggested or just extend the check interval to somthing like 12h to avoid the window where a new security update appears after the upgrade and before the next check does it make sense to just run the check after the upgrade timer instead of relying on the cache?