mod_perl的安装过程

| 暂无评论 | 暂无引用通告
可参考这篇文章,很不错:
http://pyh7.spaces.live.com/blog/cns!47D8D44208AC51E5!128.entry

mod_perl下载地址:
http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz

Apache2::Request
http://search.cpan.org/~joesuf/libapreq2-2.12/glue/perl/lib/Apache2/Request.pm
http://search.cpan.org/CPAN/authors/id/J/JO/JOESUF/libapreq2-2.12.tar.gz



在/home/modperl下安装mod_perl和libapreq2

cd /home/modeperl
tar zxvf mod_perl-2.0-current.tar.gz
cd mod_perl-2.0.4/
perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs
make
make test
make install

编译libapreq2 for apache2
cd /home/modeperl
tar zxvf libapreq2-2.12.tar.gz
cd libapreq2-2.12
./configure --with-expat=/usr/local/apr-util/ --with-apache2-apxs=/usr/local/apache2/bin/apxs
make
make test
make install

配置httpd.conf
LoadModule perl_module          modules/mod_perl.so
LoadModule apreq_module         modules/mod_apreq2.so


再安装Apache2::Request模块
perl Make.PL  --with-expat=/usr/local/apr-util/ --with-apache2-apxs=/usr/local/apache2/bin/apxs
make
make test
make install

系统的平均负载loadavg

| 暂无评论 | 暂无引用通告
man proc得到以下解释:
       /proc/loadavg
              The  load  average  numbers  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.  They are the
              same as the load average numbers given by uptime(1) and other programs.
使用ps找出这两种状态的进程数
ps aux |grep ' [D|R] '|wc -l
上面所获得的值和uptime得到的值基本相同。
如果状态为R的进程数很多,说明CPU瓶颈,如果状态为D的进程很多,说明IO出现瓶颈。

    一般来说只要每个CPU的当前活动进程数不大于3那么系统的性能就是良好的,如果每个CPU的任务数大于5,那么就表示这台机器的性能有严重问题。对于上面的例子来说,假设系统有两个CPU,那么其每个CPU的当前任务数为:8.13/2=4.065。这表示该系统的性能是可以接受的。

相关链接:
http://www.hiadmin.com/uptime%E5%91%BD%E4%BB%A4%E8%A7%A3%E9%87%8A/

进程打开文件数目限制

| 暂无评论 | 暂无引用通告
单进程打开文件数上限设置
编缉文件/etc/security/limits.conf

* - nofile 65536

此文件还可以对特定的用户进行限制

如果在/etc/rc.local中运行程序,涉及到文件数的限制
在运行命令前添加:

ulimit -SHn 65536

查看单进程打开文件数上限:

ulimit -n


所有进程打开文件数的限制
/proc/sys/fs/file-max


同时要更改

/proc/sys/fs/inode-max

此值为file-max的3-4倍,具本描述查看man文档

man proc


启动"组策略":开始-运行-gpedit.msc-确定

左侧"用户配置"-管理模板-windows组件-windows资源管理器

右侧双击第三项:  从"工具"菜单删除"文件夹选项"菜单

选中"已禁用"-确定

dmidecode

| 暂无评论 | 暂无引用通告
    dmidecode  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  useful  pieces  of  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.  While this is a good point in terms of report speed and safeness, this  also  makes the presented information possibly unreliable.

使用dmidecode命令查看硬件信息
Linux下如何获取主板序列号信息

windows下的md5sum

| 暂无评论 | 暂无引用通告
命令行工具:
http://downloads.activestate.com/contrib/md5sum/Windows/md5sum.exe
将其存放至
C:\WINDOWS\system32
cmd->所要验证的目录:
D:\test>md5sum test.gz

GUI软件: winMd5Sum
http://www.nullriver.com/downloads/Install-winMd5Sum.exe
如果文件太大的话,不是很好用。



Linux企业集群

| 暂无评论 | 暂无引用通告
http://book.51cto.com/art/200806/76015.htm

读完这本书后,对Linux集群有新的认识。

dreamhost中禁用CGI

| 暂无评论 | 暂无引用通告
在需要禁用CGI的目录中创建.htaccess文件,内容如下:

Options +IncludesNoExec -ExecCGI

