PERL based log analyzer
SourceForge.net Logo
Home Home Contact us Contacts
Overview Documentation Downloads Contacts Links
 
News & Updates
 
July 21, 2008
v 1.0 now available
Quick Links
 
Sourceforge project's page
CeCILL license
CEA web site
Re-spawning a dead process next up previous contents
Next: A simple usage of Up: A boolean composite event Previous: A chronological composite event   Contents

Re-spawning a dead process

This is an actual sample. I would say, that contrarily to the other examples that were designed for showing the way Kazimir's works, this one is an event I really use on my machines. The context is as follows: I have a process (in my example, the binary is called 'toto'2.7 and it should be restarted when it crashed. Its path is /usr/local/bin/toto.

What the following configuration file does is making kazimir use 'ps -edf | grep toto | grep -v grep' periodically. If a process named toto exists, I will see it that way, if no such process exists, when the output will be totally blank. A pattern is defined to keep track on the last time the process 'toto' was seen in the output of the 'ps' command. It is then use to defined an event, but on a negative way: event is realized when the pattern could not be found in the event window time, which means the process was not up in this interval. An action is correlated to this action, it re-spawns the process, making that way the pattern be realized and. On this example, I use explicitly 'NONE' as TimeFormat. I have said in this document to avoid using this format, but here it is pretty well adapted there, because 'ps' provides only an 'instant view' on the existing process, but nothing about the past processes, no there is no danger to identify a past information as up to date.

Kazimir: LogFile = /dev/tty ; EventDir = /tmp/eventdir ; OutputDir = /tmp/outputdir ;\
	LockFile = /tmp/kazimir.lock ; EventUpdateInt = 5 
	
Log: Name = PsEdf ; Type = CMND_OUT ; Path = ps -edf | grep toto | grep -v grep ; UpdateInt = 10s ; TimeFormat = NONE


Pattern: Name = PsToto ; Log = PsEdf ; RegExp =toto; 

Event : Name = TotoNotHere ; Fenetre = 15s; 
Begin 
	!PsToto 
End


Order: Nom = ordre1 ; Event = TotoNotHere ; Action = StartToto;
Action: Nom = StartToto ; Path = /usr/local/bin/toto ;

For testing this create a binary 'toto' (during my test is was just a test who ran a 'sleep 5000'). Then run kazimir and look at the log. Then try to kill toto and see how kazimir restart it. On this example, I have used very short Update value and window time value. They are clearly too short, but they fit well for a demo. So if you want to use a similar event and pattern, use a longer 'UpdateInt' for the PsEdf Log and a longer window size for the event.


next up previous contents
Next: A simple usage of Up: A boolean composite event Previous: A chronological composite event   Contents
Philippe Deniel 2008-07-22
Designed by CMG Technologies, adapted by Thomas LEIBOVICI
Design downloaded from Free Templates