arch-textcollector.sh 1.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

set -o errexit
set -o nounset

if (( $# != 1 )); then
  echo "Missing textcollector directory argument"
  exit 1
fi

TEXTFILE_COLLECTOR_DIR=${1}
PROM_FILE=$TEXTFILE_COLLECTOR_DIR/pacman.prom

TMP_FILE=$PROM_FILE.$$
[ -e $TMP_FILE ] && rm -f $TMP_FILE

trap "rm -f $TMP_FILE" EXIT

updates=$(/usr/bin/checkupdates | wc -l)
secupdates=$(/usr/bin/arch-audit -u | wc -l)
21
orphans=$(/usr/bin/pacman -Qdttq | wc -l)
22
foreigns=$(/usr/bin/pacman -Qmq | wc -l)
23
pacnew=$(/usr/bin/pacdiff -o | wc -l)
24
25
26

echo "# HELP pacman_updates_pending number of pending updates from pacman" >> $TMP_FILE
echo "# TYPE pacman_updates_pending gauge" >> $TMP_FILE
27
echo "pacman_updates_pending $updates" >> $TMP_FILE
28
29
30

echo "# HELP pacman_security_updates_pending number of pending updates from pacman" >> $TMP_FILE
echo "# TYPE pacman_security_updates_pending gauge" >> $TMP_FILE
31
echo "pacman_security_updates_pending $secupdates" >> $TMP_FILE
32

33
34
35
36
37
38
39
40
echo "# HELP pacman_orphans number of orphan packages from pacman" >> $TMP_FILE
echo "# TYPE pacman_orphans gauge" >> $TMP_FILE
echo "pacman_orphans $orphans" >> $TMP_FILE

echo "# HELP pacman_foreigns number of foreign packages from pacman" >> $TMP_FILE
echo "# TYPE pacman_foreigns gauge" >> $TMP_FILE
echo "pacman_foreigns $foreigns" >> $TMP_FILE

41
42
43
44
echo "# HELP pacman_pacnew number of pacnew/pacsave files" >> $TMP_FILE
echo "# TYPE pacman_pacnew gauge" >> $TMP_FILE
echo "pacman_pacnew $pacnew" >> $TMP_FILE

45
mv -f $TMP_FILE $PROM_FILE