-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnfsstat.sh
32 lines (30 loc) · 1.03 KB
/
nfsstat.sh
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
31
32
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
INTERVAL="${COLLECTD_INTERVAL:-10}"
# Local settings
CLIENT_STATS=true
SERVER_STATS=true
CLIENT_DATATYPE='gauge'
SERVER_DATATYPE='gauge'
while sleep "$INTERVAL"; do
if [ $SERVER_STATS = true ]; then
stats="$(nfsstat -e -s)"
for i in {1..8}; do
echo "$stats" | grep -v ':' | grep -v '^$' | awk "{print \$$i}" \
| paste - - | sed '/^[[:space:]]*$/d' | sort | tr '[:upper:]' '[:lower:]' \
| while read -r key value; do
echo "PUTVAL $HOSTNAME/nfsstat/${SERVER_DATATYPE}-server-${key} interval=$INTERVAL N:$value"
done
done
fi
if [ $CLIENT_STATS = true ]; then
stats="$(nfsstat -e -c)"
for i in {1..8}; do
echo "$stats" | grep -v ':' | grep -v '^$' | awk "{print \$$i}" \
| paste - - | sed '/^[[:space:]]*$/d' | sort | tr '[:upper:]' '[:lower:]' \
| while read -r key value; do
echo "PUTVAL $HOSTNAME/nfsstat/${CLIENT_DATATYPE}-client-${key} interval=$INTERVAL N:$value"
done
done
fi
done