Linuxfabrik / monitoring-plugins

200+ check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.
https://linuxfabrik.ch
The Unlicense
207 stars 48 forks source link

apt-get: Add a plugin which checks for the availability of updates on Debian based systems #755

Open mrmolybdaen opened 3 months ago

mrmolybdaen commented 3 months ago

Describe the solution you'd like

Hello together,

In addition to the deb-lastactivity plugin I would be pleased if the monitoring plugins could introduce a plugin apt/apt-get which could inform about pending updates like the check_apt plugin provided by the Debian Nagios Maintainer Group does.

The check provided by them can optionally do an apt-get update to refresh the apt cache. It returns a list with upgradable packages, marking packages from Debian's or Ubuntu's security repos with "(security)", looking a bit like this:

APT CRITICAL: 3 packages available for dist-upgrade (1 critical updates).
runc (security)
php8.3-common
php8.3-mysql

Given there is a Python API for APT provided by the APT Developers (maintained here: python-apt, documented there) I thought it might be a good idea to use it instead of wildly regexing command line calls. So I started playing around.

The API might be counterintuitive and the resulting script is not really fast (could be caused by my implementation using all the apt caches) but I managed to create something myself resembling the original a bit. What do you think?

Kind regards Christian

Additional context

Work in progress, currently missing tests: https://github.com/mrmolybdaen/monitoring-plugins/tree/check_apt/check-plugins/apt-get

markuslf commented 2 months ago

It looks pretty good and fits very well into the collection. If you are interested in feedback on the code, how can I best contact you?

mrmolybdaen commented 2 months ago

Feedback on the code would be highly appreciated. At the moment e-mail or of course Github would work the best. But I am unsure of how to share contact information securely - maybe a gist would do fine?

markuslf commented 2 months ago

You can contact us at info [at] linuxfabrik [dot] ch.