mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
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>
This commit is contained in:
parent
764da30556
commit
29d4629f55
33
text_collector_examples/pacman.sh
Executable file
33
text_collector_examples/pacman.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#
|
||||
# Description: Expose metrics from pacman updates
|
||||
# If installed The bash script *checkupdates*, included with the
|
||||
# *pacman-contrib* package, is used to calculate the number of pending updates.
|
||||
# Otherwise *pacman* is used for calculation.
|
||||
#
|
||||
# Author: Sven Haardiek <sven@haardiek.de>
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [ -x /usr/bin/checkupdates ]
|
||||
then
|
||||
updates=$(/usr/bin/checkupdates | wc -l)
|
||||
cache=0
|
||||
else
|
||||
if ! updates=$(/usr/bin/pacman -Qu | wc -l)
|
||||
then
|
||||
updates=0
|
||||
fi
|
||||
cache=1
|
||||
fi
|
||||
|
||||
echo "# HELP updates_pending number of pending updates from pacman"
|
||||
echo "# TYPE updates_pending gauge"
|
||||
echo "pacman_updates_pending $updates"
|
||||
|
||||
echo "# HELP pacman_updates_pending_from_cache pending updates information are from cache"
|
||||
echo "# TYPE pacman_updates_pending_from_cache gauge"
|
||||
echo "pacman_updates_pending_from_cache $cache"
|
Loading…
Reference in a new issue