海运的博客

Nginx开启状态监控

发布时间:May 14, 2012 // 分类:Nginx // No Comments

Nginx开启监控需在编译时加入with-http_stub_status_module,查看当前Nginx编译参数:

/usr/local/nginx/sbin/nginx -V

1.以二级目录方式开启,编辑配置文件在server段添加:

location /status {
        stub_status on;
        access_log off;
        allow 192.168.1.16;
        deny all;
}

访问www.haiyun.me/status即可看到状态页面。
2.以二级域名方式开启:

server
{
       listen 80;
       server_name status.www.haiyun.me;

       location / {
       stub_status on;
       access_log off;
       allow 192.168.1.16;
       deny all;
       }
}

状态说明:
Active connections: 1 对后端发起的活动连接数
server accepts handled requests
909 909 7148
共处理909个连接,成功创建909次握手,总共处理7148个请求。
Reading: 0 Writing: 1 Waiting: 0
Reading:Nginx读取客户端的Header信息数。
Writing:Nginx返回客户端的Header信息数。
Waiting:开启keep-alive的情况下,等于active-(reading+writing),即Nginx已经处理完成,在等候下一次请求的连接。
在并发数较高,Waiting次数较多正常,如果reading+writing较多,代表并发访问量较大。

用Cacti监控服务器硬盘IO

发布时间:May 14, 2012 // 分类:Cacti // 3 Comments

此监控模板以iostat命令为数据源,需先安装cacti和sysstat组件。

yum -y install systat unzip
wget https://www.haiyun.me/download/cacti-iostat.zip
unzip cacti-iostat.zip
cd markround-Cacti-iostat-templates-7394c7b/

复制iostat.pl到被监控服务器目录:

cp scripts/iostat.pl  /usr/local/bin/iostat.pl

被监控服务器snmp配置文件添加:

echo "pass .1.3.6.1.3.1 /usr/bin/perl /usr/local/bin/iostat.pl" >> /etc/snmp/snmpd.conf
service snmpd restart

复制iostat.xml至Cacti安装目录:

cp snmp_queries/linux/iostat.xml  /cactipath/resource/snmp_queries/
#新版本cacti如果无法采集数据需删除ioName字段
#sed -i 's/:ioName//g' cactipath/resource/snmp_queries/iostat.xml 

添加计划任务,用于采集数据。

cat > /etc/cron.d/iostat <<EOF
*/5 * * * * root cd /tmp && iostat -xkd 2 2 | sed 's/,/\./g' > io.tmp && mv io.tmp iostat.cache
EOF

测试数据采集是否正常:

snmpwalk -v1 -c public www.haiyun.me .1.3.6.1.3.1.2
SNMPv2-SMI::experimental.1.2.1 = STRING: "sda"
SNMPv2-SMI::experimental.1.2.2 = STRING: "sda1"
SNMPv2-SMI::experimental.1.2.3 = STRING: "sda2"
SNMPv2-SMI::experimental.1.2.4 = STRING: "dm-0"
SNMPv2-SMI::experimental.1.2.5 = STRING: "dm-1"
SNMPv2-SMI::experimental.1.2.6 = STRING: "hdc"

Cacti界面导入templates/linux目录下模板:
cacti导入模板.png
然后在新建设备时添加相应的模板,效果图如下:
cacti监控io效果图(iostat).png

Cacti安装高效轮询器spine

发布时间:May 14, 2012 // 分类:Cacti // No Comments

Cacti默认轮询器cmd.php执行效率有点低,spine为C语言编写的组件,性能要好许多。
编译安装spine需以下软件支持:

net-snmp-devel
mysql
mysql-devel
openssl-devel

安装spine要和Cacti的版本相匹配,本文以最新版cacti0.8.8a安装为例。

cd /usr/local/src
wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
tar zxvf cacti-spine-0.8.8a.tar.gz 
cd cacti-spine-0.8.8a
./configure
make
make install

配置spine:

cd /usr/local/spine/etc/
mv spine.conf.dist spine.conf
vim spine.conf

填写数据库信息,即Cacti数据库。

DB_Host         localhost
DB_Database     cacti
DB_User         root
DB_Pass         passwd
DB_Port         3306

设置spine路径,Console——Settings——Paths
cacti设置spine路径.png
更改cacti轮询器为spine,Console——Settings——Poller
cacti更改轮询器为spine.png
测试spine轮询器:

/usr/local/spine/bin/spine 
SPINE: Using spine config file [spine.conf]
SPINE: Version 0.8.8a starting
SPINE: Time: 0.1167 s, Threads: 1, Hosts: 2

如出现FATAL: Unable to read configuration file! (Spine init)请确认以上配置是否正确。

Linux下Web服务器压力测试工具

发布时间:May 12, 2012 // 分类:系统调优 // No Comments

1.Webbench,安装:

wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz
tar zxvf webbench-1.5.tar.gz 
cd webbench-1.5/
make && make install

常用参数:

-t 测试时间
-c 并发连接数

应用举例:

webbench -c 1000 -t 300 https://www.haiyun.me/
#模拟1000并发数,测试时间300秒。

2.Http_load,安装:

cd /usr/local/src/
http://www.acme.com/software/http_load/http_load-12mar2006.tar.gz
tar zxvf http_load-12mar2006.tar.gz 
cd http_load-12mar2006/
make && make install

常用参数:

-p 并发访问进程数
-f 总的访问次数
-r 每秒的访问频率
-s 总的访问时间

应用示例:

http_load -p 100 -f 1000 url.txt #总访问1000次,并发100。
http_load -r 100 -s 300 url.txt #持续300秒,每秒100次访问。

3.Siege,安装:

wget http://www.joedog.org/pub/siege/siege-latest.tar.gz
tar zxvf siege-latest.tar.gz 
cd siege-2.72/
./configure 
make 
make install
siege.config 

常用参数:

-i 多个url,随机访问
-c 并发用户数
-r 重复次数
-t 测试时间
-l 输出测试日志

应用示例:

siege -c 200 -t 10  https://www.haiyun.me
#并发数200,持续时间10秒。

4.ab,apache自带的一款功能强大的测试工具,debian下单独安装:

apt-get install apache2-utils

常用参数:

-n 请求总次数
-c 并发请求数,不能大于-n

应用示例:

ab -c 100 -n 1000 https://www.haiyun.me/index.html
#并行发送100个请求,执行1000次。

Apache自定义404错误页面

发布时间:May 12, 2012 // 分类:Apache // No Comments

1.Apache全局设置,httpd.conf文件中添加或修改:

#https://www.haiyun.me
ErrorDocument 404 /404.html 

2.针对特定站点设置,在VirtualHost内添加:

ErrorDocument 404 /404.html 

3.虚拟机用户修改.htaccess文件添加:

ErrorDocument 404 /404.html 

注意:404页面不要大于512字节,否则IE会转向自带错误页面。

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...
归档