Windshaft-cartodb/tools/checkfds.sh

43 lines
1.0 KiB
Bash
Raw Normal View History

2013-02-07 19:32:06 +08:00
#!/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}"
2013-02-07 19:32:06 +08:00
echo -n "worker $pid postgres: "
cat "${pidrep}" | grep ':6432 .EST' | wc -l;
2013-02-07 19:32:06 +08:00
echo -n "worker $pid redis: "
cat "${pidrep}" | grep ':6379 .EST' | wc -l;
2013-02-07 19:32:06 +08:00
echo -n "worker $pid incoming http: "
cat "${pidrep}" | grep ':8181' | wc -l;
2013-02-07 19:32:06 +08:00
echo -n "worker $pid total: "
cat "${pidrep}" | wc -l;
2013-02-07 19:32:06 +08:00
done
echo -n "master $master_pid total: "
lsof -p $master_pid | grep node | wc -l;