File: pacman.sh

package info (click to toggle)
prometheus-node-exporter 0.17.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,576 kB
  • sloc: ansic: 1,377; sh: 868; python: 304; makefile: 182; awk: 60; asm: 2
file content (33 lines) | stat: -rwxr-xr-x 884 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"