正在加载...
分页: 83/186 第一页 上页 78 79 80 81 82 83 84 85 86 87 下页 最后页 [ 显示模式: 摘要 | 列表 ]

PHP版iis日志分析程序

[ 2009/06/10 01:36 | by selboo ]

<?php
/*******************************************************
*功能:iis日志分析,分析出访问IP总数,搜索引擎抓取次数
*说明:
*       将日志文件放在网站根目录,并改名为log.log。
*演示:http://www.zhanzhangpu.com/tools/iislog/
*       http://www.zhanzhangpu.com/tools/iislog/demo.gif
*作者:blackli,来自落伍者
*问题:搜索引擎蜘蛛地址不准确,尤其是google蜘蛛地址,国内流行的地址列
*       表存在相当大的误差,能力有限,不能够解决这个问题。有兴趣的可以参考
*       下面的网址.
*参考:http://www.seonewthing.com/googleBotCheck.aspx
*       http://googlewebmastercentral.blogspot.com/2006/09/how-to-verify-googlebot.html
*******************************************************/

        //打开日志文件
        $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
        $fp = fopen("$DOCUMENT_ROOT/log.log",'rb');
        if ( !$fp )
        {
                echo '打开文件失败';
                exit;
        }

        //分析每行日志
        $num_ip = 0;    //访问IP总数
        $ip = array();    //IP数据数组,其中ip[$i][0]为IP地址、ip[$i][1]为该地址出现次数
        while ( !feof($fp) )
        {
                $line = fgets($fp,1001);
                if ( substr($line,0,1) == '#' )
                {
                        //获取日志生成时间
                        if ( substr($line,0,5) == '#Date' )
                        {
                                $date_info = explode(' ',$line);
                                //echo '日志生成时间:'.$date_info[1].'  '.$date_info[2].'</br>';
                        }
                }
                else
                {
                        //获取访问IP
                        if ( $line == '' ) continue;
                        $ip_info = explode(' ',$line);

                        for ( $j = $num_ip-1, $having_ip = false; $j >= 0 ; $j -- )
                        {
                                if ( $ip[$j][0] == $ip_info[6] )
                                {
                                        $having_ip = true;
                                        $ip[$j][1] ++ ;
                                        break;
                                }
                        }
                        if ( $having_ip == false )
                        {
                                $ip[$num_ip][0] = $ip_info[6];
                                $ip[$num_ip][1] = 1;
                                $num_ip ++;
                        }
                }
        }

        //获取搜索引擎蜘蛛访问次数
        //baidu、google蜘蛛地址列表
        $baiduSpider = array('220.181','159.226','202.108','61.135.');
        $googleBot = array('74.125.','209.85.','66.102.','64.233.','64.249','209.85.');

        $num_Spider = $num_googleBot = 0;
        for ( $i = 0; $i < $num_ip ; $i++ )
        {
                //计算百度蜘蛛访问次数
                for ( $j = 0 ; $j < 4 ; $j ++ )
                {

                        if ( substr($ip[$i][0],0,7) == $baiduSpider[$j] )
                        {
                                $num_Spider += $ip[$i][1];
                                continue;
                        }
                }
                //计算google蜘蛛访问次数
                for ( $j = 0 ; $j < 6 ; $j ++ )
                {
                        if ( substr($ip[$i][0],0,7) == $googleBot[$j] )
                        {
                                $num_googleBot += $ip[$i][1];
                                continue;
                        }
                }
        }

        //echo '百度蜘蛛请求'.$num_Spider.'次
';
        //echo 'google蜘蛛请求'.$num_googleBot.'次
';
        fclose($fp);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>iis日志分析-Powered by ZhanZhangPu</title>
<style type="text/css">
#main{
        width:800px;
        margin:0 auto;
        border:1px solid #EEE;
}
#main div{
        background:#EEE;
        border:2px solid #FBFBFB;
        line-height:25px;
        font-size:15px;
        padding:15px;
}
</style>
</head>
<body >
<div id="main">
        <h2>日志生成时间<?php echo $date_info[1].'  '.$date_info[2]; ?></h2>
        <div>
                共有<?php echo $num_ip; ?>IP的请求.

                百度蜘蛛请求<?php echo $num_Spider; ?>次.

                google蜘蛛请求<?php echo $num_googleBot; ?>次.
        </div>
        <div>
                IP地址列表:

                <?php
                        for ( $i = 0 ; $i < $num_ip ; $i ++ )
                        {
                                echo $ip[$i][0].'     '.$ip[$i][1].'次.
';
                        }
                ?>
        </div>
        <div>Powered by <a href="http://www.zhanzhangpu.com">站长铺</a>&trade;</div>
