【Abstract】Two methods for calculating the number of people online, and compared them.
Calculate the number of WWW online users
Method 1:
‘netstat -a | grep http|awk ‘{print $5}‘|cut –d“:“ -f1|sort| uniq |wc -l | awk '{print $1 - 1}‘
This is how I read it online. And more popular.
Method 2:
The method we use.
‘netstat -an | grep “:80 “| grep -i ESTABLISHED | awk ‘{print $5}‘|cut –d“:”-f1|sort| uniq |wc -l | awk '{print $1 - 1}'
Method 2 does not require reverse parsing, so the speed will be faster than method 1. But you need to get the already established link, so you need grep –I ESTABLISHED. This is assuming that the port of ww is 80.
The above two methods passed the test under Redhat linux AS3, and method two is better than method one.
Calculate the number of WWW online users
Method 1:
‘netstat -a | grep http|awk ‘{print $5}‘|cut –d“:“ -f1|sort| uniq |wc -l | awk '{print $1 - 1}‘
This is how I read it online. And more popular.
Method 2:
The method we use.
‘netstat -an | grep “:80 “| grep -i ESTABLISHED | awk ‘{print $5}‘|cut –d“:”-f1|sort| uniq |wc -l | awk '{print $1 - 1}'
Method 2 does not require reverse parsing, so the speed will be faster than method 1. But you need to get the already established link, so you need grep –I ESTABLISHED. This is assuming that the port of ww is 80.
The above two methods passed the test under Redhat linux AS3, and method two is better than method one.