Skip to content

Commit

Permalink
Add mk_apt_hook for automatic cache handling after package installations
Browse files Browse the repository at this point in the history
Checkmk treasures provide some useful scripts, see:

* i.e. /opt/omd/versions/2.0.0p23.cre/share/doc/check_mk/treasures
* https://github.com/tribe29/checkmk/blob/master/doc/treasures

When mk_apt_hook is installed in /etc/apt/apt.conf.d/ then after every
package installation (included updates) the cache file gets adjusted so
we don't have outdated cache information. This is useful especially when
installing outstanding security updates, then after they get applied
monitoring status corresponds to what's actually present on the system
(instead of dealing with outdated cache files).

Adapted the provided sample and touch
/var/lib/check_mk_agent/cache/*mk_apt.cache only if directory exists.

Thx @mikagrml for the hint with this checkmk treasure.
  • Loading branch information
jkirk committed Jul 7, 2022
1 parent 84df8dd commit 009e3e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions files/check-mk/mk_apt_hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# HEADER: managed by ansible, do NOT edit manually!
# retrigger mk-apt
#
# If you want use this hook, copy this file to:
# /etc/apt/apt.conf.d/98mk-apt.
#
# For further details please consult the check manual page of apt.

DPkg::Post-Invoke {"test -d /var/lib/check_mk_agent/cache && touch -t 197012181200 /var/lib/check_mk_agent/cache/*mk_apt.cache"; };
8 changes: 8 additions & 0 deletions tasks/checkmk-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
group: 'root'
mode: 0755

- name: Deploy mk_apt_hook for usage with checkmk agent plugin mk_apt
copy:
src: 'check-mk/mk_apt_hook'
dest: '/etc/apt/apt.conf.d/98mk-apt'
mode: 0644
owner: root
group: root

### checkmk agent plugins

- name: "Deploy checkmk agent plugins"
Expand Down

0 comments on commit 009e3e3

Please sign in to comment.