Projet

Général

Profil

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

root / plugins / disk / dm_cache_occupancy_ @ 64089240

Historique | Voir | Annoter | Télécharger (2,67 ko)

1 550a4f33 Am1GO
#!/bin/bash
2
# -*- sh -*-
3
4
: << =cut
5
6
=head1 NAME
7
8
dm_cache_occupancy_ - Wildcard-plugin to dm-cache occupancy.
9
10
=head1 CONFIGURATION
11
12
This plugin does not normally require configuration.
13
14
The plugin may need to run as root to determine dm-cache status.
15
This is configured like this:
16
17
  [dm_cache_*]
18
	  user root
19
20
This is a wildcard plugin. To monitor a cached device-mapper volume,
21
link volume to this file. For example,
22
23
  ln -s /usr/share/munin/plugins/dm_cache_occupancy_ \
24
        /etc/munin/plugins/dm_cache_occupancy_vg_1122____lv_home
25
26
will monitor vg_1122-lv_home.
27
28
Please note that ____ (4 underscores) is replaced by - (dash) symbol.
29
This is workaround for http://munin-monitoring.org/ticket/1236
30
31
Cached volumes found in dmsetup status can be monitored.
32
33
=head1 AUTHOR
34
35
Original idea: Steinar H. Gunderson <sgunderson@bigfoot.com>
36
Found in Google by keywords "munin dm-cache"
37
38
Copyright (C) 2014 Vladimir Stackov <amigo.elite@gmail.com>
39
40
=head1 LICENSE
41
42
GPLv2
43
44
=head1 MAGIC MARKERS
45
46
 #%# family=auto
47
 #%# capabilities=autoconf suggest
48
49
=cut
50
51
CVOL=${0##*dm_cache_occupancy_}
52
#workaround for http://munin-monitoring.org/ticket/1236
53 58e37130 zivillian
while [[ $CVOL == *"____"* ]]
54
do
55
	CVOL=${CVOL/____/-}
56
done
57 550a4f33 Am1GO
58
case $1 in
59
	autoconf)
60
		env dmsetup status > /dev/null 2>&1
61
		if [[ $? -eq 0 ]]; then
62
			echo yes
63
			exit 0
64
		else
65
			echo "no (env dmsetup returned value > 0)"
66
			exit 0
67
		fi
68
		;;
69
	suggest)
70
		dmsetup status | grep ' cache ' | awk -F: '{print $1}'
71
		exit $?
72
		;;
73
	config)
74
		echo "graph_title $CVOL dm-cache cache occupancy"
75
		echo 'graph_args --base 1000'
76
		echo 'graph_vlabel blocks'
77
		echo 'graph_category disk'
78 69e88119 Am1GO
		echo "graph_info This graph shows the dm-cache cache occupancy of the $CVOL cached volume."
79 550a4f33 Am1GO
		echo 'cache_used_metadata.label Used metadata'
80
		echo 'cache_used_metadata.info Used metadata blocks for cache'
81
		echo 'cache_total_metadata.label Total metadata'
82
		echo 'cache_total_metadata.info Total metadata blocks for cache'
83
		echo 'cache_used_blocks.label Used blocks'
84
		echo 'cache_used_blocks.info Used blocks in cache for cache'
85
		echo 'cache_total_blocks.label Total blocks'
86
		echo 'cache_total_blocks.info Total blocks in cache for cache'
87
		echo 'cache_dirty.label Dirty blocks'
88
		echo 'cache_dirty.info Dirty blocks for cache'
89
90
		exit 0
91
		;;
92
esac
93
94
dmstatus=$(dmsetup status $CVOL)
95
96
echo "cache_used_metadata.value $(echo $dmstatus | awk '{print $5}' | awk -F/ '{print $1}')"
97
echo "cache_total_metadata.value $(echo $dmstatus | awk '{print $5}' | awk -F/ '{print $2}')"
98
echo "cache_used_blocks.value $(echo $dmstatus | awk '{print $7}' | awk -F/ '{print $1}')"
99
echo "cache_total_blocks.value $(echo $dmstatus | awk '{print $7}' | awk -F/ '{print $2}')"
100
echo "cache_dirty.value $(echo $dmstatus | awk '{print $14}')"