[Linux]一個統計appche站點IP訪問量的shell腳本

[Linux]一個統計appche站點IP訪問量的shell腳本
經常需要根據IP地址統計apache站點訪問量,最基本的腳本.

1.根據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


效果如下:

[[email protected] ~]# sh access_count
  94989 192.168.100.34
  38863 192.168.200.92
  23658 192.168.1.71
  16720 192.168.100.80
  13688 192.168.200.34
   1618 192.168.100.104
   1251 192.168.1.202
   1195 192.168.100.30
   1058 192.168.1.203
    934 192.168.1.208
    792 127.0.0.1
    773 192.168.5.126
    189 192.168.1.68

2.訪問量前三的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 -n 3

效果如下:

[[email protected] ~]# sh access_count
  94989 192.168.100.34
  38863 192.168.200.92
  23658 192.168.1.71
Related Posts Plugin for WordPress, Blogger...
標籤: , ,