aboutsummaryrefslogtreecommitdiff
path: root/text_collector_examples/apt.sh
diff options
context:
space:
mode:
Diffstat (limited to 'text_collector_examples/apt.sh')
-rwxr-xr-xtext_collector_examples/apt.sh32
1 files changed, 0 insertions, 32 deletions
diff --git a/text_collector_examples/apt.sh b/text_collector_examples/apt.sh
deleted file mode 100755
index 171bb0a..0000000
--- a/text_collector_examples/apt.sh
+++ /dev/null
@@ -1,32 +0,0 @@
1#!/bin/bash
2#
3# Description: Expose metrics from apt updates.
4#
5# Author: Ben Kochie <superq@gmail.com>
6
7upgrades="$(/usr/bin/apt-get --just-print upgrade \
8 | /usr/bin/awk -F'[()]' \
9 '/^Inst/ { sub("^[^ ]+ ", "", $2); gsub(" ","",$2);
10 sub("\\[", " ", $2); sub("\\]", "", $2); print $2 }' \
11 | /usr/bin/sort \
12 | /usr/bin/uniq -c \
13 | awk '{ gsub(/\\\\/, "\\\\", $2); gsub(/\"/, "\\\"", $2);
14 gsub(/\[/, "", $3); gsub(/\]/, "", $3);
15 print "apt_upgrades_pending{origin=\"" $2 "\",arch=\"" $3 "\"} " $1}'
16)"
17
18echo '# HELP apt_upgrades_pending Apt package pending updates by origin.'
19echo '# TYPE apt_upgrades_pending gauge'
20if [[ -n "${upgrades}" ]] ; then
21 echo "${upgrades}"
22else
23 echo 'apt_upgrades_pending{origin="",arch=""} 0'
24fi
25
26echo '# HELP node_reboot_required Node reboot is required for software updates.'
27echo '# TYPE node_reboot_required gauge'
28if [[ -f '/run/reboot-required' ]] ; then
29 echo 'node_reboot_required 1'
30else
31 echo 'node_reboot_required 0'
32fi