diff options
Diffstat (limited to 'text_collector_examples/apt.sh')
-rwxr-xr-x | text_collector_examples/apt.sh | 32 |
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 | |||
7 | upgrades="$(/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 | |||
18 | echo '# HELP apt_upgrades_pending Apt package pending updates by origin.' | ||
19 | echo '# TYPE apt_upgrades_pending gauge' | ||
20 | if [[ -n "${upgrades}" ]] ; then | ||
21 | echo "${upgrades}" | ||
22 | else | ||
23 | echo 'apt_upgrades_pending{origin="",arch=""} 0' | ||
24 | fi | ||
25 | |||
26 | echo '# HELP node_reboot_required Node reboot is required for software updates.' | ||
27 | echo '# TYPE node_reboot_required gauge' | ||
28 | if [[ -f '/run/reboot-required' ]] ; then | ||
29 | echo 'node_reboot_required 1' | ||
30 | else | ||
31 | echo 'node_reboot_required 0' | ||
32 | fi | ||