mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 10:39:53 +00:00
plugin zfs_list: add "ignore_datasets_pattern" configuration
Allow to ignore certain volumes.
This commit is contained in:
parent
87280ed7c3
commit
4612c1bc90
1 changed files with 46 additions and 18 deletions
|
@ -1,21 +1,37 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor ZFS Filesystems
|
||||
# Author: Adam Michel (elfurbe@furbism.com)
|
||||
# Description:
|
||||
# This is an extension of the zfs_fs plugin
|
||||
# modified as a multigraph to graph all zfs
|
||||
# filesystems it can find
|
||||
#
|
||||
# Tested on Ubuntu-14.04
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#%# family=auto
|
||||
|
||||
: << EOF
|
||||
=head1 NAME
|
||||
zfs_list - Plugin to monitor ZFS Filesystems
|
||||
|
||||
This is an extension of the zfs_fs plugin
|
||||
modified as a multigraph to graph all zfs
|
||||
filesystems it can find
|
||||
|
||||
=head1 CONFIGURATION
|
||||
plugin config:
|
||||
[zfs_list]
|
||||
env.ignore_datasets_pattern <Datasets to ignore; String for grep>
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
=over 4
|
||||
=item * Adam Michel (elfurbe@furbism.com)
|
||||
=back
|
||||
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
=begin comment
|
||||
These magic markers are used by munin-node-configure when installing
|
||||
munin-node.
|
||||
=end comment
|
||||
#%# family=auto
|
||||
=cut
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
. "$MUNIN_LIBDIR/plugins/plugin.sh"
|
||||
|
||||
need_multigraph()
|
||||
|
@ -30,8 +46,20 @@ if [ "$1" = "suggest" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# set standard value
|
||||
ignore_datasets_pattern=${ignore_datasets_pattern:-}
|
||||
|
||||
# set search term, based on if the searh pattern is set
|
||||
if [ -n "$ignore_datasets_pattern" ]; then
|
||||
search_term=$(zfs list -Hp -t filesystem,volume | grep -v "$ignore_datasets_pattern" | awk '{print $1}')
|
||||
else
|
||||
search_term=$(zfs list -Hp -t filesystem,volume | awk '{print $1}')
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
for i in `zfs list -Hp -t filesystem,volume | awk '{print $1}'`; do
|
||||
for i in $search_term; do
|
||||
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;}') )
|
||||
fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g'))
|
||||
|
||||
|
@ -39,7 +67,7 @@ if [ "$1" = "config" ]; then
|
|||
graph_title $fsname usage
|
||||
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
|
||||
graph_args --base 1024 -r -l 0 --vertical-label Bytes --upper-limit ${values[6]}
|
||||
graph_info This graph shows how is used a zfs filesystems.
|
||||
graph_info This graph shows how a zfs filesystem is used.
|
||||
graph_category fs
|
||||
graph_period second
|
||||
usedbydataset.label UsedByDataset
|
||||
|
@ -75,7 +103,7 @@ EOF
|
|||
exit 0
|
||||
fi
|
||||
|
||||
for i in `zfs list -Hp -t filesystem,volume | awk '{print $1}'`; do
|
||||
for i in $search_term; do
|
||||
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;}') )
|
||||
fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g'))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue