Find nginx pid:

ps -ef | grep nginx

Results:

nginx      57233   57209  0 20:34 ?        00:00:00 php-fpm: pool www
root       57234       1  0 20:34 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx      57235   57234  0 20:34 ?        00:00:01 nginx: worker process
nginx      57236   57234  0 20:34 ?        00:00:00 nginx: cache manager process
root       57482   55217  0 20:43 pts/0    00:00:00 grep --color=auto nginx

pool: mean nginx run php-fpm

master: not worker, just is a parent

cache manager: Just for cache

color=auto: The ps -ef | grep nginx

worker process: This is result. 57234 is parent pid, this pid is 57235

So, if we have many worker process pids from 1833681 to 1833692. We can count in terminal:

total_connections=0
for pid in $(seq 1833681 1833692); do
  connections=$(ss -anp | grep "$pid" | wc -l)
  echo "$pid: $connections"
  total_connections=$((total_connections + connections))
done
echo "Total connections: $total_connections"

If have one pid: ss -anp | grep "$pid" | wc -l

,

DMCA.com Protection Status


Leave a Reply

Your email address will not be published. Required fields are marked *