Last active
December 12, 2015 01:08
-
-
Save thecarlhall/4688247 to your computer and use it in GitHub Desktop.
Riak status shell function
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
riak_ping() { | |
NODES=$(dig +short A production-reporting-source-129485720.us-east-1.elb.amazonaws.com) | |
for n in $NODES; do | |
echo "Server ${n}: $(curl --connect-timeout 3 -s -k https://${n}:8080/ping)" & | |
done | |
} | |
alias riak_ping=riak_ping |
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
riak_status() { | |
NODES=$(dig +short A production-reporting-source-129485720.us-east-1.elb.amazonaws.com) | |
NAME="hostname" | |
RIAK_PROCS="ps ax | grep -v grep | grep beam\.smp | wc -l" | |
MONIT_PROCS="ps ax | grep -v grep | grep monit | wc -l" | |
UL_SOFT="ulimit -Sn" | |
UL_HARD="ulimit -Hn" | |
OPEN_FILES_RIAK="sudo lsof | grep riak | wc -l" | |
OPEN_FILES_TOTAL="sudo lsof | wc -l" | |
MEMORY_FREE="free | head -n 3 | tail -n 1 | awk '{print \$4 / (\$3 + \$4) * 100}'" | |
MEMORY_USED="free | head -n 3 | tail -n 1 | awk '{print \$3 / (\$3 + \$4) * 100}'" | |
for n in $NODES; do | |
limits=$(ssh ubuntu@$n -t "(${RIAK_PROCS}) && (${MONIT_PROCS}) && (${UL_SOFT}) && (${UL_HARD}) && (${OPEN_FILES_RIAK}) && (${OPEN_FILES_TOTAL}) && (${MEMORY_FREE}) && (${NAME})") | |
echo "Name: $(echo "$limits" | head -n 8 | tail -n 1)" | |
echo "Status: $(curl --connect-timeout 3 -s -k https://${n}:8080/ping)" | |
echo "Riak Processes: $(echo "$limits" | head -n 1)" | |
echo "Monit Processes: $(echo "$limits" | head -n 2 | tail -n 1)" | |
echo "ulimit (soft): $(echo -n "$limits" | head -n 3 | tail -n 1)" | |
echo "ulimit (hard): $(echo -n "$limits" | head -n 4 | tail -n 1)" | |
echo "Open Files (riak): $(echo -n "$limits" | head -n 5 | tail -n 1)" | |
echo "Open Files (total): $(echo -n "$limits" | head -n 6 | tail -n 1)" | |
echo "Free memory (%): $(echo "$limits" | head -n 7 | tail -n 1)" | |
echo "=====" | |
done | |
} | |
alias riak_status=riak_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is what the output looks like for
riak_ping
: