Révision 960122b9
Initial Commit of FreeBSD NFS Plugins
This is an initial commit of FreeBSD NFS plugins for the Munin
monitoring platform. The NFS plugins for Munin depend on the
/proc filesystem in Linux for statistics which does not exist in
FreeBSD by default. While one can add the linproc package to their
installation to emulate this functionality, I felt it would be better
to write plugins that made use of native tools.
I'm leveraging the nfsstat command to create these plugins. I'm sure
there is a better primary data source in FreeBSD to gather this output
from but for my purposes, using nfsstat is adequate and acceptable.
Unfortunately this means if the output of the nfsstat command changes
due to updates, these plugins will likely report inaccurate data.
These are the days of our lives, as they say. Someone with appropriate
levels of FreeBSD knowledge can probably improve these plugins
trivially.
I'm specifically targeting FreeNAS/NAS4Free, but the code should work
on any FreeBSD system with minimal package additions. Installing munin
on FreeNAS is not supported in general, but it's easy enough to do and
I wanted it monitored, ergo we are here.
| plugins/nfs-freebsd/README.rst | ||
|---|---|---|
| 1 |
NFS plugins for FreeBSD |
|
| 2 |
------------------------ |
|
| 3 |
|
|
| 4 |
NFS plugins for FreeBSD |
|
| plugins/nfs-freebsd/nfsd | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# -*- sh -*- |
|
| 3 |
|
|
| 4 |
: << =cut |
|
| 5 |
|
|
| 6 |
=head1 NAME |
|
| 7 |
|
|
| 8 |
nfsd - Plugin to monitor NFS server activity on FreeBSD |
|
| 9 |
|
|
| 10 |
=head1 CONFIGURATION |
|
| 11 |
|
|
| 12 |
No configuration |
|
| 13 |
|
|
| 14 |
=head1 AUTHORS |
|
| 15 |
|
|
| 16 |
Plugin created by Adam Michel, based on work by Alexandre Dupouy, with the assistance of Mike Fedyk |
|
| 17 |
|
|
| 18 |
=head1 LICENSE |
|
| 19 |
|
|
| 20 |
GPLv2 |
|
| 21 |
|
|
| 22 |
=head1 MAGIC MARKERS |
|
| 23 |
|
|
| 24 |
#%# family=auto |
|
| 25 |
#%# capabilities=autoconf |
|
| 26 |
|
|
| 27 |
=cut |
|
| 28 |
|
|
| 29 |
# This is where nfsstat lives |
|
| 30 |
NFSSTAT=/usr/bin/nfsstat |
|
| 31 |
if [ "$1" = "autoconf" ]; then |
|
| 32 |
if [ -x "$NFSSTAT" ]; then |
|
| 33 |
echo yes |
|
| 34 |
exit 0 |
|
| 35 |
else |
|
| 36 |
echo "no (no $NFSSTAT)" |
|
| 37 |
exit 0 |
|
| 38 |
fi |
|
| 39 |
fi |
|
| 40 |
|
|
| 41 |
labels=`$NFSSTAT -s | grep -iv "[0-9]" | grep -v ":" | sed 's/Server\ //' | tr '\n' ' ' | awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30}' | tr '[A-Z]' '[a-z]'`
|
|
| 42 |
values=`$NFSSTAT -s | grep -i "[0-9]" | tr '\n' ' ' | awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30}'`
|
|
| 43 |
|
|
| 44 |
larray=( $labels ) |
|
| 45 |
varray=( $values ) |
|
| 46 |
|
|
| 47 |
if [ "$1" = "config" ]; then |
|
| 48 |
|
|
| 49 |
echo 'graph_title NFS Server' |
|
| 50 |
echo 'graph_args --base 1000 -l 0' |
|
| 51 |
echo 'graph_vlabel requests / ${graph_period}'
|
|
| 52 |
echo 'graph_total total' |
|
| 53 |
echo 'graph_category NFS' |
|
| 54 |
for a in $labels; do echo "$a.label $a" ; echo "$a.type DERIVE"; echo "$a.min 0"; done |
|
| 55 |
exit 0 |
|
| 56 |
fi |
|
| 57 |
|
|
| 58 |
for i in {0..29}; do
|
|
| 59 |
label=${larray[$i]}
|
|
| 60 |
value=${varray[$i]}
|
|
| 61 |
echo "$label.value $value" |
|
| 62 |
done |
|
Formats disponibles : Unified diff