2013-02-07 19:32:06 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
http_port=8181
|
|
|
|
db_port=6432
|
|
|
|
redis_port=6379
|
2013-02-07 19:32:06 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
pids=$(lsof -i :${http_port} | grep LISTEN | awk '{print $2}')
|
|
|
|
nworkers=$(echo "${pids}" | wc -l)
|
|
|
|
pids=$(echo "${pids}" | paste -sd ' ')
|
2013-02-07 19:32:06 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
tmpreport="/tmp/checkfd.$$.txt"
|
2013-02-07 19:32:06 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
lsof -p $(echo "${pids}" | tr ' ' ',') > "${tmpreport}"
|
2013-02-07 19:32:06 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
maxdb=0
|
|
|
|
maxredis=0
|
|
|
|
maxhttp=0
|
|
|
|
maxtot=0
|
2013-02-07 19:32:06 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
for pid in ${pids}; do
|
2013-02-07 20:26:11 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
cnt=$(grep "${pid}" "${tmpreport}" | grep ":${db_port} " | wc -l);
|
|
|
|
if test $cnt -gt $maxdb; then maxdb=$cnt; fi
|
|
|
|
|
|
|
|
cnt=$(grep "${pid}" "${tmpreport}" | grep ":${redis_port} " | wc -l);
|
|
|
|
if test $cnt -gt $maxredis; then maxredis=$cnt; fi
|
2013-02-07 20:26:11 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
cnt=$(grep "${pid}" "${tmpreport}" | grep ":${http_port} " | grep -v "LISTEN" | wc -l);
|
|
|
|
if test $cnt -gt $maxhttp; then maxhttp=$cnt; fi
|
2013-02-07 20:26:11 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
cnt=$(grep "${pid}" "${tmpreport}" | wc -l);
|
|
|
|
if test $cnt -gt $maxtot; then maxtot=$cnt; fi
|
2013-02-07 20:26:11 +08:00
|
|
|
|
2013-02-07 19:32:06 +08:00
|
|
|
done
|
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
echo "procs.value ${nworkers}"
|
|
|
|
echo "pgsql.value ${maxdb}"
|
|
|
|
echo "redis.value ${maxredis}"
|
|
|
|
echo "http.value ${maxhttp}"
|
|
|
|
echo "nfd.value ${maxtot}"
|
2013-02-07 19:32:06 +08:00
|
|
|
|
2013-02-08 22:24:25 +08:00
|
|
|
rm -f "${tmpreport}"
|