Skip to content

Use classic Observer Pattern to implement a simple supervisord PROCESS_LOG listener, and send message to HipChat or Mail or else place.

License

Notifications You must be signed in to change notification settings

hanks/Supervisord_Notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Supervisord Notifier

Use classic Observer Pattern to implement a simple supervisord PROCESS_LOG listener, and send message to HipChat or Mail or else place.

Why

Supervisord is an useful tool to manage background processes, and it is used in my project heavily to control RabbitMQ consumer processes. And when the process is crashed by some unexpected conditions, supervisord will record the traceback information to log file. The log info is good for us to solve the problems.

But the problem is now I always need to ssh to the remote server to find out the log file of the crashed process, and often after a long time that problem happened. It may create a great loss. The cause of these is no effective way to notify me, So I tried to create this simple script to send error log instantly to Hipchat(An Instant Message Application) and mail and other places.

Demo

![alt text][demo]

Left window is Hipchat, Right window is supervisord monitor page. [demo]: https://raw.githubusercontent.com/hanks/Supervisord_Notifier/master/demo/demo.gif "demo"

##Implementation

  1. Event Listener
    1. This allows user to implement actions response to specified events sent by supervisord.
  2. PROCESS_LOG
      This event type allows user to interact with supervisord server when supervisord writes error log and fetch the log content.

Configuration

Need to config process like below:

[eventlistener:crashlistenter] ;; define a event listener process
command=python your_absolute_path/notifier.py
events=PROCESS_LOG ;; set event type to be listened to
redirect_stderr=true
stdout_logfile=/tmp/crashlistenter.log

[program:crash_demo]
command=python your_absolute_path/notifier_error_demo.py
stderr_logfile=/tmp/crash_demo.log
autostart=false
stderr_events_enabled=true ;; set to true, means to triggle stderr event when write error logs.

Lisence

MIT Lisence

About

Use classic Observer Pattern to implement a simple supervisord PROCESS_LOG listener, and send message to HipChat or Mail or else place.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages