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

deb-lastactivity: returns Unable to get dpkg-query info, maybe an update never happened. #743

Closed withanhdammit closed 4 months ago

withanhdammit commented 4 months ago

This issue respects the following points:

Which variant of the Monitoring Plugins do you use?

Bug description

When calling this (installed via director) it returns

Unable to get dpkg-query info, maybe an update never happened. Traceback (most recent call last): File "deb-lastactivity.py", line 85, in main ValueError: invalid literal for int() with base 10: 'icingaweb2-common'

Steps to reproduce - Plugin call

/usr/lib64/nagios/plugins/deb-lastactivity

Steps to reproduce - Data

Unable to get dpkg-query info, maybe an update never happened. Traceback (most recent call last): File "deb-lastactivity.py", line 85, in main ValueError: invalid literal for int() with base 10: 'icingaweb2-common'

Environment

uname -a

Linux frigate 6.5.0-0.deb12.4-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.10-1~bpo12+1 (2023-11-23) x86_64 GNU/Linux

Plugin Version

deb-lastactivity: v2023112901 by Linuxfabrik GmbH, Zurich/Switzerland

Python version

No response

List of Python modules

No response

Additional Information

No response

markuslf commented 4 months ago

What output do you get running dpkg-query --show --showformat='${db-fsys:Last-Modified} ${Package}\n'?

withanhdammit commented 4 months ago

Sorry, I didn't get the notification. This is a trim of the output:

sudo dpkg-query --show --showformat='${db-fsys:Last-Modified} ${Package}\n' [sudo] password for user: 1702081306 adduser 1702081330 alsa-topology-conf 1702081330 alsa-ucm-conf 1702083656 amd64-microcode 1702081710 apache2 1702081714 apache2-bin 1702081711 apache2-data 1702081331 apache2-doc 1702083071 apache2-suexec-pristine 1702081711 apache2-utils 1702083072 apparmor 1702083072 appstream 1702081716 apt 1702077209 apt-listchanges 1702081331 apt-transport-https 1702081718 apt-utils 1702083057 aspell 1702081331 aspell-en 1702083068 attr 1707601160 base-files 1702081720 base-passwd 1702081702 bash 1702081327 bash-completion 1702081332 bc 1708747954 bind9-dnsutils 1708747954 bind9-host 1708747954 bind9-libs 1702081682 binutils 1702081685 binutils-common 1702081684 binutils-x86-64-linux-gnu 1702083071 bsdextrautils 1702081702 bsdutils 1702077780 build-essential 1702083029 busybox 1702081694 bzip2

markuslf commented 4 months ago

Seems that the plugin is working but it fails because of sudo. Did you configure sudo properly?

withanhdammit commented 4 months ago

All the other commands that use sudo work properly

markuslf commented 4 months ago

The plugin says ValueError: invalid literal for int() with base 10: 'icingaweb2-common', but I am missing the interesting part of your output because of your trimming. It would be good to know what happens around that line (just ~10 lines around icingaweb2-common).

withanhdammit commented 4 months ago

That definitely looks odd, but I don't know what it means. Like "why don't those three packages have numbers next to them?" Should I reinstall those packages?

OK, so looking at the command, that's last modified (date). Still unsure why those three packages don't show a date.

1619017839 hicolor-icon-theme 1702081704 hostname 1702083105 htop 1702077858 i965-va-driver 1702083106 iamerican 1702083106 ibritish 1702083106 ibverbs-providers 1706389537 icinga2 1706389537 icinga2-bin 1706389538 icinga2-common 1706389538 icinga2-doc icinga2-ido-mysql icingaweb2 icingaweb2-common 1702083106 ienglish-common 1702081689 ifupdown 1708747955 imagemagick 1708747953 imagemagick-6-common 1708747955 imagemagick-6.q16 1702083071 inetutils-telnet 1702081301 init 1702081712 init-system-helpers 1702083029 initramfs-tools 1702083030 initramfs-tools-core

withanhdammit commented 4 months ago

I reinstalled the three applications and the issue is resolved.

sudo apt install icinga2-ido-mysql icingaweb2 icingaweb2-common --reinstall
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  dbconfig-common icinga-l10n icinga-php-library icinga-php-thirdparty icingacli php php-icinga php-mysql php-pgsql php8.3 php8.3-mysql php8.3-pgsql
Suggested packages:
  dbconfig-mysql | dbconfig-pgsql | dbconfig-sqlite3 | dbconfig-no-thanks default-mysql-server | mysql-server
The following NEW packages will be installed:
  dbconfig-common icinga-l10n icinga-php-library icinga-php-thirdparty icinga2-ido-mysql icingacli icingaweb2 icingaweb2-common php php-icinga
  php-mysql php-pgsql php8.3 php8.3-mysql php8.3-pgsql

And the 'dpkg-query' is showing valid dates now as well.

sudo dpkg-query --show --showformat='${db-fsys:Last-Modified} ${Package}\n' | grep icinga
1708924252 icinga-l10n
1708924252 icinga-php-library
1708924253 icinga-php-thirdparty
1706389537 icinga2
1706389537 icinga2-bin
1706389538 icinga2-common
1706389538 icinga2-doc
1708924253 icinga2-ido-mysql
1708924254 icingacli
1708924254 icingaweb2
1708924253 icingaweb2-common
1708924254 php-icinga
markuslf commented 4 months ago

Based on your report, I improved the plugin. It now warns if the last modified timestamp is not found for one or more packages.

withanhdammit commented 4 months ago

Cool! Thanks for updating it!