diff options
author | Filippo Giunchedi <filippog@users.noreply.github.com> | 2017-12-12 10:45:59 +0100 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2017-12-12 10:45:59 +0100 |
commit | af4cf20b460835721ed04147bb36f31c8b5c766f (patch) | |
tree | a76e57b75647011b275cadb1837e3ff6ca352f52 /text_collector_examples | |
parent | 1e9bb4ec3a8374b062659d49f42ab5064381ae88 (diff) | |
download | prometheus_node_collector-af4cf20b460835721ed04147bb36f31c8b5c766f.tar.bz2 prometheus_node_collector-af4cf20b460835721ed04147bb36f31c8b5c766f.tar.xz prometheus_node_collector-af4cf20b460835721ed04147bb36f31c8b5c766f.zip |
apt.sh: handle multiple origins in apt-get output (#757)
It might happen that a given upgrade comes from multiple origins, in
which case the origins are separated by ", " and thus breaking
whitespace-based split. For example:
Inst package [1.2.3] (1.2.4 Debian:8.10/oldstable, Debian-Security:8/oldstable [amd64])
To workaround this case, mangle the apt-get output to remove whitespaces from
the origins list.
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-x | text_collector_examples/apt.sh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/text_collector_examples/apt.sh b/text_collector_examples/apt.sh index 3919b7c..1dddf45 100755 --- a/text_collector_examples/apt.sh +++ b/text_collector_examples/apt.sh | |||
@@ -5,7 +5,9 @@ | |||
5 | # Author: Ben Kochie <superq@gmail.com> | 5 | # Author: Ben Kochie <superq@gmail.com> |
6 | 6 | ||
7 | upgrades="$(/usr/bin/apt-get --just-print upgrade \ | 7 | upgrades="$(/usr/bin/apt-get --just-print upgrade \ |
8 | | /usr/bin/awk '/^Inst/ {print $5, $6}' \ | 8 | | /usr/bin/awk -F'[()]' \ |
9 | '/^Inst/ { sub("^[^ ]+ ", "", $2); sub("\\[", " ", $2); | ||
10 | sub(" ", "", $2); sub("\\]", "", $2); print $2 }' | ||
9 | | /usr/bin/sort \ | 11 | | /usr/bin/sort \ |
10 | | /usr/bin/uniq -c \ | 12 | | /usr/bin/uniq -c \ |
11 | | awk '{ gsub(/\\\\/, "\\\\", $2); gsub(/\"/, "\\\"", $2); | 13 | | awk '{ gsub(/\\\\/, "\\\\", $2); gsub(/\"/, "\\\"", $2); |