Feed on Posts or Comments

Monthly Archive六月 2009



Linux 相關 Aaron on 30 六月 2009

apache log IP count & sort

話說,常常在分析 apache log 時最常用的就是 IP 排序+統計,如果三不五時都要把 webalizer 叫出來跑,實在是有點辛苦,所以我們家 J神 就提供了一個簡易的語法,非常精準好用。

cat access.log |awk ‘{print $1}’|sort|uniq -c|sort -rn|head -n 10

這樣子會排出前十名 hit 最高的 IP,結果就會像

2416 123.156.xx.212
601 122.122.xx.101
583 114.38.xx.214
565 218.168.xx.140
526 114.43.xx.250
525 114.41.xx.40
476 218.168.xx.72
449 115.43.xx.154
424 114.42.xx.172
389 218.169.xx.162

至於其他更進階的用法就靠大家自已變化囉 ~

20090706 再補一個 netstat 的

netstat -nat| sed -e ’s/:/ /g’ |awk ‘{print $6}’|sort|uniq -c|sort -rn|head -n 10

Linux 相關 Aaron on 25 六月 2009

Squid 3.0 on CentOS x86_64

因為 squid 3.0 在 CentOS x86_64 底下編譯都會出現 『client_side.cc:2144: warning: comparison between signed and unsigned integer expressions』

所以只好回頭來找 rpm source 來安裝,底下是簡單的法子:

yum -y groupinstall 『Development Tools』
yum -y install rpm-build openjade linuxdoc-tools gcc gcc-c++ openldap-devel pam-devel openssl-devel
cd /usr/local/src
wget http://download.fedora.redhat.com/pub/fedora/linux/releases/10/Fedora/source/SRPMS/squid-3.0.STABLE10-1.fc10.src.rpm
rpm -ivh squid-3.0.STABLE10-1.fc10.src.rpm
cd /usr/src/redhat/SPECS
rpmbuild -bb squid.spec
rpm -Uvh /usr/src/redhat/RPMS/x86_64/squid-3.0.STABLE10-1.x86_64.rpm

搞定收工 …..

Linux 相關 Aaron on 08 六月 2009

Argument list too long

話說,最近一直在幫忙清垃圾信~ 結果發現到有時垃圾信的目錄太久沒清,都不能用正常的 RM 來刪除,總是會出現 『Argument list too long』 …. 這是因為 rm 在刪檔前,會針對這目錄做出一個 remove file list,但檔案數超過了他建立 list 的能量,這時,就只好用 find 這指令,找出一個,刪一個囉 ~~

find /var/spool/mqueue -type f -exec rm {} \;

搞定收工….