root / plugins / zfs / zfs_list @ d41a94b1
Historique | Voir | Annoter | Télécharger (3,07 ko)
| 1 | cb6c9595 | amichel | #!/bin/bash |
|---|---|---|---|
| 2 | #%# family=auto |
||
| 3 | |||
| 4 | 4612c1bc | Michael Grote | : << EOF |
| 5 | =head1 NAME |
||
| 6 | zfs_list - Plugin to monitor ZFS Filesystems |
||
| 7 | |||
| 8 | This is an extension of the zfs_fs plugin |
||
| 9 | modified as a multigraph to graph all zfs |
||
| 10 | filesystems it can find |
||
| 11 | |||
| 12 | =head1 CONFIGURATION |
||
| 13 | d41a94b1 | Michael Grote | [zfs_list] |
| 14 | env.ignore_datasets_pattern <Datasets to ignore; String for grep> |
||
| 15 | 4612c1bc | Michael Grote | |
| 16 | |||
| 17 | =head1 AUTHOR |
||
| 18 | d41a94b1 | Michael Grote | |
| 19 | Adam Michel (elfurbe@furbism.com) |
||
| 20 | 4612c1bc | Michael Grote | |
| 21 | |||
| 22 | =head1 MAGIC MARKERS |
||
| 23 | d41a94b1 | Michael Grote | |
| 24 | #%# family=auto |
||
| 25 | |||
| 26 | 4612c1bc | Michael Grote | =cut |
| 27 | |||
| 28 | EOF |
||
| 29 | |||
| 30 | |||
| 31 | f6dbe9bd | Sephtex | . "$MUNIN_LIBDIR/plugins/plugin.sh" |
| 32 | |||
| 33 | cb6c9595 | amichel | need_multigraph() |
| 34 | |||
| 35 | if [ "$1" = "autoconf" ]; then |
||
| 36 | # Makes little sense to autoconf if you can't suggest |
||
| 37 | echo no |
||
| 38 | exit 0 |
||
| 39 | fi |
||
| 40 | |||
| 41 | if [ "$1" = "suggest" ]; then |
||
| 42 | exit 0 |
||
| 43 | fi |
||
| 44 | |||
| 45 | 4612c1bc | Michael Grote | # set standard value |
| 46 | ignore_datasets_pattern=${ignore_datasets_pattern:-}
|
||
| 47 | |||
| 48 | # set search term, based on if the searh pattern is set |
||
| 49 | if [ -n "$ignore_datasets_pattern" ]; then |
||
| 50 | search_term=$(zfs list -Hp -t filesystem,volume | grep -v "$ignore_datasets_pattern" | awk '{print $1}')
|
||
| 51 | else |
||
| 52 | search_term=$(zfs list -Hp -t filesystem,volume | awk '{print $1}')
|
||
| 53 | fi |
||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | cb6c9595 | amichel | if [ "$1" = "config" ]; then |
| 58 | 4612c1bc | Michael Grote | for i in $search_term; do |
| 59 | cb6c9595 | amichel | values=( $(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota $i | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}') )
|
| 60 | f72390cb | Sephtex | fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g')) |
| 61 | cb6c9595 | amichel | |
| 62 | echo <<EOF "multigraph zfs_list_$fsname |
||
| 63 | graph_title $fsname usage |
||
| 64 | graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota |
||
| 65 | graph_args --base 1024 -r -l 0 --vertical-label Bytes --upper-limit ${values[6]}
|
||
| 66 | 4612c1bc | Michael Grote | graph_info This graph shows how a zfs filesystem is used. |
| 67 | 65652aa0 | dipohl | graph_category fs |
| 68 | cb6c9595 | amichel | graph_period second |
| 69 | usedbydataset.label UsedByDataset |
||
| 70 | usedbydataset.draw AREA |
||
| 71 | usedbydataset.info Used space by Dataset |
||
| 72 | usedbydataset.colour FF0000 |
||
| 73 | usedbychildren.label UsedByChildren |
||
| 74 | usedbychildren.draw STACK |
||
| 75 | usedbychildren.info Used space by children |
||
| 76 | usedbychildren.colour FFCC33 |
||
| 77 | usedbysnapshots.label UsedBySnapshots |
||
| 78 | usedbysnapshots.draw STACK |
||
| 79 | usedbysnapshots.info Used space by snapshot |
||
| 80 | usedbysnapshots.colour 0000FF |
||
| 81 | usedbyrefreservation.label Usedbyrefreservation |
||
| 82 | usedbyrefreservation.draw STACK |
||
| 83 | usedbyrefreservation.info Used space by Ref Reservation |
||
| 84 | usedbyrefreservation.colour 33CCFF |
||
| 85 | available.label Available |
||
| 86 | available.draw STACK |
||
| 87 | available.info Free space |
||
| 88 | available.colour 00FF00 |
||
| 89 | total.label Total |
||
| 90 | total.draw LINE1 |
||
| 91 | total.info Total |
||
| 92 | total.colour 000000 |
||
| 93 | quota.label Quota |
||
| 94 | quota.draw LINE1 |
||
| 95 | quota.info Quota |
||
| 96 | quota.colour 555555" |
||
| 97 | EOF |
||
| 98 | done |
||
| 99 | exit 0 |
||
| 100 | fi |
||
| 101 | |||
| 102 | 4612c1bc | Michael Grote | for i in $search_term; do |
| 103 | cb6c9595 | amichel | values=( $(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota $i | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}') )
|
| 104 | f6dbe9bd | Sephtex | fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g')) |
| 105 | cb6c9595 | amichel | |
| 106 | aee6a152 | Michael Fritscher | if [ ${values[5]} = "-" ]; then
|
| 107 | quota=0 |
||
| 108 | else |
||
| 109 | quota=${values[5]}
|
||
| 110 | fi |
||
| 111 | |||
| 112 | c35eee02 | Sephtex | echo <<EOF "multigraph zfs_list_$fsname |
| 113 | cb6c9595 | amichel | usedbydataset.value ${values[0]}
|
| 114 | usedbysnapshots.value ${values[2]}
|
||
| 115 | usedbychildren.value ${values[1]}
|
||
| 116 | usedbyrefreservation.value ${values[3]}
|
||
| 117 | available.value ${values[4]}
|
||
| 118 | total.value ${values[6]}
|
||
| 119 | aee6a152 | Michael Fritscher | quota.value $quota" |
| 120 | cb6c9595 | amichel | EOF |
| 121 | done |
||
| 122 | |||
| 123 | exit 0 |
