需要有关 Nginx 连接的监控警报的帮助

发布于 2024-10-02 19:37:59 字数 5199 浏览 3 评论 0原文

我希望外面的某个地方能够在这方面帮助我。我的生产环境如下:

Rails 2.3.5
Passenger 2.2.11
Nginx
Monit

似乎一切都按预期工作,但是,每天 2 到 3 次,我收到 Monit 发来的电子邮件,如下所示:

monit alert -- Connection failed nginx

To: [email protected]
Connection failed Service nginx

    Date:        Thu, 11 Nov 2010 10:46:44 +0000
    Action:      restart
    Host:        mydomain
    Description: 'nginx' failed, cannot open a connection to INET[mydomain.com:80] via TCP

Your faithful employee,
monit

然后大约 30 秒后,我收到另一封电子邮件,如下所示:

Connection passed Service nginx

    Date:        Thu, 11 Nov 2010 10:47:16 +0000
    Action:      alert
    Host:        mydomain
    Description: 'nginx' connection passed to INET[mydomain.com:80] via TCP

Your faithful employee,
monit

在我的 monit 配置文件中,我有以下内容:

set daemon 30
check process nginx with pidfile /opt/nginx/logs/nginx.pid
  start program = "/opt/nginx/sbin/nginx"
  stop program = "/opt/nginx/sbin/nginx -s stop"
  if failed host mydomain.com port 80 protocol http request / then restart
  if 5 restarts within 5 cycles then timeout

在当时的 Nginx 日志中,我有这样的内容:

2010/11/11 10:46:44 [notice] 3812#0: signal process started
*** Exception Errno::EPIPE in Passenger RequestHandler (Broken pipe) (process 3803):
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/rack/request_handler.rb:94:in `write'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/rack/request_handler.rb:94:in `process_request'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/utils.rb:184:in `safe_fork'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:163:in `start'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:213:in `start'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/bin/passenger-spawn-server:61

我无法弄清楚是什么导致了这个问题。我尝试在 Passenger 配置文件中将 max_pool_size 设置为 30,但没有任何区别。

任何帮助将不胜感激。

谢谢。

I hope somewhere out there will be able to help me on this. I have my production evironment as follows:

Rails 2.3.5
Passenger 2.2.11
Nginx
Monit

It seems that everything is working as it's supposed to be but, 2 or 3 times a day, I get an email from Monit as follows:

monit alert -- Connection failed nginx

To: [email protected]
Connection failed Service nginx

    Date:        Thu, 11 Nov 2010 10:46:44 +0000
    Action:      restart
    Host:        mydomain
    Description: 'nginx' failed, cannot open a connection to INET[mydomain.com:80] via TCP

Your faithful employee,
monit

Then after about 30 seconds, I have another email as follows:

Connection passed Service nginx

    Date:        Thu, 11 Nov 2010 10:47:16 +0000
    Action:      alert
    Host:        mydomain
    Description: 'nginx' connection passed to INET[mydomain.com:80] via TCP

Your faithful employee,
monit

In my monit config file I have the followings:

set daemon 30
check process nginx with pidfile /opt/nginx/logs/nginx.pid
  start program = "/opt/nginx/sbin/nginx"
  stop program = "/opt/nginx/sbin/nginx -s stop"
  if failed host mydomain.com port 80 protocol http request / then restart
  if 5 restarts within 5 cycles then timeout

And in Nginx log around that time, I have this:

2010/11/11 10:46:44 [notice] 3812#0: signal process started
*** Exception Errno::EPIPE in Passenger RequestHandler (Broken pipe) (process 3803):
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/rack/request_handler.rb:94:in `write'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/rack/request_handler.rb:94:in `process_request'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/utils.rb:184:in `safe_fork'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:163:in `start'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb:213:in `start'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/bin/passenger-spawn-server:61

I couldn't make out what's causing this problem. I have tried putting the max_pool_size to 30 in Passenger config file and it didn't make any difference yet.

Any help would be appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心欲静而疯不止 2024-10-09 19:37:59

如果你想检查你的网站是否正常运行,也许你应该使用像 wasitup.com 这样的服务(顺便说一句,这是免费的) 。

如果乘客一段时间不“活跃”,就会下降。 go down 是一个很重的词,但是如果有人在 10 分钟左右没有访问您的网站,任何乘客实例都会被杀死,并且第一个访问您网站的人将不得不等待网站启动。

我用它来让乘客保持清醒,因为没有更好的词了。

请告诉我们您是否使用 monit 解决了这个问题,也许其他人需要互联网上的帮助。

if you want to check for your site being up perhaps you should use a service like wasitup.com (which is free btw).

Passenger will go down if it's not 'active' for awhile. go down is a strong word, but if someone doesn't visit your site in say 10 minutes or so, any passenger instances get killed, and the first person to visit your site will have to wait while it boots up.

I use this to keep passenger awake, for lack of a better word.

Please tell us if you fixed this problem with monit however, maybe someone else will need the help on the interwebs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文