root / plugins / other / zfs-stats-for-freebsd-arc-utilization @ cf0bc19b
Historique | Voir | Annoter | Télécharger (1,54 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# -*- sh -*- |
| 3 |
# |
| 4 |
# $Id: zfs_arc_utilization 11 2010-11-25 07:10:14Z patpro $ |
| 5 |
# |
| 6 |
# Parameters: |
| 7 |
# |
| 8 |
# config (required) |
| 9 |
# autoconf (optional - used by munin-config) |
| 10 |
# |
| 11 |
# Magick markers (optional - used by munin-config and som installation |
| 12 |
# scripts): |
| 13 |
#%# family=auto |
| 14 |
#%# capabilities=autoconf |
| 15 |
|
| 16 |
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
| 17 |
|
| 18 |
# autoconf |
| 19 |
|
| 20 |
if [ "$1" = "autoconf" ]; then |
| 21 |
# Is the zfs-stats executable there at least ? |
| 22 |
if [ -x /usr/local/bin/zfs-stats ]; then |
| 23 |
if /usr/local/bin/zfs-stats -p > /dev/null 2>&1; then |
| 24 |
echo yes |
| 25 |
exit 0 |
| 26 |
else |
| 27 |
echo "no" |
| 28 |
exit 0 |
| 29 |
fi |
| 30 |
else |
| 31 |
echo "no (no /usr/local/bin/zfs-stats executable)" |
| 32 |
exit 0 |
| 33 |
fi |
| 34 |
fi |
| 35 |
|
| 36 |
# config |
| 37 |
if [ "$1" = "config" ]; then |
| 38 |
echo 'graph_title ZFS ARC Size' |
| 39 |
echo 'graph_args -l 0' |
| 40 |
echo 'graph_vlabel Size in MB' |
| 41 |
echo 'graph_category ZFS' |
| 42 |
echo 'graph_info This graph shows the ARC Size utilization' |
| 43 |
|
| 44 |
/usr/local/bin/zfs-stats -A | awk 'BEGIN { RS = "" ; FS = "\n" } /^ARC Size/ {print}' | \
|
| 45 |
awk '/^\t/ {sub("\t","");sub(/ \(.*\):.*/,""); displayname = $0; gsub(/[ .]/,"_",$0); print $0".label "displayname"\n"$0".min 0"}'
|
| 46 |
|
| 47 |
exit 0 |
| 48 |
fi |
| 49 |
|
| 50 |
# This is the main part of the script, basically it calls |
| 51 |
# /usr/local/bin/zfs-stats and processes its output |
| 52 |
|
| 53 |
/usr/local/bin/zfs-stats -A | awk 'BEGIN { RS = "" ; FS = "\n" } /^ARC Size/ {print}' | \
|
| 54 |
sed -e 's, ,,' -e 's, ,_,g' -e 's,\._,__,' -e 's,_(.*):., ,' -e 's, , ,g' -e 's,\([A-Za-z_]*\) *[^ ]* \([0-9.]*\)M,\1.value \2,' | grep value |
