root / plugins / system / systemd @ ef80db4b
Historique | Voir | Annoter | Télécharger (1,49 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# -*- sh -*- |
| 3 |
|
| 4 |
: << =cut |
| 5 |
|
| 6 |
=head1 NAME |
| 7 |
|
| 8 |
systemd - Plugin to monitor systemd units state |
| 9 |
|
| 10 |
=head1 APPLICABLE SYSTEMS |
| 11 |
|
| 12 |
Linux systems with systemd installed. |
| 13 |
|
| 14 |
=head1 CONFIGURATION |
| 15 |
|
| 16 |
None needed. |
| 17 |
|
| 18 |
=head1 AUTHOR |
| 19 |
|
| 20 |
Olivier Mehani <shtrom+munin@ssji.net> |
| 21 |
|
| 22 |
=head1 LICENSE |
| 23 |
|
| 24 |
GPLv2 |
| 25 |
|
| 26 |
=head1 MAGIC MARKERS |
| 27 |
|
| 28 |
#%# family=auto |
| 29 |
#%# capabilities=autoconf |
| 30 |
|
| 31 |
=cut |
| 32 |
|
| 33 |
states="active \ |
| 34 |
reloading \ |
| 35 |
inactive \ |
| 36 |
failed \ |
| 37 |
activating \ |
| 38 |
deactivating" |
| 39 |
autoconf() {
|
| 40 |
which systemctl >/dev/null && \ |
| 41 |
systemctl --state=failed --no-pager --no-legend >/dev/null 2>&1 && echo yes || echo "no (No systemctl or error running it)" |
| 42 |
} |
| 43 |
|
| 44 |
config () {
|
| 45 |
cat << EOF |
| 46 |
graph_title Systemd units state |
| 47 |
graph_args -l 0 |
| 48 |
graph_category system |
| 49 |
graph_scale no |
| 50 |
graph_vlabel units |
| 51 |
EOF |
| 52 |
for state in $states; do |
| 53 |
echo "$state.label $state" |
| 54 |
echo "$state.draw AREASTACK" |
| 55 |
if [ $state = failed ]; then |
| 56 |
echo "$state.warning 0" |
| 57 |
echo "$state.critical 10" |
| 58 |
fi |
| 59 |
done |
| 60 |
} |
| 61 |
|
| 62 |
fetch () {
|
| 63 |
case $1 in |
| 64 |
"units") |
| 65 |
tmp=`mktemp -t munin-systemd.XXXXXX` |
| 66 |
systemctl --no-pager --no-legend --all | awk '{print $1, $3}' > $tmp
|
| 67 |
for state in \ |
| 68 |
$states ; do |
| 69 |
echo -n "$state.value " |
| 70 |
grep $state$ $tmp | wc -l |
| 71 |
extinfo=`grep $state$ $tmp | cut -d " " -f 1` |
| 72 |
if [ "$extinfo" ]; then |
| 73 |
echo "$state.extinfo" $extinfo |
| 74 |
fi |
| 75 |
done |
| 76 |
rm $tmp |
| 77 |
;; |
| 78 |
"*") |
| 79 |
echo "$0: unknown mode '$1'" >&2 |
| 80 |
exit 1 |
| 81 |
esac |
| 82 |
} |
| 83 |
|
| 84 |
# mode=`echo $0 | sed 's/.*_//'` |
| 85 |
mode=units |
| 86 |
|
| 87 |
case $1 in |
| 88 |
"autoconf") |
| 89 |
autoconf |
| 90 |
;; |
| 91 |
"config") |
| 92 |
config $mode |
| 93 |
;; |
| 94 |
*) |
| 95 |
fetch $mode |
| 96 |
;; |
| 97 |
esac |
