diff options
author | Sven Haardiek <sven@haardiek.de> | 2018-11-05 22:27:57 +0100 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-11-05 22:27:57 +0100 |
commit | 29d4629f55603001e25fea65e8cb593b86e58f47 (patch) | |
tree | fc984a622d48978b24d957dce83c39b4497e845c /text_collector_examples | |
parent | 764da305567809b5ad6aee8d2ccd319a645404fd (diff) | |
download | prometheus_node_collector-29d4629f55603001e25fea65e8cb593b86e58f47.tar.bz2 prometheus_node_collector-29d4629f55603001e25fea65e8cb593b86e58f47.tar.xz prometheus_node_collector-29d4629f55603001e25fea65e8cb593b86e58f47.zip |
Introduce example to get pending updates from pacman (#1114)
* Introduce example to get pending updates from pacman
Signed-off-by: Sven Haardiek <sven@haardiek.de>
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-x | text_collector_examples/pacman.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/text_collector_examples/pacman.sh b/text_collector_examples/pacman.sh new file mode 100755 index 0000000..82ac4cf --- /dev/null +++ b/text_collector_examples/pacman.sh | |||
@@ -0,0 +1,33 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # | ||
4 | # Description: Expose metrics from pacman updates | ||
5 | # If installed The bash script *checkupdates*, included with the | ||
6 | # *pacman-contrib* package, is used to calculate the number of pending updates. | ||
7 | # Otherwise *pacman* is used for calculation. | ||
8 | # | ||
9 | # Author: Sven Haardiek <sven@haardiek.de> | ||
10 | |||
11 | set -o errexit | ||
12 | set -o nounset | ||
13 | set -o pipefail | ||
14 | |||
15 | if [ -x /usr/bin/checkupdates ] | ||
16 | then | ||
17 | updates=$(/usr/bin/checkupdates | wc -l) | ||
18 | cache=0 | ||
19 | else | ||
20 | if ! updates=$(/usr/bin/pacman -Qu | wc -l) | ||
21 | then | ||
22 | updates=0 | ||
23 | fi | ||
24 | cache=1 | ||
25 | fi | ||
26 | |||
27 | echo "# HELP updates_pending number of pending updates from pacman" | ||
28 | echo "# TYPE updates_pending gauge" | ||
29 | echo "pacman_updates_pending $updates" | ||
30 | |||
31 | echo "# HELP pacman_updates_pending_from_cache pending updates information are from cache" | ||
32 | echo "# TYPE pacman_updates_pending_from_cache gauge" | ||
33 | echo "pacman_updates_pending_from_cache $cache" | ||