Add : service without host will be just droped, like Nagios.
[shinken.git] / bin / shinken-poller
blob6febaef8cbe8673ad989a8eb6187af2c9e215982
1 #!/usr/bin/env python
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 the application that launches the checks
25 #The poller listens to the Arbiter for the configuration sent through
26 #the port given as first argument.
27 #The configuration sent by the arbiter specifies on which schedulers the
28 #poller will take its checks.
29 #When the poller is already launched and has its own conf, it still
30 #listens to arbiter (one a timeout)
31 #In case the arbiter has a new conf to send, the poller forget his old
32 #schedulers (and the checks that goes with them) and take the new ones
33 #instead.
35 import sys
36 import os
37 import optparse
39 try:
40 import shinken
41 except ImportError:
42 # If importing shinken fails, try to load from current directory
43 # or parent directory to support running without installation.
44 # Submodules will then be loaded from there, too.
45 import imp
46 if not hasattr(os, "getuid") or os.getuid() != 0:
47 imp.load_module('shinken', *imp.find_module('shinken', [".", ".."]))
50 from shinken.daemons.pollerdaemon import Poller
51 from shinken.bin import VERSION
54 parser = optparse.OptionParser(
55 "%prog [options]", version="%prog " + VERSION)
56 parser.add_option('-c', '--config',
57 dest="config_file", metavar="CONFIG-FILE",
58 help='Config file')
59 parser.add_option('-d', '--daemon', action='store_true',
60 dest="is_daemon",
61 help="Run in daemon mode")
62 parser.add_option('-r', '--replace', action='store_true',
63 dest="do_replace",
64 help="Replace previous running poller")
65 parser.add_option('--debugfile', dest='debug_file',
66 help=("Debug file. Default: not used "
67 "(why debug a bug free program? :) )"))
68 opts, args = parser.parse_args()
69 if args:
70 parser.error("Does not accept any argument.")
72 daemon = Poller(debug=opts.debug_file is not None, **opts.__dict__)
73 daemon.main()