除了建立 TCP 连接之外,如何检查 FastCGI 服务器是否处于活动状态并正常运行?
我有许多远程、独立的 FastCGI 服务器。我想监视 FastCGI 服务器本身以确保它处于活动状态。仅仅向 Web 服务器发出请求是不够的,因为它会自动绕过死服务器。
谢谢!
除了建立 TCP 连接之外,如何检查 FastCGI 服务器是否处于活动状态并正常运行?
我有许多远程、独立的 FastCGI 服务器。我想监视 FastCGI 服务器本身以确保它处于活动状态。仅仅向 Web 服务器发出请求是不够的,因为它会自动绕过死服务器。
谢谢!
您可以使用FastCGI 开发工具包附带的 cgi-fcgi 程序。在类 Debian 系统和 macports 中,程序包含在 libfcgi 包中。
我的带有 cgi-fcgi 调用的脚本发布在http://gist.github.com/209446
您可以连接到 FastCGI 服务器并发送控制FCGI_GET_VALUES
空请求。fastcgi服务器应该支持,官方libfcgi应该支持。
见http://www.fastcgi.com/devkit/doc/fcgi-spec.html
发送到 Socket 如下:
unsigned char buf[16] = { 1,9,0,0 ,0,0,8,0 , 0,0,0,0, 0,0,0,0};
// fcgi protocols = 1
// fcgi_get_values = 9
// padding = 8 -- for some reason libfcgi expects non-empty body
// body -- empty 8 bytes.
你应该得到
unsigned char buf[8] = { 1, 10,0,0, 0,0,0,0 };
// fcgi_protocol = 1
// fcgi_get_values_response = 10
您实际上应该检查您得到 10 作为响应。