linux下统计appche站点IP访问量的shell脚本
经常需要根据IP地址统计apache站点访问量,最基本的脚本.
根据IP访问量降序排列:
#!/bin/bash #Script_name:access_count acc_log=/usr/local/apache2/logs/access_log /bin/awk'{print$1}'$acc_log |sort|uniq-c|sort-nr
执行效果:
[root@zabbix~]#shaccess_count 94989192.168.100.34 38863192.168.200.92 23658192.168.1.71 16720192.168.100.80 13688192.168.200.34 1618192.168.100.104 1251192.168.1.202 1195192.168.100.30 1058192.168.1.203 934192.168.1.208 792127.0.0.1 773192.168.5.126 189192.168.1.68
打印访问量前三的IP地址:
#!/bin/bash #Script_name:access_count acc_log=/usr/local/apache2/logs/access_log /bin/awk'{print$1}'$acc_log |sort|uniq-c|sort-nr|head-n3