Add orphans apt packages metric
parent
3c2f218a2f
commit
e55bef009a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue