Skip to content

Instantly share code, notes, and snippets.

@matthanley
Created February 13, 2020 15:14
Show Gist options
  • Save matthanley/1110973313a2761fa5de322dd488d202 to your computer and use it in GitHub Desktop.
Save matthanley/1110973313a2761fa5de322dd488d202 to your computer and use it in GitHub Desktop.
PRTG monitoring scripts for GlusterFS
#!/bin/bash
if [ -z "$1" ]; then
echo "2:0:no volume provided"
exit 1
fi
# volume bricks online = y
bricks=`sudo gluster volume info $1 | sed -nr 's/Number of Bricks:[^=]+= ([0-9]+)/\1/p'`
online=`sudo gluster volume status $1 detail | egrep 'Online.+Y' | wc -l`
if [ "$online" -eq "$bricks" ]; then
echo "0:$online:all bricks online"
exit 0
fi
echo "1:$online:bricks offline"
exit 1
#!/bin/bash
if [ -z "$1" ]; then
echo "2:0:no volume provided"
exit 1
fi
# volume heal info entries = 0
entries=0
for entry in `sudo gluster volume heal $1 info | sed -nr 's/Number of entries: ([0-9]+)/\1/p'`; do
entries=$(( $entries + $entry ))
done
if [ "$entries" -gt 0 ]; then
echo "1:$entries:self-heal in progress"
exit 1
fi
echo "0:0:no self-heal entries"
exit 0
#!/bin/bash
# peer status = connected
nodes=`sudo gluster pool list | tail -n +2 | wc -l`
if [ "$nodes" -eq 0 ]; then
echo "2:0:failed to get pool list"
exit 1
fi
connected=`sudo gluster pool list | tail -n +2 | awk '{print $3}' | grep "Connected" | wc -l`
if [ "$nodes" -gt "$connected" ]; then
echo "1:$nodes:missing peers"
exit 1
fi
echo "0:$nodes:all nodes connected"
# /etc/sudoers.d/prtg
prtg ALL=(root) NOPASSWD:/usr/sbin/gluster
@merovingian
Copy link

Works like a charm, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment