aboutsummaryrefslogtreecommitdiff
path: root/text_collector_examples
diff options
context:
space:
mode:
authorSven Haardiek <sven@haardiek.de>2018-11-05 22:27:57 +0100
committerBen Kochie <superq@gmail.com>2018-11-05 22:27:57 +0100
commit29d4629f55603001e25fea65e8cb593b86e58f47 (patch)
treefc984a622d48978b24d957dce83c39b4497e845c /text_collector_examples
parent764da305567809b5ad6aee8d2ccd319a645404fd (diff)
downloadprometheus_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-xtext_collector_examples/pacman.sh33
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
11set -o errexit
12set -o nounset
13set -o pipefail
14
15if [ -x /usr/bin/checkupdates ]
16then
17 updates=$(/usr/bin/checkupdates | wc -l)
18 cache=0
19else
20 if ! updates=$(/usr/bin/pacman -Qu | wc -l)
21 then
22 updates=0
23 fi
24 cache=1
25fi
26
27echo "# HELP updates_pending number of pending updates from pacman"
28echo "# TYPE updates_pending gauge"
29echo "pacman_updates_pending $updates"
30
31echo "# HELP pacman_updates_pending_from_cache pending updates information are from cache"
32echo "# TYPE pacman_updates_pending_from_cache gauge"
33echo "pacman_updates_pending_from_cache $cache"