gjw_apparitor 博客
孤独是一种态度
孤独是一种态度
三 19th
脚本类似shell的tail功能,用来统计每分钟的4xx、5xx的状态码数量,统计php执行时间小于1秒、1-5秒、5秒以上的数量,和每秒的并发请求。将结果放到/tmp目录下, 也可以用cacti将结果画图。
#!/usr/bin/env python
import time, os
#-----------------------------
log_file = '/var/log/httpd/cmi_access_log'
#-----------------------------
log_name = log_file.split('/')[-1]
file = open(log_file, 'r')
lt1,to1_5,gt5,status4,status5,concurrent = 0,0,0,0,0,0
Time2 = '0'
st_results = os.stat(log_file)
st_size = st_results[6]
file.seek(st_size)
size = os.path.getsize(log_file)
while 1:
Time = time.strftime("%Y_%m_%d",time.localtime(time.time() - 60))
where = file.tell()
line = file.readline()
L = line.split('"')
Time1 = time.strftime("%Y_%m_%d_%H:%M",time.localtime(time.time() - 60))
if not line:
size = os.path.getsize(log_file)
if size < where:
file = open(log_file, 'r')
else:
time.sleep(1)
file.seek(where)
else:
try:
Phptime = float(L[-2])
url = L[1]
status = L[2][1:4]
if '4' in status[0]:
status4 += 1
elif '5' in status[0]:
status5 += 1
if Time1 in Time2:
if 'f5.php' not in url:
concurrent += 1
if Phptime < 1:
lt1 += 1
elif 1 <= Phptime <= 5:
to1_5 += 1
else:
gt5 += 1
else:
concurrent = concurrent / 60
out = Time1 + "," + str(lt1) + "," + str(to1_5) + "," + str(gt5) + "," + str(status4) + "," + str(status5) + "," + str(concurrent)
F = open('/tmp/' + log_name + '_' + Time + '.data', 'a')
print >> F, out
F.close()
Time2 = Time1
lt1,to1_5,gt5,status4,status5,concurrent = 0,0,0,0,0,0
except:
pass
十 25th
9月份 F5发布新的版本 V11,性能和功能都提升了不少。
1、Analytics模块开启:
System ›› Resource Provisioning 里 开启 Application Visibility and Reporting (AVR) 这个模块。
2、在VS里 Analytics Profile 选择 analytics.
3、过10多分钟后会在 Overview ›› Statistics : Analytics 里看到一些数据。
例:
所有Response Code的统计和TPS
所有Pool Member的TPS 等
URLs:显示每个URL的TPS,方便查出哪个URL的时间最长。对研发和运维的帮助都很大。
功能非常强大,有图有数据。非常不错。
十 10th
http://www.howtoforge.com/how-to-install-django-on-fedora9-apache2-mod_python
九 20th
参加了2011系统架构师大会在 “TCP协议优化在互联网行业的应用” 听到刘泓昊对TCP的优化很受启发。
之前我测试过他们的设备感觉非常不错附上测试结果http://www.apparitor.info/2011/05/23/fastkernel-%E8%AE%BE%E5%A4%87%E6%B5%8B%E8%AF%95/
决定测试一下我们服务器的初始的接收窗口大小。
再次感谢刘泓昊的帮助。
分析服务器初始的接收窗口大小测试方法:
1、开一个终端监听eth0网卡的到 www.apparitor.info台机器的数据包
# tcpdump -i eth0 host www.apparitor.info
2、开另一个终端访问www.apparitor.info
# curl www.apparitor.info