コード例 #1
0
ファイル: factory.py プロジェクト: shanxichen/Antilles
def make_application(global_config, **local_conf):

    db_host = global_config.get("db_host", None)
    db_port = global_config.get("db_port", None)
    db_name = global_config.get("db_name", None)

    # Set db user and db password
    db_account = fetch_pass(keyword="postgres",
                            host=db_host,
                            port=db_port,
                            db=db_name)
    global_config["db_user"] = db_account.user
    global_config["db_pass"] = db_account.passwd

    # Set influxdb user and password
    influx_account = fetch_pass(keyword="influxdb",
                                host=db_host,
                                port=db_port,
                                db=db_name)
    global_config["influx_username"] = influx_account.user
    global_config["influx_password"] = influx_account.passwd

    # Set confluent user and password
    confluent_account = fetch_pass(keyword="confluent",
                                   host=db_host,
                                   port=db_port,
                                   db=db_name)
    global_config["confluent_user"] = confluent_account.user
    global_config["confluent_pass"] = confluent_account.passwd

    app = get_configured_django_wsgi_app(global_config, **local_conf)

    return app
コード例 #2
0
def main():
    config = parse_config()

    db_host = config['postgresql']['host']
    db_port = int(config['postgresql']['port'])
    db_name = config['postgresql']['database']

    api_account = fetch_pass(
        keyword='icinga2 api',
        host=db_host,
        port=db_port,
        db=db_name
    )

    influx_account = fetch_pass(
        keyword='influxdb',
        host=db_host,
        port=db_port,
        db=db_name
    )

    icinga_client = DataSource(
        host=config['icinga']['host'],
        port=int(config['icinga']['port']),
        user=api_account.user,
        password=api_account.passwd,
        service=config['base']['service'],
        attrs=config['icinga'].get('attributes', ''),
        api_v=config['icinga'].get('api_version', 'v1'),
        domain_filter=config['base'].get('domain_filter', list()),
        timeout=int(config['icinga']['timeout'])
    )

    writer_client = InfluxDBWriter(
        host=config['influxdb']['host'],
        port=int(config['influxdb']['port']),
        user=influx_account.user,
        password=influx_account.passwd,
        database=config['influxdb']['database'],
        timeout=int(config['influxdb']['timeout'])
    )

    scheduler = BlockingScheduler()
    interval = int(config['base'].get('sample_interval', '15'))
    scheduler.add_job(
        func=monitor,
        args=(icinga_client, writer_client),
        trigger="interval",
        seconds=interval,
        max_instances=1,
        id="antilles-monitoring"
    )
    scheduler.start()
コード例 #3
0
    def _parseConfig(self, cfgdata):
        self.influx_config = {i[0]: i[1]
                              for i in cfgdata} if cfgdata is not None else {}

        # Query influxdb account
        cfg_db_host = self.influx_config.get('cfg_db_host', '127.0.0.1')
        cfg_db_port = int(self.influx_config.get('cfg_db_port', '5432'))
        cfg_db_name = self.influx_config.get('cfg_db_name', 'antilles')

        influxdb_account = fetch_pass(keyword='influxdb',
                                      host=cfg_db_host,
                                      port=cfg_db_port,
                                      db=cfg_db_name)

        username = influxdb_account.user
        password = influxdb_account.passwd

        self.influx = InfluxDBClient(
            host=self.influx_config.get('host', '127.0.0.1'),
            port=int(self.influx_config.get('port', 8086)),
            username=username,
            password=password,
            database=self.influx_config.get('database', 'antilles'),
            timeout=int(self.influx_config.get('timeout', 10)))
        self.hostlist = expand_hostlist(
            self.influx_config['hostlist']
        ) if 'hostlist' in self.influx_config else []
コード例 #4
0
def main():
    arguments = docopt(__doc__, version='Antilles Confluent Mond 1.0.1')

    config = ConfigParser()
    config.read(resource_filename(__name__, 'data/default.ini'))
    filepath = arguments['--config']
    if filepath is None:
        filepath = '/etc/antilles/confluent-mond.ini'
    config.read(filepath)

    db_host = config.get('database', 'db_host')
    db_port = config.get('database', 'db_port')
    db_name = config.get('database', 'db_name')

    influxdb_account = fetch_pass(keyword='influxdb',
                                  host=db_host,
                                  port=db_port,
                                  db=db_name)
    username = influxdb_account.user
    password = influxdb_account.passwd

    confluent_account = fetch_pass(keyword='confluent',
                                   host=db_host,
                                   port=db_port,
                                   db=db_name)

    influx = InfluxDBClient(host=config.get('influxdb', 'host'),
                            port=config.getint('influxdb', 'port'),
                            username=username,
                            password=password,
                            database=config.get('influxdb', 'database'),
                            timeout=config.getint('influxdb', 'timeout'))

    plugin = load_entry_point(dist='antilles-confluent-mond',
                              group='confluent_metric',
                              name=arguments.get('<metric>'))

    server = config.get('confluent', 'server')

    metric = plugin(noderange=config.get('confluent', 'noderange'),
                    hostlist=expand_hostlist(config.get(
                        'influxdb', 'hostlist')),
                    user=confluent_account.user,
                    passwd=confluent_account.passwd,
                    server=server if len(server) > 0 else None)

    influx.write_points(points=metric.get_points())
コード例 #5
0
ファイル: factory.py プロジェクト: shanxichen/Antilles
def _fetch_confluent_account(global_config):
    db_host = global_config.get("db_host", None)
    db_port = global_config.get("db_port", None)
    db_name = global_config.get("db_name", None)

    return fetch_pass(keyword="confluent",
                      host=db_host,
                      port=db_port,
                      db=db_name)