Created
February 13, 2020 15:14
-
-
Save matthanley/1110973313a2761fa5de322dd488d202 to your computer and use it in GitHub Desktop.
PRTG monitoring scripts for GlusterFS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/sudoers.d/prtg | |
prtg ALL=(root) NOPASSWD:/usr/sbin/gluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like a charm, thank you very much!