Projet

Général

Profil

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

root / plugins / disk / dm_cache_statistics_ @ c3660c2a

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

1 550a4f33 Am1GO
#!/bin/bash
2
# -*- sh -*-
3
4
: << =cut
5
6
=head1 NAME
7
8
dm_cache_statistics_ - Wildcard-plugin to dm-cache statistics.
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_statistics_ \
24
        /etc/munin/plugins/dm_cache_statistics_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_statistics_}
52
#workaround for http://munin-monitoring.org/ticket/1236
53
CVOL=${CVOL/____/-}
54
55
case $1 in
56
	autoconf)
57
		env dmsetup status > /dev/null 2>&1
58
		if [[ $? -eq 0 ]]; then
59
			echo yes
60
			exit 0
61
		else
62
			echo "no (env dmsetup returned value > 0)"
63
			exit 0
64
		fi
65
		;;
66
	suggest)
67
		dmsetup status | grep ' cache ' | awk -F: '{print $1}'
68
		exit $?
69
		;;
70
	config)
71
		echo "graph_title $CVOL dm-cache cache statistics"
72
		echo 'graph_args --base 1000'
73
		echo 'graph_vlabel blocks/sec'
74
		echo 'graph_category disk'
75 69e88119 Am1GO
		echo "graph_info This graph shows the dm-cache cache statistics of the $CVOL cached volume."
76 550a4f33 Am1GO
77
		echo 'cache_read_hits.type DERIVE'
78
		echo 'cache_read_hits.label Read hits'
79
		echo 'cache_read_hits.info Read hits for cache'
80
81
		echo 'cache_read_misses.type DERIVE'
82
		echo 'cache_read_misses.label Read misses'
83
		echo 'cache_read_misses.info Read misses for cache'
84
85
		echo 'cache_write_hits.type DERIVE'
86
		echo 'cache_write_hits.label Write hits'
87
		echo 'cache_write_hits.info Write hits for cache'
88
89
		echo 'cache_write_misses.type DERIVE'
90
		echo 'cache_write_misses.label Write misses'
91
		echo 'cache_write_misses.info Write misses for cache'
92
93
		echo 'cache_demotions.type DERIVE'
94
		echo 'cache_demotions.label Demotions'
95
		echo 'cache_demotions.info Demotions for cache'
96
97
		echo 'cache_promotions.type DERIVE'
98
		echo 'cache_promotions.label Promotions'
99
		echo 'cache_promotions.info Promotions for cache'
100
101
		exit 0
102
		;;
103
esac
104
105
dmstatus=$(dmsetup status $CVOL)
106
107
echo "cache_read_hits.value $(echo $dmstatus | awk '{print $8}')"
108
echo "cache_read_misses.value $(echo $dmstatus | awk '{print $9}')"
109
echo "cache_write_hits.value $(echo $dmstatus | awk '{print $10}')"
110
echo "cache_write_misses.value $(echo $dmstatus | awk '{print $11}')"
111
echo "cache_demotions.value $(echo $dmstatus | awk '{print $12}')"
112
echo "cache_promotions.value $(echo $dmstatus | awk '{print $13}')"