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 interface for Broker
24 #The broker listen configuration from Arbiter in a port (first argument)
25 #the configuration gived by arbiter is schedulers where broker will take broks.
26 #When already launch and have a conf, broker still listen to arbiter
28 #if arbiter whant it to have a new conf, broker forgot old chedulers
30 #take new ones and do the (new) job.
38 #Try to load shinken lib.
39 #Maybe it's not in our python path, so we detect it
40 #it so (it's a untar install) we add .. in the path
43 # HACK : under python2.4, without this, it seems that
44 # modules are not so happy to import
45 if hasattr(sys
.modules
['__main__'], '__file__'):
46 my_path
= os
.path
.abspath(sys
.modules
['__main__'].__file
__)
47 elts
= os
.path
.dirname(my_path
).split(os
.sep
)[:-1]
48 elts
.append('shinken')
49 sys
.path
.append(os
.sep
.join(elts
))
50 except ImportError, e
:
51 # We can have problem in importing with direct launch.
52 # if so we must add the shinken lib in .. of this file to
54 if hasattr(sys
.modules
['__main__'], '__file__'):
55 my_path
= os
.path
.abspath(sys
.modules
['__main__'].__file
__)
56 elts
= os
.path
.dirname(my_path
).split(os
.sep
)[:-1]
57 sys
.path
.append(os
.sep
.join(elts
))
58 elts
.append('shinken')
59 sys
.path
.append(os
.sep
.join(elts
))
61 from shinken
.daemons
.brokerdaemon
import Broker
, usage
64 if __name__
== "__main__":
67 opts
, args
= getopt
.getopt(sys
.argv
[1:], "hrdc::w", ["help", "replace", "daemon", "config=", "debug=", "easter"])
68 except getopt
.GetoptError
, err
:
69 # print help information and exit:
70 print str(err
) # will print something like "option -a not recognized"
80 if o
in ("-h", "--help"):
83 elif o
in ("-r", "--replace"):
85 elif o
in ("-c", "--config"):
87 elif o
in ("-d", "--daemon"):
89 elif o
in ("--debug"):
93 print "Sorry, the option",o
, a
, "is unknown"
97 daemon
= Broker(config_file
, is_daemon
, do_replace
, debug
, debug_file
)