root / plugins / disk / dm_cache_statistics_ @ 16d38264
Historique | Voir | Annoter | Télécharger (2,92 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 | ca2484b3 | 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 statistics" |
||
| 75 | echo 'graph_args --base 1000' |
||
| 76 | echo 'graph_vlabel blocks/sec' |
||
| 77 | echo 'graph_category disk' |
||
| 78 | 69e88119 | Am1GO | echo "graph_info This graph shows the dm-cache cache statistics of the $CVOL cached volume." |
| 79 | 550a4f33 | Am1GO | |
| 80 | echo 'cache_read_hits.type DERIVE' |
||
| 81 | echo 'cache_read_hits.label Read hits' |
||
| 82 | echo 'cache_read_hits.info Read hits for cache' |
||
| 83 | |||
| 84 | echo 'cache_read_misses.type DERIVE' |
||
| 85 | echo 'cache_read_misses.label Read misses' |
||
| 86 | echo 'cache_read_misses.info Read misses for cache' |
||
| 87 | |||
| 88 | echo 'cache_write_hits.type DERIVE' |
||
| 89 | echo 'cache_write_hits.label Write hits' |
||
| 90 | echo 'cache_write_hits.info Write hits for cache' |
||
| 91 | |||
| 92 | echo 'cache_write_misses.type DERIVE' |
||
| 93 | echo 'cache_write_misses.label Write misses' |
||
| 94 | echo 'cache_write_misses.info Write misses for cache' |
||
| 95 | |||
| 96 | echo 'cache_demotions.type DERIVE' |
||
| 97 | echo 'cache_demotions.label Demotions' |
||
| 98 | echo 'cache_demotions.info Demotions for cache' |
||
| 99 | |||
| 100 | echo 'cache_promotions.type DERIVE' |
||
| 101 | echo 'cache_promotions.label Promotions' |
||
| 102 | echo 'cache_promotions.info Promotions for cache' |
||
| 103 | |||
| 104 | exit 0 |
||
| 105 | ;; |
||
| 106 | esac |
||
| 107 | |||
| 108 | dmstatus=$(dmsetup status $CVOL) |
||
| 109 | |||
| 110 | echo "cache_read_hits.value $(echo $dmstatus | awk '{print $8}')"
|
||
| 111 | echo "cache_read_misses.value $(echo $dmstatus | awk '{print $9}')"
|
||
| 112 | echo "cache_write_hits.value $(echo $dmstatus | awk '{print $10}')"
|
||
| 113 | echo "cache_write_misses.value $(echo $dmstatus | awk '{print $11}')"
|
||
| 114 | echo "cache_demotions.value $(echo $dmstatus | awk '{print $12}')"
|
||
| 115 | echo "cache_promotions.value $(echo $dmstatus | awk '{print $13}')"
|
