Exemplo n.º 1
0
def init(options):
    """Prepare to start up NagCat"""

    # Set uid/gid/file_limit
    util.setup(options.user, options.group,
               options.file_limit,
               options.core_dumps)

    # Write out the pid to make the verify script happy
    if options.pidfile:
        util.write_pid(options.pidfile)

    log.init(options.logfile, options.loglevel)
    config = coil.parse_file(options.config, expand=False)

    init_plugins(options)

    try:
        if options.test:
            nagcat = simple.NagcatSimple(config,
                    rradir=options.rradir,
                    rrdcache=options.rrdcache,
                    monitor_port=options.status_port,
                    test_name=options.test,
                    host=options.host, port=options.port)
        else:
            nagcat = nagios.NagcatNagios(config,
                    rradir=options.rradir,
                    rrdcache=options.rrdcache,
                    monitor_port=options.status_port,
                    nagios_cfg=options.nagios, tag=options.tag)
    except (errors.InitError, coil.errors.CoilError), ex:
        log.error(str(ex))
        sys.exit(1)
Exemplo n.º 2
0
def main():
    """Start up NagCat, profiling things as requested"""

    options = parse_options()
    log.init(options.logfile, options.loglevel)

    if options.pidfile:
        util.write_pid(options.pidfile)

    site = monitor_api.MonitorSite()
    site.root.putChild("nagios", nagios_api.NagiosStatus(options.nagios))

    if not options.read_only:
        try:
            rpc = nagios_api.NagiosXMLRPC(options.nagios)
        except errors.InitError, ex:
            log.error(str(ex))
            sys.exit(1)
        site.root.putChild("RPC2", rpc)