2 #Copyright (C) 2009-2011 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
5 # Gregory Starck, g.starck@gmail.com
6 # Hartmut Goebel, h.goebel@goebel-consult.de
8 #This file is part of Shinken.
10 #Shinken is free software: you can redistribute it and/or modify
11 #it under the terms of the GNU Affero General Public License as published by
12 #the Free Software Foundation, either version 3 of the License, or
13 #(at your option) any later version.
15 #Shinken is distributed in the hope that it will be useful,
16 #but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 #GNU Affero General Public License for more details.
20 #You should have received a copy of the GNU Affero General Public License
21 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
24 #This class is an application that launches actions like
25 #notifications or event handlers
26 #The reactionner listens to the Arbiter for the configuration sent through
27 #the port given as first argument.
28 #The configuration sent by the arbiter specifies on which schedulers the
30 #When the reactionner is already launched and has its own conf, it still
31 #listens to arbiter (one a timeout)
32 #In case the arbiter has a new conf to send, the reactionner forget his old
33 #schedulers (and the actions that goes with them) and take the new ones
44 # If importing shinken fails, try to load from current directory
45 # or parent directory to support running without installation.
46 # Submodules will then be loaded from there, too.
48 if not hasattr(os
, "getuid") or os
.getuid() != 0:
49 imp
.load_module('shinken', *imp
.find_module('shinken', [".", ".."]))
52 from shinken
.daemons
.reactionnerdaemon
import Reactionner
53 from shinken
.bin
import VERSION
55 parser
= optparse
.OptionParser(
56 "%prog [options]", version
="%prog " + VERSION
)
57 parser
.add_option('-c', '--config',
58 dest
="config_file", metavar
="CONFIG-FILE",
60 parser
.add_option('-d', '--daemon', action
='store_true',
62 help="Run in daemon mode")
63 parser
.add_option('-r', '--replace', action
='store_true',
65 help="Replace previous running reactionner")
66 parser
.add_option('--debugfile', dest
='debug_file',
67 help=("Debug file. Default: not used "
68 "(why debug a bug free program? :) )"))
69 opts
, args
= parser
.parse_args()
71 parser
.error("Does not accept any argument.")
73 daemon
= Reactionner(debug
=opts
.debug_file
is not None, **opts
.__dict
__)