Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / system / systemd_units @ d0216f00

Historique | Voir | Annoter | Télécharger (1,32 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
	tmp=$(systemctl --no-pager --no-legend --all | awk '{print $1, $3}')
64
	for state in $states ; do
65
		count=$(echo "$tmp" | grep -c "$state$")
66
		echo "$state.value $count"
67
		extinfo=$(echo "$tmp" | grep "$state$" | cut -d " " -f 1 | tr '\n' ' ')
68
		if [ -n "$extinfo" ]; then
69
			echo "$state.extinfo" "$extinfo"
70
		fi
71
	done
72
}
73

    
74
case $1 in
75
	"autoconf")
76
		autoconf
77
		;;
78
	"config")
79
		config
80
		;;
81
	*)
82
		fetch
83
		;;
84
esac