Exemplo n.º 1
0
def main():
    parser = optparse.OptionParser(
        "%prog [options]", version="%prog " + VERSION)
    parser.add_option('-c', '--config',
                      dest="config_file", metavar="INI-CONFIG-FILE",
                      help='Config file')
    parser.add_option('-d', '--daemon', action='store_true',
                      dest="is_daemon",
                      help="Run in daemon mode")
    parser.add_option('-r', '--replace', action='store_true',
                      dest="do_replace",
                      help="Replace previous running poller")
    parser.add_option('--debugfile', dest='debug_file',
                      help=("Debug file. Default: not used "
                            "(why debug a bug free program? :) )"))
    parser.add_option("-p", "--profile",
                      dest="profile",
                      help="Dump a profile file. Need the python cProfile librairy")

    opts, args = parser.parse_args()
    if args:
        parser.error("Does not accept any argument.")

    daemon = Poller(debug=opts.debug_file is not None, **opts.__dict__)
    if not opts.profile:
        daemon.main()
    else:
        # For perf tuning:
        import cProfile
        cProfile.run('''daemon.main()''', opts.profile)
Exemplo n.º 2
0
 def get_poller_daemon(self):
     os.chdir(curdir)
     p = Poller(pollerconfig, False, True, False, None)
     p.load_config_file()
     p.port = 0  # let's here choose automatic port attribution..
     self.get_login_and_group(p)
     return p
Exemplo n.º 3
0
 def get_poller_daemon(self):
     os.chdir(curdir)
     p = Poller(pollerconfig, False, True, False, None)
     p.load_config_file()
     p.port = 0  # let's here choose automatic port attribution..
     self.get_login_and_group(p)
     return p
from shinken.bin import VERSION


parser = optparse.OptionParser(
    "%prog [options]", version="%prog " + VERSION)
parser.add_option('-c', '--config',
                  dest="config_file", metavar="CONFIG-FILE",
                  help='Config file')
parser.add_option('-d', '--daemon', action='store_true',
                  dest="is_daemon",
                  help="Run in daemon mode")
parser.add_option('-r', '--replace', action='store_true',
                  dest="do_replace",
                  help="Replace previous running poller")
parser.add_option('--debugfile', dest='debug_file',
                  help=("Debug file. Default: not used "
                        "(why debug a bug free program? :) )"))
opts, args = parser.parse_args()
if args:
    parser.error("Does not accept any argument.")

# Protect for windows multiprocessing that will RELAUNCH all
if __name__ == '__main__':
    daemon = Poller(debug=opts.debug_file is not None, **opts.__dict__)
    daemon.main()

# For perf tuning :
#import cProfile
#cProfile.run('''daemon.main()''', '/tmp/poller.profile')