Skip to content
Snippets Groups Projects
Verified Commit e55bef00 authored by me5na7qbjqbrp's avatar me5na7qbjqbrp
Browse files

Add orphans apt packages metric

parent 3c2f218a
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,13 @@ autoremove="$(/usr/bin/apt-get --just-print autoremove \
| /usr/bin/awk '/^Remv/{a++}END{printf "apt_autoremove_pending %d", a}'
)"
orphans="$(comm -23 \
<(dpkg-query -W -f '${db:Status-Abbrev}\t${Package}\n' \
| grep '^.[^nc]' | cut -f2 | sort) \
<(apt-cache dumpavail | sed -rn 's/^Package: (.*)/\1/p' | sort -u) \
| awk 'END{printf "apt_orphans %d", NR}'
)"
echo '# HELP apt_upgrades_pending Apt package pending updates by origin.'
echo '# TYPE apt_upgrades_pending gauge'
if [[ -n "${upgrades}" ]] ; then
......@@ -31,6 +38,10 @@ echo '# HELP apt_autoremove_pending Apt package pending autoremove.'
echo '# TYPE apt_autoremove_pending gauge'
echo "${autoremove}"
echo '# HELP apt_orphans Orphan apt package.'
echo '# TYPE apt_orphans gauge'
echo "${orphans}"
echo '# HELP node_reboot_required Node reboot is required for software updates.'
echo '# TYPE node_reboot_required gauge'
if [[ -f '/run/reboot-required' ]] ; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment