佳音的博客

2010/02/28

Twitter 更新 for 2010-02-28

Filed under: Uncategorized — 标签: — 佳音 @ 4:20 下午
  • 为啥我点的链接都是被墙了! #
  • vpn 上网比平时上网都快! #

Powered by Twitter Tools

2010/02/26

static hostname to special module -zend framework

Filed under: php — 佳音 @ 4:36 下午

麻烦的zend                 tnnd 手册也不全
‘sso’ => array(
‘type’ => ‘Zend_Controller_Router_Route_Hostname’,
‘route’ => ‘sso.xxxxxx.com’,
‘defaults’ => array(
‘module’ => ‘sso’,
‘controller’=>’index’,
‘action’=> ‘index’
),

‘chains’ =>  array(
array(
‘type’=>’Zend_Controller_Router_Route’,
‘route’=>’:controller/:action’,
‘defaults’ => array(
‘module’     => ‘sso’,
‘controller’ => ‘index’,
‘action’     => ‘index’
)
)
)
)

大概是这么写的

2010/02/25

网站排障分析常用的命令

Filed under: Uncategorized — 佳音 @ 4:23 下午

http://docs.linuxtone.org/webapp/webscan.txt

好久没有发贴了,
整理一些常用分析网站的小命令方便大家排障,内容均来源于网络。
如果你是初学者关于AWK应用技巧请参照论坛的脚本编程版块,
如果你是老手,什么好的命令集或者必杀技欢迎跟贴,丰富此贴!

系统连接状态篇:
1.查看TCP连接状态
netstat -nat |awk ‘{print $6}’|sort|uniq -c|sort -rn

netstat -n | awk ‘/^tcp/ {++S[$NF]};END {for(a in S) print a, S[a]}’ 或
netstat -n | awk ‘/^tcp/ {++state[$NF]}; END {for(key in state) print key,”\t”,state[key]}’
netstat -n | awk ‘/^tcp/ {++arr[$NF]};END {for(k in arr) print k,”\t”,arr[k]}’

netstat -n |awk ‘/^tcp/ {print $NF}’|sort|uniq -c|sort -rn

netstat -ant | awk ‘{print $NF}’ | grep -v ‘[a-z]‘ | sort | uniq -c

2.查找请求数请20个IP(常用于查找攻来源):
netstat -anlp|grep 80|grep tcp|awk ‘{print $5}’|awk -F: ‘{print $1}’|sort|uniq -c|sort -nr|head -n20

netstat -ant |awk ‘/:80/{split($5,ip,”:”);++A[ip[1]]}END{for(i in A) print A[i],i}’ |sort -rn|head -n20

3.用tcpdump嗅探80端口的访问看看谁最高
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F”.” ‘{print $1″.”$2″.”$3″.”$4}’ | sort | uniq -c | sort -nr |head -20

4.查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk ‘{print $5}’|sort|uniq -c|sort -rn|head -n20

5.找查较多的SYN连接
netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more

6.根据端口列进程
netstat -ntlp | grep 80 | awk ‘{print $7}’ | cut -d/ -f1

网站日志分析篇1(Apache):

1.获得访问前10位的ip地址
cat access.log|awk ‘{print $1}’|sort|uniq -c|sort -nr|head -10
cat access.log|awk ‘{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}’

2.访问次数最多的文件或页面,取前20
cat access.log|awk ‘{print $11}’|sort|uniq -c|sort -nr|head -20

3.列出传输最大的几个exe文件(分析下载站的时候常用)
cat access.log |awk ‘($7~/\.exe/){print $10 ” ” $1 ” ” $4 ” ” $7}’|sort -nr|head -20

4.列出输出大于200000byte(约200kb)的exe文件以及对应文件发生次数
cat access.log |awk ‘($10 > 200000 && $7~/\.exe/){print $7}’|sort -n|uniq -c|sort -nr|head -100

5.如果日志最后一列记录的是页面文件传输时间,则有列出到客户端最耗时的页面
cat access.log |awk ‘($7~/\.php/){print $NF ” ” $1 ” ” $4 ” ” $7}’|sort -nr|head -100

6.列出最最耗时的页面(超过60秒的)的以及对应页面发生次数
cat access.log |awk ‘($NF > 60 && $7~/\.php/){print $7}’|sort -n|uniq -c|sort -nr|head -100

7.列出传输时间超过 30 秒的文件
cat access.log |awk ‘($NF > 30){print $7}’|sort -n|uniq -c|sort -nr|head -20

8.统计网站流量(G)
cat access.log |awk ‘{sum+=$10} END {print sum/1024/1024/1024}’

9.统计404的连接
awk ‘($9 ~/404/)’ access.log | awk ‘{print $9,$7}’ | sort

10. 统计http status.
cat access.log |awk ‘{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}'
cat access.log |awk '{print $9}'|sort|uniq -c|sort -rn

10.蜘蛛分析
查看是哪些蜘蛛在抓取内容。
/usr/sbin/tcpdump -i eth0 -l -s 0 -w - dst port 80 | strings | grep -i user-agent | grep -i -E 'bot|crawler|slurp|spider'

网站日分析2(Squid篇)

2.按域统计流量
zcat squid_access.log.tar.gz| awk '{print $10,$7}' |awk 'BEGIN{FS="[ /]"}{trfc[$4]+=$1}END{for(domain in trfc){printf "%s\t%d\n",domain,trfc[domain]}}'

效率更高的perl版本请到此下载:http://docs.linuxtone.org/soft/tools/tr.pl

数据库篇
1.查看数据库执行的sql
/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 'SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL'

系统Debug分析篇

1.调试命令
strace -p pid

2.跟踪指定进程的PID
gdb -p pid

更多的请参考:

http://bbs.linuxtone.org/forum-14-1.html

hadoop0.20.1 eclipse plugin

Filed under: hadoop — 佳音 @ 3:33 下午

http://issues.apache.org/jira/browse/MAPREDUCE-1262

src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/launch/HadoopApplicationLaunchShortcut.java

@@ -32,7 +32,7 @@
-import org.eclipse.jdt.internal.debug.ui.launcher.JavaApplicationLaunchShortcut;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaApplicationLaunchShortcut;

@@ -65,6 +65,10 @@
ILaunchConfiguration iConf =
super.findLaunchConfiguration(type, configType);

+    if(iConf == null){
+      return null;
+    }
+
ILaunchConfigurationWorkingCopy iConfWC;
try {
/*

cd  src/contrib/eclipse-plugin/

ant jar -Declipse.home=/usr/local/eclipse   ///usr/local/eclipse your eclipse home

EBOOK Pro Hadoop

Filed under: hadoop — 标签: — 佳音 @ 1:37 下午

Pro Hadoop

OReilly.Hadoop.The.Definitive.Guide.June.2009.RETAiL.eBOOk-sUppLeX.pdf

Filed under: hadoop — 佳音 @ 1:29 下午

OReilly.Hadoop.The.Definitive.Guide.June.2009.RETAiL.eBOOk-sUppLeX

2010/02/24

fuse-hdfs 简单测试

Filed under: Uncategorized — 佳音 @ 12:01 下午
这东西实验性还是很强 在编译过程中 出现很多错误,
最后一次忽略所有错误继续 编译 才编译过去,
time dd if=/mnt/hdfs/user/root/with_country.tsv/part-00071  of=/tmp/a.txt bs=8k count=30000
3603+1 records in
3603+1 records out
29519802 bytes (30 MB) copied, 2.98445 s, 9.9 MB/s
real 0m3.015s
user 0m0.008s
sys 0m0.104s
sudo time dd if=/dev/zero of=/mnt/hdfs/test.txt bs=8k count=3000
3000+0 records in
3000+0 records out
24576000 bytes (25 MB) copied, 2.98638 s, 8.2 MB/s
0.00user 0.08system 0:03.01elapsed 2%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+261minor)pagefaults 0swaps
~$ sudo time dd if=/dev/zero of=/mnt/hdfs/test.txt bs=8k count=30000
30000+0 records in
30000+0 records out
245760000 bytes (246 MB) copied, 30.1176 s, 8.2 MB/s
0.03user 0.78system 0:30.19elapsed 2%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+259minor)pagefaults 0swaps

Powered by 00RZ