# check_fastcgi.pl checks if a php-cgi server (or, theorically, any
# other fastcgi server) is alive.
#
# Copyright (c) 2009 Rodolfo Gonzalez
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# include modules
use strict;
use FCGI::Client;
use IO::Socket::INET;
use Getopt::Long;
# command line parameters with some defaults
my $host = ''; # server host
my $port = 9999; # tcp port
my $script = ''; # test script (absolute path starting at / - root directory -)
my $query_string = ''; # query string
my $expected = 'OK'; # expected string
my $timeout = 5; # timeout in seconds
sub _good()
{
print "OK: fastcgi server is working.";
exit(0);
}
sub _bad()
{
print "FastCGI CRITICAL: fastcgi has not responded.";
exit(2);
}
先使用cpan安装
strict
FCGI::Client
IO::Socket::INET
Getopt::Long
建立一个/tmp/test.php文件
echo "ok" ;
?>
测试 脚本 :
./check_fastcgi.pl -H 127.0.0.1 -p 9000 -s /tmp/test.php -e ok
OK: fastcgi server is working
配置:
我对脚本进行了修改。指定了文件的目录。
可根据个人情况进行修改
my $host = ''; # server host
my $port = 9999; # tcp port
my $script = ''; # test script (absolute path starting at / - root directory -)
my $query_string = ''; # query string
my $expected = 'OK'; # expected string
my $timeout = 5; # timeout in seconds