Windshaft-cartodb/tools/checkfds.sh
2013-02-07 13:26:11 +01:00

43 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Sorry, you must currently manually edit the regexp to make this work
# on your machine.
master_pid=$(ps xa | grep windshaft | grep -v local | grep -v grep | awk '{print $1}')
# TODO: use pid files
worker_pids=$(ps xa | grep windshaft | grep local | awk '{print $1}' |
python -c "import sys; print ','.join((x.strip() for x in sys.stdin.readlines()))")
if test -z "${worker_pids}"; then
echo "No workers found"
exit 1
fi
echo "Master: $master_pid"
echo "Workers: $worker_pids"
for pid in $(echo $worker_pids | tr ',' ' '); do
pidrep="/tmp/checkfd.$pid.txt"
lsof -p $pid > "${pidrep}"
echo -n "worker $pid postgres: "
cat "${pidrep}" | grep ':6432 .EST' | wc -l;
echo -n "worker $pid redis: "
cat "${pidrep}" | grep ':6379 .EST' | wc -l;
echo -n "worker $pid incoming http: "
cat "${pidrep}" | grep ':8181' | wc -l;
echo -n "worker $pid total: "
cat "${pidrep}" | wc -l;
done
echo -n "master $master_pid total: "
lsof -p $master_pid | grep node | wc -l;