netstat -ntlp | sed '/Active/d' | sed '/Proto/d' | sed 's/:::/:/g'| sed 's/::ffff:/ /g'| awk '{print $4,$7}' | awk -F':' '{print $2}' | sed 's/[0-9][0-9][0-9][0-9]\// /g'
查看當前系統全部服務進程對應的端口
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
查看當前網絡tcp鏈接
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
顯示服務器上全部的每一個IP多少個鏈接數服務器
cat access.log | grep "13/Jul/2013" | awk '{print $11}' | sort | uniq -c | sort -nr | head -n 10
日誌統計查看當天訪問最多的頁面,取前10
cat access.log | grep "13/Jul/2013" | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 10
日誌統計查看當天訪問排名前10的ip鏈接數
cat access_20130811.log |awk '{print $NF}' | sort | uniq -c | sort -nr | head -n 15
查找日誌中,取值末尾,保留訪問最多的前15個
cat access.log | grep "13/Jul/2013" | awk '{sum+=$10} END {print sum/1024/1024/1024}'
統當天計網站流量(G)
cat access.log | grep "13/Jul/2013" |awk '{sum+=$10} END {print sum/1024/1024}'
統計當天網站流量(M)網絡
cat access.log | grep "13/Jul/2013" | awk '{counts[$(9)]+=1}; END {for(code in counts) print code,counts[code]}'
cat access.log | grep "13/Jul/2013" |awk '{print $9}'|sort|uniq -c|sort -rn
查看今日訪問的http狀態數
cat access.log | grep "13/Jul/2013" | grep "163.177.71.12" | awk '{print $7}' | sort | uniq -c | sort -nr
查看當天指定ip訪問次數過的url和訪問次數tcp
把IP數量直接輸出顯示:
cat access_log_2011_06_26.log |awk '{print $1}'|uniq -c|wc -l網站