Skip to content

Instantly share code, notes, and snippets.

@thecarlhall
Last active December 12, 2015 01:08
Show Gist options
  • Save thecarlhall/4688247 to your computer and use it in GitHub Desktop.
Save thecarlhall/4688247 to your computer and use it in GitHub Desktop.
Riak status shell function
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
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
@thecarlhall
Copy link
Author

This is what the output looks like for riak_ping:

Server 50.16.216.xxx: OK
Server 54.225.186.xxx: OK
Server 50.19.236.xxx: OK
Server 184.73.249.xxx: OK

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