27 messages in ru.sysoev.nginxRe: Feature request: Run a script whe...
FromSent OnAttachments
Rt IbmerApr 28, 2008 8:44 am 
Cliff WellsApr 28, 2008 10:20 am 
mikeApr 28, 2008 11:53 am 
Rt IbmerApr 28, 2008 2:02 pm 
Cliff WellsApr 28, 2008 2:18 pm 
Manlio PerilloApr 28, 2008 2:37 pm 
Rt IbmerApr 28, 2008 6:10 pm 
Rt IbmerApr 28, 2008 6:19 pm 
Manlio PerilloApr 29, 2008 1:18 am 
Manlio PerilloApr 29, 2008 1:25 am 
Rt IbmerApr 29, 2008 8:11 am 
François BattailApr 29, 2008 10:46 am 
Rt IbmerApr 29, 2008 1:41 pm 
Manlio PerilloApr 29, 2008 1:57 pm 
François BattailApr 29, 2008 2:27 pm 
Aleksandar LazicApr 29, 2008 2:36 pm 
François BattailApr 29, 2008 11:20 pm 
Mansoor PeerbhoyApr 30, 2008 1:46 am 
Manlio PerilloApr 30, 2008 2:36 am 
François BattailApr 30, 2008 3:54 am 
Mansoor PeerbhoyApr 30, 2008 5:03 am 
Grzegorz NosekApr 30, 2008 5:18 am 
Cliff WellsApr 30, 2008 10:40 am 
Manlio PerilloApr 30, 2008 12:16 pm 
Manlio PerilloMay 1, 2008 2:42 am 
Grzegorz NosekMay 1, 2008 11:28 am 
Manlio PerilloMay 1, 2008 12:02 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Feature request: Run a script when upstream detected down/upActions...
From:Rt Ibmer (rtib@public.gmane.org)
Date:Apr 29, 2008 1:41:30 pm
List:ru.sysoev.nginx

if (fork() == 0) execl("/bin/sh","/path/to/upstream_down.sh","ID of down upsteam goes here", NULL);

It's not as easy to do.

At a high level, what am I missing / oversimplifying?

Perhaps instead, a simpler and more efficient approach may be for me to write to
a log when nginx stops routing requests to an upstream box. I cannot use the
events it logs current, because it doesn't differentiate between a failed
attempt vs. enough failed attempts based on max_fails and fail_timeout.

For instance it'll write to the log saying a connection or timeout occurred with
an upstream, but does not record an entry saying that this has occurred
max_fails times and it is now taking that upstream out of rotation for
fail_timeout duration. I think at a minimum even if nothing further is done
here it should at least report that event in the logs. Also I may be mistaken
but I believe the current logging it does in this regard is only seen with like
"notices" - I would expect those to get a high level logging priority like error
or critical.

Well, from my point of view your solution is not good engineering and not in the

That does not surprise me at all! This is over my head for sure. All I know is
that I disparately need to know when nginx stops routing requests to an
upstream. And the only way to know 100% sure that its doing so is for nginx to
tell us, not to try and determine what nginx must be seeing based on some
external monitoring.

I don't believe Igor is likely to call fork() to execute a script in response to an event in its code.

Agree it is lousy! :) At the same time, for an event that (hopefully) happens
very rarely I wouldn't mind the couple of second hit from inefficiency here.
That being said clearly better solutions can be engineered (just not be my
unfortunately).

As I'm not a completely negative guy ;-) I propose a more general solution to monitor Nginx cleanly and to do whatever your want.

That is an excellent idea! Basically some sort of event / hook system that nginx
can use to report various events (including "upstream down" and "previously
detected downed ppstream now back up").

The script/agent will just read the shared memory and act according to data.

Perfect! I just need the hook.

Thank you for your consideration and I hope these discussions help make in
incredible product even more robust.