这样,此目录下的文件就会不以CGI方式运行了。

使用Perl进行web制表

| 暂无评论 | 暂无引用通告
ChartDirector
http://www.advsofteng.com/
下载地址
http://www.advsofteng.com/download.html

安装ChartDirector
使用
perl -V
得到perl的@INC
将lib下的内容copy到INC的任一路径中

cd ChartDirector
cp -rf lib/*  /usr/lib/perl5/5.8.5/
如果自己定制目录的话,在编写脚本时,可在脚本头部加如下代码:
如:
use lib "/home/supersun/ChartDirector/lib/";


chart_create.pl


用法:
chart_create.pl  -f 数据文件 -m 图表类型 -t 图表标题 -p 图片文件名 -x X轴标题 -y Y轴标题
图表类型为:
bar 柱状图
line    曲线图
数据文件格式:
date                    host1     host2     host3     host4     host5     host6     host7     host8
20090101                3031132 3253513 3035196 3130065 3323986 3024694 3076513 3287113
20090102                3610310 3545421 3332149 3862804 3352384 3361875 3341946 3412295
20090103                3756983 3815154 3997797 3941998 3760445 3730529 3721120 3672436
20090104                3926538 3875646 3902116 4038819 4058506 3886227 3846330 4052068
20090105                3905990 4000435 3936811 3863121 3843673 3844999 3786345 3868149

#!/usr/bin/perl
#chart_create.pl
#author: supersun06@gmail.com
#url:  http://supersun.biz
use strict;
use lib dirname($0);

use perlchartdir;
use Getopt::Std;

sub line_grap;
sub bar_grap;
sub usage;

my %opts;
getopt('fmtpxy',\%opts);

my $file=$opts{f};
my $mode=$opts{m};
my $title=$opts{t};
my $png_file=$opts{p};
my $x_title=$opts{x};
my $y_title=$opts{y};

$x_title="X" if $x_title eq '';
$y_title="Y" if $y_title eq '';
usage unless $mode eq "line" || $mode eq "bar";
usage if  -z $title || -z $png_file;
die "$file isn't exsit\n" unless -f $file;



my $data={};
open FD,$file;
my @entries=<FD>;
my $head=[];
@{$head}=split /\s+/,$entries[0];
foreach my $entry (@entries){
        chomp $entry;
        my @utils=split /\s+/,$entry;
        foreach my $i (0..scalar(@$head)-1){
                push @{$$data{$$head[$i]}},$utils[$i];
        }
}
if($mode eq "bar"){
        bar_grap($png_file,$title,$x_title,$y_title,$head,$data);
}else{
        line_grap($png_file,$title,$x_title,$y_title,$head,$data);
}




sub usage {
        print "$0 -f datafile -m line|bar -t graph_title -p image_name -x x_title -y y_title\n";
        exit;
}

sub line_grap {
        my ($file,$head,$x_title,$y_title,$lable,$data)=@_;

        my $x_lable_tag=shift @$lable;
        print "$x_lable_tag\n";
        shift @{$$data{$x_lable_tag}};
        my @corlor=(0xffff00, 0x00ff00, 0x9999ff, 0xff0000, 0x223366,0xff8800, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6);

        my $c = new XYChart(1200, 400, 0xffffc0, 0x000000, 1);
        $c->setPlotArea(80, 50, 1100, 300, 0xffffff, -1, -1, 0xc0c0c0, -1);
        $c->addLegend(45, 12, 0, "", 8)->setBackground($perlchartdir::Transparent);
        $c->addTitle($head, "arialbd.ttf", 9, 0xffffff)->setBackground($c->patternColor([0x004000, 0x008000], 2));
        $c->yAxis()->setTitle($y_title);
        $c->xAxis()->setTitle($x_title);
        $c->yAxis()->setLabelFormat("{value}");
        $c->xAxis()->setLabels($$data{$x_lable_tag});
        my $layer = $c->addLineLayer();
        foreach my $util (@$lable){
                my $col=shift @corlor;
                my $tag=shift @{$$data{$util}};
                $layer->addDataSet($$data{$util}, $col, $tag)->setDataSymbol($perlchartdir::SquareSymbol, 7);
        }



        #$layer->setDataLabelFormat("{value}");
        $c->makeChart("$file")
}

sub bar_grap {
        my ($file,$head,$x_title,$y_title,$lable,$data)=@_;
        my $x_lable_tag= shift @$lable;
        print "$x_lable_tag\n";
        shift @{$$data{$x_lable_tag}};

        my @corlor=(0xffff00, 0x00ff00, 0x9999ff, 0xff0000, 0x223366,0xff8800, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6);

        my $c = new XYChart(1200, 400);
        $c->addTitle($head, "", 10);
        $c->setPlotArea(80, 50, 1100, 300, 0xffffc0, 0xffffe0);
        $c->addLegend(55, 18, 0, "", 8)->setBackground($perlchartdir::Transparent);
        $c->yAxis()->setTitle($y_title);
        $c->xAxis()->setTitle($x_title);
        $c->yAxis()->setTopMargin(20);
        $c->xAxis()->setLabels($$data{$x_lable_tag});
        my $layer = $c->addBarLayer2($perlchartdir::Side, 7);
        foreach my $util (@$lable){
                my $col=shift @corlor;
                my $tag=shift @{$$data{$util}};
                $layer->addDataSet($$data{$util},$col, "$tag");
        }
        $c->makeChart("$file")
}

运行
perl chart_create.pl -f data -m line -t "a test " -p line.png -x date -y pv
perl chart_create.pl -f data -m line -t "a test" -p bar.png -x date -y pv
bar.png

line.png
Windows下使用方法:
下载ActivePerl
http://www.activestate.com/activeperl/features/
下载ChartDirector,平台选择windows
http://download2.advsofteng.com/chartdir_perl_win32.zip
下载脚本,将其存放到D:\perl\chartdir_perl_win32\ChartDirector\lib\chart_create.pl
chart_create.pl
perl chart_create.pl -f c.txt -m bar -t "a test " -p line.png -x date -y pv
运行命令即可。





awstats按日报表日历界面

| 暂无评论 | 暂无引用通告
脚本:perl_calendar.pl
使用模块:HTML::Calendar::Simple
安装模块:
cpan HTML::Calendar::Simple
如手动,需安装以下两个包:
Date-Simple
HTML-Calendar-Simple
将其存放在cgi目录中添加可执行权限

#!/usr/bin/perl -w
#Script Name: perl_calendar.pl
#author: supersun@gmail.com
#url: http://supersun.biz
use strict;

use HTML::Calendar::Simple;
use CGI qw/:all/;

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime;
my $awstats_path="/awstats/awstats.pl";
print header(-charset=>'gbk');
if(param('host')){
        $year+=1900;
        $mon++;
        my $host=param("host");
        my $link_tag=1;

        print start_html("awstats for $host");
        print h1({-align=>"center"},"awstats for $host"),hr({-align=>"center"});

        print "<table border='1' align='center'>\n";
        print "<tr>\n";
        foreach my $month (01..12)
        {
                print "<tr>\n" if($month =~ /5|9/);
                print "<td valign='top'>";
                my $cal = HTML::Calendar::Simple->new({ 'month' => $month, 'year'  => $year});

                foreach my $day (1..31){
                        my $location=$awstats_path."?config=$host&databasebreak=day&day=$day&month=$month";
                        if($month eq $mon && $day eq $mday ){
                                $link_tag=0;
                                $cal->daily_info({'day'      => $day, 'pin_up'=>'now'});
                        }
                        if( $link_tag eq 1){
                                $cal->daily_info({'day'      => $day, 'day_link' => $location});
                        }else{
                                $cal->daily_info({'day'      => $day });
                        }
                }
                my $html = $cal->calendar_month;

                print $html;
                print "</td>\n";
                print "</tr>\n" if($month =~ /4|8/ );

        }
        print "</tr></table>\n";
}else{
        print "You must input a host: ",start_form,"Host: ",textfield('host'),submit,end_form;
}
print end_html;
界面如下:
perl_calander.jpg的缩略图
使用awstats按日分析参考:
http://www.chedong.com/blog/archives/001293.html


最新资源

  • line.png
  • bar.png
  • perl_calander.jpg

最近评论

最新资源

  • line.png
  • bar.png
  • perl_calander.jpg

首页归档页可以看到最新的日记和所有日记。