</div>
</body>
</html>
Tags: ,

cmd下邮件发送工具blat

[ 2009/06/09 22:12 | by selboo ]
cmd下发送邮件工具

官方链接
http://www.blat.net/

更多详细命令开帮助了

This is The DOS Code
blat.exe file.txt -to root@selboo.com.cn -subject 主题  -server smtp.gmail.com -f root@selboo.com.cn -u root -pw 123456
Parsed in 0.002 seconds at 72.35 KB/s
Tags: , , ,

ping测试批处理(第二版)

[ 2009/06/08 12:38 | by selboo ]
ping测试批处理

[codes=dos]@echo off
for /f "delims=" %%a in (data.txt) do  (
echo starttime %date:~0,10% %time% >> %%a.ping
start/b ping %%a -n 2 -l 32 >> %%a.ping
start/b tracert -d %%a >> %%a.tracert
)
:a
set c=0
for /f %%a in ('tasklist^|findstr/i "ping.exe tracert.exe"') do set c=1
if %c%==1 goto a
for /f "delims=" %%a in (data.txt) do  (
echo ===================%%a=================== &
Tags: ,

nginx upstream 的几种分配方式

[ 2009/06/05 18:34 | by selboo ]
nginx的upstream目前支持4种方式的分配

1、轮询(默认)

每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除。

2、weight
指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。
例如:
upstream bakend {
server 192.168.0.14 weight=10;
server 192.168.0.15 weight=10;
}

2、ip_hash
每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器,可以解决session的问题。
例如:
upstream bakend {
ip_hash;
server 192.168.0.14:88;
server 192.168.0.15:80;
}

3、fair(第三方)
按后端服务器的响应时间来分配请求,响应时间短的优先分配。
upstream backend {
server server1;
server server2;
fair;
}

4、url_hash(第三方)

按访问url的hash结果来分配请求,使每个url定向到同一个后端服务器,后端服务器为缓存时比较有效。

例:在upstream中加入hash语句,server语句中不能写入weight等其他的参数,hash_method是使用的hash算法

upstream backend {
server squid1:3128;
server squid2:3128;
hash $request_uri;
hash_method crc32;
}

tips:

upstream bakend{#定义负载均衡设备的Ip及设备状态
ip_hash;
server 127.0.0.1:9090 down;
server 127.0.0.1:8080 weight=2;
server 127.0.0.1:6060;
server 127.0.0.1:7070 backup;
}
在需要使用负载均衡的server中增加
proxy_pass http://bakend/;

每个设备的状态设置为:
1.down 表示单前的server暂时不参与负载
2.weight 默认为1.weight越大,负载的权重就越大。
3.max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
4.fail_timeout:max_fails次失败后,暂停的时间。
5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。

nginx支持同时设置多组的负载均衡,用来给不用的server来使用。

client_body_in_file_only 设置为On 可以讲client post过来的数据记录到文件中用来做debug
client_body_temp_path 设置记录文件的目录 可以设置最多3层目录

location 对URL进行匹配.可以进行重定向或者进行新的代理 负载均衡

Tags:

cmd下修改网络配置

[ 2009/06/05 18:26 | by selboo ]
在cmd下修改网络配置信息

C:\Documents and Settings\Administrator>netsh
netsh>interface
netsh interface>ip
netsh interface ip>show address
netsh interface ip>set address "本地连接" static 172.16.28.115 255.255.255.0 gateway=172.16.28.1


以上命令可以一起执行 如下
C:\Documents and Settings\Administrator>netsh interface ip set address "本地连接" static 172.16.28.115 255.255.255.0 gateway=172.16.28.1

Tags: ,
分页: 83/186 第一页 上页 78 79 80 81 82 83 84 85 86 87 下页 最后页 [ 显示模式: 摘要 | 列表 ]