<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>supersun&apos;s space</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/" />
    <link rel="self" type="application/atom+xml" href="http://supersun.info/atom.xml" />
    <id>tag:,2008-11-03:/8</id>
    <updated>2009-08-06T08:16:38Z</updated>
    <subtitle>让系统保持在系统管理员掌握之中的关键，就是让尽可能多的任务自动完成……</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Open Source 4.21-zh-cn</generator>

<entry>
    <title>红烧鸡块</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/08/post-141.html" />
    <id>tag:supersun.biz,2009://8.943</id>

    <published>2009-08-06T08:07:37Z</published>
    <updated>2009-08-06T08:16:38Z</updated>

    <summary>原料：    鸡，蒜，姜，葱，香菇调味料：    盐，老抽，糖，鸡精做法：1、将...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Life" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[<pre>原料：<br /><br />    鸡，蒜，姜，葱，香菇<br /><br />调味料：<br /><br />    盐，老抽，糖，鸡精<br /><br />做法：<br /><br />1、将鸡斩成小块，蒜去皮拍烂，姜拍烂，葱切成段，香菇对切；<br /><br />2、锅里下油，鸡块放入锅中，炒至颜色变白后加水600-700毫升；<br /><br />3、锅中加入1汤匙酱油，2汤匙糖，少许盐、鸡精；<br /><br />4、大火煮开之后，小火炖煮至水基本上收干即可。<br /></pre> ]]>
        
    </content>
</entry>

