2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
5 # Gregory Starck, g.starck@gmail.com
7 #This file is part of Shinken.
9 #Shinken is free software: you can redistribute it and/or modify
10 #it under the terms of the GNU Affero General Public License as published by
11 #the Free Software Foundation, either version 3 of the License, or
12 #(at your option) any later version.
14 #Shinken is distributed in the hope that it will be useful,
15 #but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 #GNU Affero General Public License for more details.
19 #You should have received a copy of the GNU Affero General Public License
20 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
23 #This class is an application for launch actions
24 #like notifications or event handlers
25 #The actionner listen configuration from Arbiter in a port (first argument)
26 #the configuration gived by arbiter is schedulers where actionner will take
28 #When already launch and have a conf, actionner still listen to arbiter (one
29 #a timeout) if arbiter wants it to have a new conf, actionner forgot old
30 #chedulers (and actions into) take new ones and do the (new) job.
37 #Try to load shinken lib.
38 #Maybe it's not in our python path, so we detect it
39 #it so (it's a untar install) we add .. in the path
42 except ImportError, e
:
43 if hasattr(sys
.modules
['__main__'], '__file__'):
44 my_path
= os
.path
.abspath(sys
.modules
['__main__'].__file
__)
45 elts
= os
.path
.dirname(my_path
).split(os
.sep
)[:-1]
46 sys
.path
.append(os
.sep
.join(elts
))
47 elts
.append('shinken')
48 sys
.path
.append(os
.sep
.join(elts
))
51 from shinken
.daemons
.reactionnerdaemon
import Reactionner
, usage
56 if __name__
== "__main__":
59 opts
, args
= getopt
.getopt(sys
.argv
[1:], "hrdc::w", ["help", "replace", "daemon", "config=", "debug=", "easter"])
60 except getopt
.GetoptError
, err
:
61 # print help information and exit:
62 print str(err
) # will print something like "option -a not recognized"
72 if o
in ("-h", "--help"):
75 elif o
in ("-r", "--replace"):
77 elif o
in ("-c", "--config"):
79 elif o
in ("-d", "--daemon"):
81 elif o
in ("--debug"):
85 print "Sorry, the option",o
, a
, "is unknown"
90 daemon
= Reactionner(config_file
, is_daemon
, do_replace
, debug
, debug_file
)