鸭子的路标

 
Filed under

nginx

 

命令行下的Apache日志分析

1,查看apache进程:
ps aux | grep httpd | grep -v grep | wc -l

2,查看80端口的tcp连接:
netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l

3,通过日志查看当天ip连接数,过滤重复:

cat access_log | grep "24/Jul/2007" | awk '{print $2}' | sort | uniq -c | sort -nr

4,当天ip连接数最高的ip都在干些什么(原来是蜘蛛):
cat access_log | grep "24/Jul/2007:00" | grep "61.135.166.230" | awk '{print $8}' | sort | uniq -c | sort -nr | head -n 10

5,当天访问页面排前10的url:

cat access_log | grep "24/Jul/2007:00" | awk '{print $8}' | sort | uniq -c | sort -nr | head -n 10

6,用tcpdump嗅探80端口的访问看看谁最高
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr
接着从日志里查看该ip在干嘛:
cat access_log | grep 220.181.38.183| awk '{print $1"\t"$8}' | sort | uniq -c | sort -nr | less


7,查看某一时间段的ip连接数:
grep "2006:0[7-8]" www20060723.log | awk '{print $2}' | sort | uniq -c| sort -nr | wc -l

Loading mentions Retweet
Filed under  //   apache   linux   nginx  

Comments [0]

基于CentOS下Nagios在nginx下安装

Check out this website I found at limylau.blog.51cto.com

1.确定Centos系统中是否安装如下软件包:
Apache
GCC compiler
GD development libraries
2.如果没有安装,则按如下方式进行安装:
yum -y install httpd
yum -y install gcc
yum -y install glibc glibc-common
yum -y install gd gd-devel
3.创建一个nagios user并为其设置password
useradd nagios
passwd nagios
4.创建用户组并将nagios user和apache user加入到用户组中
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
5.下载nagios软件包及nagios插件
wget [url]http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz[/url]
wget [url]http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz[/url]
6.编译安装nagios
tar xzf nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
7.配置web接口
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
重启apache服务器,让刚才的配置生效。
8.安装nagios插件
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure --with-nagios-user=nagios --with-nagios group=nagios
make
make install
9.把nagios服务增加到服务清单中并设置开机自启动
chkconfig --add nagios
chkconfig nagios on
10.检查nagios服务器是否存在配置错误。
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
若没有错误信息就启动nagios服务器
service nagios start
11.在ie中输入http://“nagios server ipaddress”/nagios/,测试nagios服务器是否已经能正确安装。
安装到此完成,之后做troubleshooting.
-----------------------------

Loading mentions Retweet
Filed under  //   linux   nagios   nginx  

Comments [2]

如何写nginx module

Check out this website I found at timyang.net

如何写nginx module

对于一些访问量特别大,业务逻辑也相对简单的Web调用来说,通过一个nginx module来实现是一种比较好的优化方法。实现一个nginx module实际上比较简单。

1. nginx 配置添加

./configure --add-module=/path/to/module1/source

2. 添加 /path/to/module1/source/config 文件,内容

ngx_addon_name=ngx_http_hello_module
HTTP_MODULES="$HTTP_MODULES ngx_http_hello_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_hello_module.c"
CORE_LIBS="$CORE_LIBS -lfoo"

最后一行如果没有使用其他library, 可以去掉

3. 源代码 /path/to/module1/source/ngx_http_hello_module.c, 主要的业务逻辑在make_http_get_body 中完善。典型的hello world源代码如下

Loading mentions Retweet
Filed under  //   nginx  

Comments [0]

awstats 分析 Nginx 访问日志

# /usr/local/awstats/tools/awstats_buildstaticpages.pl -update  \
-config=www.moabc.net -lang=cn -dir=/data/admin_web/awstats  \
-awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl


上述命令的具体意思如下:

    * /usr/local/awstats/tools/awstats_buildstaticpages.pl Awstats 静态页面生成工具
    * -update -config=www.moabc.net 更新配置项
    * -lang=cn 语言为中文
    * -dir=/data/admin_web/awstats 统计结果输出目录
    * -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl Awstats 日志更新程序路径。

Loading mentions Retweet
Filed under  //   awstats   linux   nginx  

Comments [0]

结合nginx的内嵌perl-module,实现高性能的web静态化

到底web服务器的极限是多少呢?100 r/s? 500 r/s?还是1000 r/s?

StaticGenerator上看到,原来1000 r/s都不算什么.

真的是这样吗?如果是真的那就太恐怖了。

Loading mentions Retweet
Filed under  //   linux   nginx  

Comments [0]

使用nginx配置多个php fastcgi负载均衡

Comments [0]

nginx实践一支持perl模块

我们有部分服务器称为队列服务器(nginx),主要接收静态文件,后端队列程序主要处理access日志,但是我们知道rename access log后,后续的请求就不会记录到access log中,从效率考虑也不想用动态程序接受log,所以采取了nginx同perl结合的方式,使用prel脚本来记录日志文件.

Loading mentions Retweet
Filed under  //   linux   nginx  

Comments [0]