<entry>
    <title>啤酒烧鸭</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/08/post-131.html" />
    <id>tag:supersun.biz,2009://8.942</id>

    <published>2009-08-01T08:07:15Z</published>
    <updated>2009-08-01T08:13:30Z</updated>

    <summary><![CDATA[原料：鸭子&nbsp; 半只&nbsp; 啤酒&nbsp; 一罐&nbsp; 姜...]]></summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Life" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[原料：<br /><br />鸭子&nbsp; 半只&nbsp; 啤酒&nbsp; 一罐&nbsp; 姜&nbsp; 4小块&nbsp; 冰糖&nbsp; 适量<br /><br />调味料：<br /><br />盐&nbsp; 老抽 <br /><br />做法：<br /><br />1&nbsp; 把鸭子剁块，锅中加水烧开，放入鸭子煮几分钟，捞出沥干水分<br /><br />&nbsp;2&nbsp; 炒锅加油烧热，放入鸭块和姜翻炒，盖上锅盖闷一会，逼出水分打开盖子把鸭子炒干<br /><br />&nbsp;3&nbsp; 转小火加老抽冰糖和盐炒匀，开大火加入啤酒，把汁烧的浓稠即可<br /><br />切的丁小了点,难看点,味道还不错。<br /><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://supersun.biz/image/IMG_1437.JPG"><img alt="IMG_1437.JPG" src="http://supersun.biz/assets_c/2009/08/IMG_1437-thumb-644x482.jpg" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" height="482" width="644" /></a></span><br /><br /><br /> <div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>DBD-mysql安装出错处理</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/07/dbd-mysql.html" />
    <id>tag:supersun.biz,2009://8.941</id>

    <published>2009-07-06T08:37:44Z</published>
    <updated>2009-07-06T08:40:39Z</updated>

    <summary>mysql安装在/usr/local/下perl Makefile.PL --m...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[mysql安装在/usr/local/下<br /><br />perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config --testuser=root --testpassword=s3kr1t<br />make<br />make test<br />出现以下错误:<br />PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t<br />t/00base....................String found where operator expected at t/00base.t line 20, near "BAIL_OUT "Unable to load DBI""<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Do you need to predeclare BAIL_OUT?)<br />String found where operator expected at t/00base.t line 21, near "BAIL_OUT "Unable to load DBD::mysql""<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Do you need to predeclare BAIL_OUT?)<br />syntax error at t/00base.t line 20, near "BAIL_OUT "Unable to load DBI""<br />syntax error at t/00base.t line 21, near "BAIL_OUT "Unable to load DBD::mysql""<br />BEGIN not safe after errors--compilation aborted at t/00base.t line 22.<br /># Looks like your test died before it could output anything.<br />t/00base....................dubious<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Test returned status 2 (wstat 512, 0x200)<br />DIED. FAILED tests 1-6<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Failed 6/6 tests, 0.00% okay<br />t/10connect.................Use of uninitialized va<br />lue in concatenation (.) or string at t/10connect.t line 20.<br />skipped<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all skipped: ERROR:&nbsp; Can't continue test<br />t/20createdrop..............Use of uninitialized value in concatenation (.) or string at t/20createdrop.t line 19.<br />skipped<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all skipped: ERROR: . Can't continue test<br />t/25lockunlock..............Use of uninitialized value in concatenation (.) or string at t/25lockunlock.t line 23.<br />skipped<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all skipped: Can't connect to database ERROR: . Can't continue test<br />t/29warnings................skipped<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all skipped: ERROR: install_driver(mysql) failed: Can't load '/usr/local/DBD-mysql-4.008/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.16: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.<br />t/30insertfetch.............Use of uninitialized value in concatenation (.) or string at t/30insertfetch.t line 18.<br />skipped<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all skipped: ERROR: . Can't continue <br />test<br />t/31insertid................Use of uninitialized value in concatenation (.) or string at t/31insertid.t line 18.<br />make: *** [test_dynamic] Interrupt<br /><br />从这里找到出错的原因<a href="http://mail.pm.org/pipermail/za-pm/2008q4/000320.html"><br />http://mail.pm.org/pipermail/za-pm/2008q4/000320.html</a><br /><br />|&gt; Ok, the problem seems to be your version of Test::More. Upgrade it to<br />|&gt; Test-Simple-0.80 and try the tests again:<br /><br /><br /><b>升级Test-Simple</b><br /><br />make test<br />继续出错<br />Can't load '/usr/local/DBD-mysql-4.008/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.16: <br /><br />ln -s /usr/local/mysql-5.1.30-linux-x86_64-glibc23/lib/libmysqlclient.so.16 /usr/lib64/<br /><br />make test<br /><br />测试顺利通过<br /><br />另外还可以参考这篇文章<br /><a href="http://blog.c1gstudio.com/archives/183">http://blog.c1gstudio.com/archives/183</a><br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>mod_perl的安装过程</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/05/mod-perl.html" />
    <id>tag:supersun.biz,2009://8.940</id>

    <published>2009-05-23T14:24:07Z</published>
    <updated>2009-05-23T14:26:53Z</updated>

    <summary>可参考这篇文章，很不错：http://pyh7.spaces.live.com/...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apache" label="apache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mod_perl" label="mod_perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[可参考这篇文章，很不错：<br />http://pyh7.spaces.live.com/blog/cns!47D8D44208AC51E5!128.entry<br /><br />mod_perl下载地址:<br />http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz<br /><br />Apache2::Request <br />http://search.cpan.org/~joesuf/libapreq2-2.12/glue/perl/lib/Apache2/Request.pm<br />http://search.cpan.org/CPAN/authors/id/J/JO/JOESUF/libapreq2-2.12.tar.gz<br /><br /><br /><br />在/home/modperl下安装mod_perl和libapreq2<br /><br />cd /home/modeperl<br />tar zxvf mod_perl-2.0-current.tar.gz<br />cd mod_perl-2.0.4/<br />perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs<br />make<br />make test<br />make install<br /><br />编译libapreq2 for apache2<br />cd /home/modeperl<br />tar zxvf libapreq2-2.12.tar.gz<br />cd libapreq2-2.12<br />./configure --with-expat=/usr/local/apr-util/ --with-apache2-apxs=/usr/local/apache2/bin/apxs<br />make<br />make test<br />make install<br /><br />配置httpd.conf<br />LoadModule perl_module&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modules/mod_perl.so<br />LoadModule apreq_module&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modules/mod_apreq2.so<br /><br /><br />再安装Apache2::Request模块<br />perl Make.PL&nbsp; --with-expat=/usr/local/apr-util/ --with-apache2-apxs=/usr/local/apache2/bin/apxs<br />make<br />make test<br />make install<br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>系统的平均负载loadavg</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/05/loadavg.html" />
    <id>tag:supersun.biz,2009://8.939</id>

    <published>2009-05-08T08:38:31Z</published>
    <updated>2009-05-08T08:42:04Z</updated>

    <summary><![CDATA[man proc得到以下解释：&nbsp;&nbsp;&nbsp;&nbsp;&...]]></summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="linux" label="linux" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="loadavg" label="loadavg" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="平均负载" label="平均负载" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[man proc得到以下解释：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /proc/loadavg<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The&nbsp; load&nbsp; average&nbsp; numbers&nbsp; give the number of jobs in the run queue (state R) or waiting for disk I/O (state D) averaged over 1, 5, and 15 minutes.&nbsp; They are the<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; same as the load average numbers given by uptime(1) and other programs.<br />使用ps找出这两种状态的进程数<br />ps aux |grep ' [D|R] '|wc -l<br />上面所获得的值和uptime得到的值基本相同。<br />如果状态为R的进程数很多，说明CPU瓶颈，如果状态为D的进程很多，说明IO出现瓶颈。<br /><br />&nbsp;&nbsp;&nbsp; 一般来说只要每个CPU的当前活动进程数不大于3那么系统的性能就是良好的，如果每个CPU的任务数大于5，那么就表示这台机器的性能有严重问题。对于上面的例子来说，假设系统有两个CPU，那么其每个CPU的当前任务数为：8.13/2=4.065。这表示该系统的性能是可以接受的。<br /><br />相关链接:<br /><a href="http://www.hiadmin.com/uptime%E5%91%BD%E4%BB%A4%E8%A7%A3%E9%87%8A/">http://www.hiadmin.com/uptime%E5%91%BD%E4%BB%A4%E8%A7%A3%E9%87%8A/</a><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>进程打开文件数目限制</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/post-119.html" />
    <id>tag:supersun.biz,2009://8.937</id>

    <published>2009-04-22T14:48:33Z</published>
    <updated>2009-04-22T14:56:09Z</updated>

    <summary>单进程打开文件数上限设置编缉文件/etc/security/limits.con...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="tunning" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="linux" label="Linux" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="proc" label="Proc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tunning" label="tunning" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[单进程打开文件数上限设置<br />编缉文件/etc/security/limits.conf<br /><br />* - nofile 65536<br /><br />此文件还可以对特定的用户进行限制<br /><br />如果在/etc/rc.local中运行程序，涉及到文件数的限制<br />在运行命令前添加：<br /><br />ulimit -SHn 65536<br /><br />查看单进程打开文件数上限:<br /><br />ulimit -n<br /><br /><br />所有进程打开文件数的限制<br />/proc/sys/fs/file-max<br /><br /><br />同时要更改<br /><br />/proc/sys/fs/inode-max<br /><br />此值为file-max的3-4倍，具本描述查看man文档<br /><br />man proc<br /><br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>处理&quot;工具-文件夹选项&quot;消灭</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/-.html" />
    <id>tag:supersun.biz,2009://8.936</id>

    <published>2009-04-17T08:43:24Z</published>
    <updated>2009-04-17T08:46:25Z</updated>

    <summary>启动&quot;组策略&quot;：开始-运行-gpedit.msc-确定左侧&quot;用户配置&quot;-管理模板...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="windows" label="windows" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[启动"组策略"：开始-运行-gpedit.msc-确定<br /><br />左侧"用户配置"-管理模板-windows组件-windows资源管理器<br /><br />右侧双击第三项：&nbsp; 从"工具"菜单删除"文件夹选项"菜单<br /><br />选中"已禁用"-确定 ]]>
        
    </content>
</entry>

<entry>
    <title>dmidecode</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/dmidecode.html" />
    <id>tag:supersun.biz,2009://8.935</id>

    <published>2009-04-17T08:01:59Z</published>
    <updated>2009-04-17T08:07:54Z</updated>

    <summary><![CDATA[&nbsp;&nbsp;&nbsp; dmidecode&nbsp; is a ...]]></summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[&nbsp;&nbsp;&nbsp; dmidecode&nbsp; is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other&nbsp; useful&nbsp; pieces&nbsp; of&nbsp; information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware.&nbsp; While this is a good point in terms of report speed and safeness, this&nbsp; also&nbsp; makes the presented information possibly unreliable.<br /><br /><a href="http://www.lijie.org/2009/02/dmidecode_24.html">使用dmidecode命令查看硬件信息</a><br /><a href="http://bbs.chinaunix.net/viewthread.php?tid=610006&amp;page=0#pid4080540">Linux下如何获取主板序列号信息</a><br /><br />]]>
        
    </content>
</entry>

<entry>
    <title>windows下的md5sum</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/windowsmd5sum.html" />
    <id>tag:supersun.biz,2009://8.934</id>

    <published>2009-04-17T03:24:43Z</published>
    <updated>2009-04-17T03:32:08Z</updated>

    <summary>命令行工具：http://downloads.activestate.com/c...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="md5sum" label="md5sum" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[命令行工具：<br />http://downloads.activestate.com/contrib/md5sum/Windows/md5sum.exe<br />将其存放至<br />C:\WINDOWS\system32<br />cmd-&gt;所要验证的目录:<br />D:\test&gt;md5sum test.gz<br /><br />GUI软件: winMd5Sum<br />http://www.nullriver.com/downloads/Install-winMd5Sum.exe<br />如果文件太大的话，不是很好用。<br /><br /><br /><br />]]>
        
    </content>
</entry>

<entry>
    <title>Linux企业集群</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/linux-8.html" />
    <id>tag:supersun.biz,2009://8.933</id>

    <published>2009-04-14T14:48:16Z</published>
    <updated>2009-04-14T14:50:17Z</updated>

    <summary>http://book.51cto.com/art/200806/76015.h...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[<a href="http://book.51cto.com/art/200806/76015.htm">http://book.51cto.com/art/200806/76015.htm</a><br /><br />读完这本书后,对Linux集群有新的认识。<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>dreamhost中禁用CGI</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/dreamhostcgi.html" />
    <id>tag:supersun.biz,2009://8.932</id>

    <published>2009-04-12T14:07:09Z</published>
    <updated>2009-04-12T14:11:13Z</updated>

    <summary>在需要禁用CGI的目录中创建.htaccess文件,内容如下:Options +...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Life" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[在需要禁用CGI的目录中创建.htaccess文件,内容如下:<br /><br />Options +IncludesNoExec -ExecCGI<br /><br />这样,此目录下的文件就会不以CGI方式运行了。<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>使用Perl进行web制表</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/04/perlweb.html" />
    <id>tag:supersun.biz,2009://8.931</id>

    <published>2009-04-10T10:43:41Z</published>
    <updated>2009-05-19T05:02:17Z</updated>

    <summary>ChartDirectorhttp://www.advsofteng.com/下...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[ChartDirector<br />http://www.advsofteng.com/<br />下载地址<br />http://www.advsofteng.com/download.html<br /><br />安装ChartDirector<br />使用<br />perl -V<br />得到perl的@INC<br />将lib下的内容copy到INC的任一路径中<br /><br />cd ChartDirector<br />cp -rf lib/*&nbsp; /usr/lib/perl5/5.8.5/<br />如果自己定制目录的话,在编写脚本时,可在脚本头部加如下代码:<br />如:<br />use lib "/home/supersun/ChartDirector/lib/";<br /><br /><a href="http://supersun.biz/script/chart_create.txt"><br />chart_create.pl</a> <br /><br />用法:<br />chart_create.pl&nbsp; -f 数据文件 -m 图表类型 -t 图表标题 -p 图片文件名 -x X轴标题 -y Y轴标题<br />图表类型为:<br />bar 柱状图<br />line&nbsp;&nbsp; &nbsp;曲线图<br />数据文件格式:<br />date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; host1&nbsp;&nbsp;&nbsp;&nbsp; host2&nbsp;&nbsp;&nbsp;&nbsp; host3&nbsp;&nbsp;&nbsp;&nbsp; host4&nbsp;&nbsp;&nbsp;&nbsp; host5&nbsp;&nbsp;&nbsp;&nbsp; host6&nbsp;&nbsp;&nbsp;&nbsp; host7&nbsp;&nbsp;&nbsp;&nbsp; host8<br />20090101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3031132 3253513 3035196 3130065 3323986 3024694 3076513 3287113<br />20090102&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3610310 3545421 3332149 3862804 3352384 3361875 3341946 3412295<br />20090103&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3756983 3815154 3997797 3941998 3760445 3730529 3721120 3672436<br />20090104&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3926538 3875646 3902116 4038819 4058506 3886227 3846330 4052068<br />20090105&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3905990 4000435 3936811 3863121 3843673 3844999 3786345 3868149<br /><br />#!/usr/bin/perl<br />#chart_create.pl<br />#author: supersun06@gmail.com<br />#url:&nbsp; http://supersun.biz<br />use strict;<br />use lib dirname($0);<br /><br />use perlchartdir;<br />use Getopt::Std;<br /><br />sub line_grap;<br />sub bar_grap;<br />sub usage;<br /><br />my %opts;<br />getopt('fmtpxy',\%opts);<br /><br />my $file=$opts{f};<br />my $mode=$opts{m};<br />my $title=$opts{t};<br />my $png_file=$opts{p};<br />my $x_title=$opts{x};<br />my $y_title=$opts{y};<br /><br />$x_title="X" if $x_title eq '';<br />$y_title="Y" if $y_title eq '';<br />usage unless $mode eq "line" || $mode eq "bar";<br />usage if&nbsp; -z $title || -z $png_file;<br />die "$file isn't exsit\n" unless -f $file;<br /><br /><br /><br />my $data={};<br />open FD,$file;<br />my @entries=&lt;FD&gt;;<br />my $head=[];<br />@{$head}=split /\s+/,$entries[0];<br />foreach my $entry (@entries){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chomp $entry;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my @utils=split /\s+/,$entry;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $i (0..scalar(@$head)-1){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push @{$$data{$$head[$i]}},$utils[$i];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />}<br />if($mode eq "bar"){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bar_grap($png_file,$title,$x_title,$y_title,$head,$data);<br />}else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line_grap($png_file,$title,$x_title,$y_title,$head,$data);<br />}<br /><br /><br /><br /><br />sub usage {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "$0 -f datafile -m line|bar -t graph_title -p image_name -x x_title -y y_title\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br />}<br /><br />sub line_grap {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($file,$head,$x_title,$y_title,$lable,$data)=@_;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $x_lable_tag=shift @$lable;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "$x_lable_tag\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shift @{$$data{$x_lable_tag}};<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my @corlor=(0xffff00, 0x00ff00, 0x9999ff, 0xff0000, 0x223366,0xff8800, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $c = new XYChart(1200, 400, 0xffffc0, 0x000000, 1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;setPlotArea(80, 50, 1100, 300, 0xffffff, -1, -1, 0xc0c0c0, -1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;addLegend(45, 12, 0, "", 8)-&gt;setBackground($perlchartdir::Transparent);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;addTitle($head, "arialbd.ttf", 9, 0xffffff)-&gt;setBackground($c-&gt;patternColor([0x004000, 0x008000], 2));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;yAxis()-&gt;setTitle($y_title);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;xAxis()-&gt;setTitle($x_title);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;yAxis()-&gt;setLabelFormat("{value}");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;xAxis()-&gt;setLabels($$data{$x_lable_tag});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $layer = $c-&gt;addLineLayer();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $util (@$lable){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $col=shift @corlor;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $tag=shift @{$$data{$util}};<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $layer-&gt;addDataSet($$data{$util}, $col, $tag)-&gt;setDataSymbol($perlchartdir::SquareSymbol, 7);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #$layer-&gt;setDataLabelFormat("{value}");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;makeChart("$file")<br />}<br /><br />sub bar_grap {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($file,$head,$x_title,$y_title,$lable,$data)=@_;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $x_lable_tag= shift @$lable;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "$x_lable_tag\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shift @{$$data{$x_lable_tag}};<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my @corlor=(0xffff00, 0x00ff00, 0x9999ff, 0xff0000, 0x223366,0xff8800, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $c = new XYChart(1200, 400);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;addTitle($head, "", 10);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;setPlotArea(80, 50, 1100, 300, 0xffffc0, 0xffffe0);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;addLegend(55, 18, 0, "", 8)-&gt;setBackground($perlchartdir::Transparent);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;yAxis()-&gt;setTitle($y_title);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;xAxis()-&gt;setTitle($x_title);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;yAxis()-&gt;setTopMargin(20);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;xAxis()-&gt;setLabels($$data{$x_lable_tag});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $layer = $c-&gt;addBarLayer2($perlchartdir::Side, 7);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $util (@$lable){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $col=shift @corlor;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $tag=shift @{$$data{$util}};<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $layer-&gt;addDataSet($$data{$util},$col, "$tag");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c-&gt;makeChart("$file")<br />}<br /><br />运行<br />perl chart_create.pl -f data -m line -t "a test " -p line.png -x date -y pv<br />perl chart_create.pl -f data -m line -t "a test" -p bar.png -x date -y pv<br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://supersun.biz/script/chart_create.txt"><img alt="bar.png" src="http://supersun.biz/assets_c/2009/04/bar-thumb-644x214.png" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" width="644" height="214" /></a></span><br /><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://supersun.biz/image/line.png"><img alt="line.png" src="http://supersun.biz/assets_c/2009/04/line-thumb-644x214.png" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" width="644" height="214" /></a></span><br />Windows下使用方法：<br />下载ActivePerl<br />http://www.activestate.com/activeperl/features/<br />下载ChartDirector，平台选择windows<br />http://download2.advsofteng.com/chartdir_perl_win32.zip<br />下载脚本，将其存放到D:\perl\chartdir_perl_win32\ChartDirector\lib\chart_create.pl<br /><a href="http://supersun.biz/script/chart_create.txt">chart_create.pl</a><br />perl chart_create.pl -f c.txt -m bar -t "a test " -p line.png -x date -y pv<br />运行命令即可。<br /><br /><br /><br /> <div><br /></div><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>awstats按日报表日历界面</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/03/awstats-2.html" />
    <id>tag:supersun.biz,2009://8.930</id>

    <published>2009-03-31T08:59:08Z</published>
    <updated>2009-03-31T09:27:01Z</updated>

    <summary>脚本：perl_calendar.pl使用模块：HTML::Calendar::...</summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="awstats" label="awstats" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[脚本：perl_calendar.pl<br />使用模块：HTML::Calendar::Simple<br />安装模块：<br />cpan HTML::Calendar::Simple<br />如手动，需安装以下两个包:<br />Date-Simple<br />HTML-Calendar-Simple<br />将其存放在cgi目录中添加可执行权限<br /><br />#!/usr/bin/perl -w<br />#Script Name: perl_calendar.pl<br />#author: supersun@gmail.com<br />#url: http://supersun.biz<br />use strict;<br /><br />use HTML::Calendar::Simple;<br />use CGI qw/:all/;<br /><br />my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime;<br />my $awstats_path="/awstats/awstats.pl";<br />print header(-charset=&gt;'gbk');<br />if(param('host')){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $year+=1900;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $mon++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $host=param("host");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $link_tag=1;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print start_html("awstats for $host");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print h1({-align=&gt;"center"},"awstats for $host"),hr({-align=&gt;"center"});<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;table border='1' align='center'&gt;\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;tr&gt;\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $month (01..12)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;tr&gt;\n" if($month =~ /5|9/);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;td valign='top'&gt;";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $cal = HTML::Calendar::Simple-&gt;new({ 'month' =&gt; $month, 'year'&nbsp; =&gt; $year});<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $day (1..31){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $location=$awstats_path."?config=$host&amp;databasebreak=day&amp;day=$day&amp;month=$month";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($month eq $mon &amp;&amp; $day eq $mday ){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $link_tag=0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $cal-&gt;daily_info({'day'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; $day, 'pin_up'=&gt;'now'});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( $link_tag eq 1){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $cal-&gt;daily_info({'day'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; $day, 'day_link' =&gt; $location});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $cal-&gt;daily_info({'day'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; $day });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $html = $cal-&gt;calendar_month;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print $html;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;/td&gt;\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;/tr&gt;\n" if($month =~ /4|8/ );<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;/tr&gt;&lt;/table&gt;\n";<br />}else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "You must input a host: ",start_form,"Host: ",textfield('host'),submit,end_form;<br />}<br />print end_html;<br />界面如下：<br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="perl_calander.jpg的缩略图" src="http://supersun.biz/assets_c/2009/03/perl_calander-thumb-644x389.jpg" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" width="644" height="389" /></span><br />使用awstats按日分析参考：<br /><a href="http://search.cpan.org/CPAN/authors/id/I/IZ/IZUT/Date-Simple-3.03.tar.gz">http://www.chedong.com/blog/archives/001293.html</a><br /><br /><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>FTP传输模式binary和ASCII的区别</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/03/ftpbinaryascii.html" />
    <id>tag:supersun.biz,2009://8.929</id>

    <published>2009-03-31T07:30:04Z</published>
    <updated>2009-03-31T07:37:18Z</updated>

    <summary><![CDATA[&nbsp;&nbsp;&nbsp; 使用Net::FTP从FTP服务器上下载文...]]></summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="ftp" label="FTP" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[&nbsp;&nbsp;&nbsp; 使用Net::FTP从FTP服务器上下载文件,发现部分文件下载后大小有出入，可能是使用ASCII传输方式造成的。<br /><br />查一下FTP的两种传输模式的区别：<br /><br />ASCII模式和BINARY模式的区别是回车换行的处理，binary模式不对数据进行任何处理，asci模式将回车换行转换为本机的回车字符，比如<br />Unix下是\n,Windows下是\r\n，Mac下是\r<br /><br />ascii模式下会转换文件<br />不能说是不同系统对回车换行解释不同<br />而是不同的系统有不同的行结束符<br />unix系统下行结束符是一个字节，即十六进制的0A<br />而ms的系统是两个字节，即十六进制的0D0A<br />所以当你用ascii方式从unix的ftp&nbsp; server下载文件时(不管是二进制或者文本文件)，每检测到一个<br /><br />字节是0A，就会自动插入一个0D，所以如果你的文件是二进制文件比如可执行文件、压缩包什么的，就肯<br /><br />定不能用了。如果你的文件就是unix下的文本文件，你用ascii模式是正确的，要是误用了binary模式，<br /><br />你在windows上看这个文件是没有换行的，里面是一个个的黑方块。<br />一般来说，我们最好都用binary方式，这样可以保证不出错。如果有文本格式转换的问题，即unix格式<br /><br />的文本和dos格式的文本之间的转换，<br /><br />所以，可以采用这样的习惯：<br />所有的FTP传输都采用binary方式，但是在windows下面编辑的文件需要事先转换成Unix模式，这个可以使用<br />UltraEdit的conversion功能，也可以在UltraEdit下面另存为Unix Terminators-LF的格式。<br /><br />原文见：<br /><a href="http://blog.chinaunix.net/u1/56521/showart_1183437.html">http://blog.chinaunix.net/u1/56521/showart_1183437.html</a><br />百度百科：FTP<br /><a href="http://baike.baidu.com/view/369.htm">http://baike.baidu.com/view/369.htm</a><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>inotify监控文件的更改</title>
    <link rel="alternate" type="text/html" href="http://supersun.info/2009/03/inotify-1.html" />
    <id>tag:supersun.biz,2009://8.927</id>

    <published>2009-03-20T06:48:00Z</published>
    <updated>2009-03-20T07:46:23Z</updated>

    <summary><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 脚本读取目录列表(...]]></summary>
    <author>
        <name>supersun</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="SysAdmin" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="inotify" label="inotify" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="linux" label="linux" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="syslog" label="syslog" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="zh-cn" xml:base="http://supersun.info/">
        <![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 脚本读取目录列表(脚本所在目录下的db.conf),将目录添加到inotify监控中,被监控目录下新创建的目录也会被添加到监控中去.被监控目录下创建的文件或文件内容被更改后,脚本以日志的方式文件名发送给本机的syslog。脚本发送日志时使用的facility为local2,priority为info，进程名为inotifyd。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 脚本的内容如下：<br />#!/usr/bin/perl <br /><br />use strict;<br />use Event;<br />use Linux::Inotify2;<br />use POSIX;<br />use IO::File;<br />use Sys::Syslog qw(:DEFAULT setlogsock);<br /><br />my $script_dir="/opt/";<br />our $CONF_FILE=$script_dir."db.conf";<br /><br /><br />#For Daemon <br />###################################################<br />sub daemonize {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chdir "/";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open STDIN, "&lt;/dev/null";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open STDOUT, "&gt;/dev/null";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open STDERR, "&gt;&amp;STDOUT";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defined(my $pid=fork) or die "Can't fork: $!\n";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit if($pid);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; POSIX::setsid() or die "Can't start a new session: $!";<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; umask 0;<br />}<br /><br />sub add_watch {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($inotify,$log_file)=@_;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open FH,$log_file;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(&lt;FH&gt;){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $file=$_;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chomp $file;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $inotify-&gt;watch ($file, IN_ALL_EVENTS, \&amp;mywatch)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close FH;<br />}<br /><br />####################################################<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />&amp;daemonize;<br /><br />my $ident="inotify";<br />my $logopt="ndelay";<br />my $facility="local2";<br />my $priority="info";<br />openlog $ident, $logopt, $facility;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # don't forget this<br /><br /><br />our $INOTIFY_OBJECT=new Linux::Inotify2;<br />Event-&gt;io (fd =&gt; $INOTIFY_OBJECT-&gt;fileno, poll =&gt; 'r', repeat =&gt; 1, cb =&gt; sub { $INOTIFY_OBJECT-&gt;poll });<br /><br />Event-&gt;signal (signal =&gt; 'HUP',cb =&gt; \&amp;re_conf); <br /><br />add_watch($INOTIFY_OBJECT,$CONF_FILE);<br /><br />Event::loop;<br /><br />sub re_conf{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add_watch($INOTIFY_OBJECT,$CONF_FILE);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Event::loop;<br />}<br /><br /><br />sub mywatch {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $e = shift;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $PATH= $e-&gt;fullname;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $MASK= $e-&gt;mask;<br />&nbsp;&nbsp; <br />&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($e-&gt;IN_ISDIR){<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if($e-&gt;IN_CREATE){<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $INOTIFY_OBJECT-&gt;watch($PATH,IN_ALL_EVENTS, \&amp;mywatch);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if($e-&gt;IN_MODIFY || $e-&gt;IN_CREATE){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog($priority,$PATH);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />}<br /><br />例如，我们需要监控/data下的目录：<br /><br />将脚本保存在/opt下命名为inotifyd.pl<br />安装脚本使用的模块：<br />cpan Event<br />cpan Linux::Inotify2<br />cpan Sys::Syslog<br />设定脚本所在目录<br />vi /opt/inotifyd.pl<br />my $script_dir="/opt/";<br />检测脚本是否可运行：<br /><br />[supersun@supersun.biz opt]$ perl -c inotifyd.pl<br />inotifyd.pl syntax OK<br /><br /><br />配置syslog.conf，添加以下的行：<br />local2.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /var/log/inotify.log<br />或将日志发送给日志主机loghost<br />local2.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @loghost<br /><br />更改message行:<br />auth,authpriv,cron,daemon,kern,lpr,news,syslog,user.info;mail.none;authpriv.none;cron.none&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /var/log/messages<br />不然的话inotify的日志也会发送至/var/log/messages中去<br /><br />创建需要监控的目录的列表：<br />find /data -type d &gt;/opt/db.conf<br /><br />启动脚本<br />perl inotifyd.pl<br /><br />脚本接收HUP信号，重新读加监控目录列表，将上次未加载的录添加到监控中。<br /><br />如果目录列表很长的话，使用top查看进程状态，态状为R时，inotifyd.pl正在加载目录列表，状态S时，脚本已开始监控。<br /><br />查看/var/log/inotify.log（根椐自己/etc/syslog.conf中的配置）中的日志输出。<br /><br />Mar 20 15:36:28 supersun.biz inotify: /data/hello.txt<br /><br />syslog使用的udp协议发送日志，如何使syslog监听udp的514端口可以参考<a href="http://supersun.biz/2007/12/post-132.html">将防火墙的日志发送给日志主机</a>。<br /><a href="http://supersun.biz/2009/03/syslog-ng.html">syslog-ng可以使用tcp协议发送日志</a>，也可以通过<a href="http://server.it168.com/server/2007-11-15/200711140845734.shtml">加密的方式发送日志</a>。<br /><br />&nbsp;<br />]]>
        
    </content>
</entry>

</feed>
