当前位置: 首页>>代码示例>>Python>>正文


Python influxdb.InfluxDBClient方法代码示例

本文整理汇总了Python中influxdb.InfluxDBClient方法的典型用法代码示例。如果您正苦于以下问题:Python influxdb.InfluxDBClient方法的具体用法?Python influxdb.InfluxDBClient怎么用?Python influxdb.InfluxDBClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在influxdb的用法示例。


在下文中一共展示了influxdb.InfluxDBClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def __init__(
            self,
            host='localhost',
            port=8086,
            user='root',
            password='root',
            dbname='example',
            dbuser='test',
            dbuser_pw='test'):

        self.host = host
        self.port = port
        self.user = user
        self.password = password
        self.dbname = dbname
        self.dbuser = dbuser
        self.dbuser_pw = dbuser_pw
        self.client = InfluxDBClient(host, port, user, password, dbname)
        self.client.create_database(dbname) 
开发者ID:OpenMTC,项目名称:OpenMTC,代码行数:21,代码来源:connector.py

示例2: connect

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def connect(self, silent=False):
        try:
            client = influxdb.InfluxDBClient(self.settings.influxdb['host'],
                                             self.settings.influxdb['port'],
                                             self.settings.influxdb['user'],
                                             self.settings.influxdb['password']
                                             )

            # dummy request to test connection
            client.get_list_database()
        except influxdb.client.InfluxDBClientError as e:
            self.client, self.valid = None, False
            if not silent:
                print("  {0} Could not connect to database: {1}".format(Symbol.WARN_YELLOW, e))
        except Exception as e:
            print("Error: %s" % e)
            self.client, self.valid = None, False
        else:
            self.client, self.valid = client, True

        if self.settings.influxdb['database']:
            self.client.switch_database(self.settings.influxdb['database'])

        return self.valid 
开发者ID:mvonthron,项目名称:munin-influxdb,代码行数:26,代码来源:influxdbclient.py

示例3: test_multi_fetch_non_existant_series

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def test_multi_fetch_non_existant_series(self):
        """Test single fetch data for a series by name"""
        path1, path2 = 'fake_path1', 'fake_path2'
        reader1 = influxgraph.InfluxDBReader(InfluxDBClient(
            database=self.db_name), path1)
        reader2 = influxgraph.InfluxDBReader(InfluxDBClient(
            database=self.db_name), path2)
        nodes = [influxgraph.classes.leaf.InfluxDBLeafNode(path1, reader1),
                 influxgraph.classes.leaf.InfluxDBLeafNode(path2, reader2)]
        time_info, data = self.finder.fetch_multi(nodes,
                                                  int(self.start_time.strftime("%s")),
                                                  int(self.end_time.strftime("%s")))
        for metric_name in data:
            self.assertFalse(data[metric_name],
                             msg="Expected no data for non-existant series %s - got %s" % (
                                 metric_name, data,))
        fake_nodes = list(self.finder.find_nodes(Query('fake_pathy_path')))
        time_info, data = self.finder.fetch_multi(fake_nodes,
                                                  int(self.start_time.strftime("%s")),
                                                  int(self.end_time.strftime("%s")))
        self.assertFalse(data) 
开发者ID:InfluxGraph,项目名称:influxgraph,代码行数:23,代码来源:test_influxdb_integration.py

示例4: __init__

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def __init__(self, config=None):
        # Shouldn't be trying imports in __init__.
        # It turns what should be a load error into a runtime error
        config = normalize_config(config)
        self.config = config
        self.client = InfluxDBClient(config['host'], config['port'], config['user'], config['passw'], config['db'], config['ssl'])
        self.schemas = [(re.compile(patt), step) for (patt, step) in config['schema']]
        try:
            self.statsd_client = statsd.StatsClient(config['statsd'].get('host'),
                                                    config['statsd'].get('port', 8125)) \
                                                    if 'statsd' in config and config['statsd'].get('host') else NullStatsd()
        except NameError:
            logger.warning("Statsd client configuration present but 'statsd' module"
                           "not installed - ignoring statsd configuration..")
            self.statsd_client = NullStatsd()
        self._setup_logger(config['log_level'], config['log_file'])
        self.es = None
        if config['es_enabled']:
            try:
                from elasticsearch import Elasticsearch
            except ImportError:
                logger.warning("Elasticsearch configuration present but 'elasticsearch'"
                               "module not installed - ignoring elasticsearch configuration..")
            else:
                self.es = Elasticsearch(config['es_hosts']) 
开发者ID:vimeo,项目名称:graphite-influxdb,代码行数:27,代码来源:graphite_influxdb.py

示例5: setUp

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def setUp(self):
        self.step, self.num_datapoints, self.db_name = 60, 2, 'integration_test'
        self.start_time, self.end_time = (datetime.datetime.utcnow() - datetime.timedelta(hours=1)), \
          datetime.datetime.utcnow()
        self.steps = int(round((int(self.end_time.strftime("%s")) - \
                                int(self.start_time.strftime("%s"))) * 1.0 / self.step)) + 1
        self.client = InfluxDBClient(database=self.db_name)
        self.config = { 'influxdb' : { 'host' : 'localhost',
                                       'port' : 8086,
                                       'user' : 'root',
                                       'pass' : 'root',
                                       'db' : self.db_name,
                                       'schema' : [('', 60)],
                                       'log_level' : 'debug',
                                       },}
        self.finder = graphite_influxdb.InfluxdbFinder(self.config)
        self.metric_prefix = "integration_test"
        self.nodes = ["leaf_node1", "leaf_node2"]
        self.series1, self.series2 = ".".join([self.metric_prefix, self.nodes[0]]), \
          ".".join([self.metric_prefix, self.nodes[1]])
        self.series = [self.series1, self.series2]
        self.setup_db() 
开发者ID:vimeo,项目名称:graphite-influxdb,代码行数:24,代码来源:test_influxdb_integration.py

示例6: __init__

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def __init__(self, query, host="127.0.0.1", port=8086, database="thingflow", 
                 username="root", password="root", 
                 ssl=False, verify_ssl=False, timeout=None, 
                 use_udp=False, udp_port=4444, proxies=None,
                 bulk_size=10):
        super().__init__()
        self.dbname = database
        self.client = InfluxDBClient(host=host, port=port, 
                                     username=username, password=password, 
                                     database=database,
                                     ssl=ssl, verify_ssl=verify_ssl, 
                                     timeout=timeout, 
                                     use_udp=use_udp, udp_port=udp_port, 
                                     proxies=proxies)
        self.query = query
        self.points = self.client.query(query).get_points() 
开发者ID:mpi-sws-rse,项目名称:thingflow-python,代码行数:18,代码来源:influxdb.py

示例7: get_influxdb_client

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def get_influxdb_client(self):
        influx_args = {}
        if not self._influxdb_config:
            return None
        use_udp = bool(self._influxdb_config.get('use_udp', False))
        port = self._influxdb_config.get('port')
        if use_udp:
            influx_args['use_udp'] = True
        if 'port' in self._influxdb_config:
            if use_udp:
                influx_args['udp_port'] = port
            else:
                influx_args['port'] = port
        for key in ['host', 'username', 'password', 'database', 'timeout']:
            if key in self._influxdb_config:
                influx_args[key] = self._influxdb_config[key]
        if influxdb and influx_args:
            try:
                return influxdb.InfluxDBClient(**influx_args)
            except Exception:
                self.log.warning('Cannot establish connection to InfluxDB')
        else:
            self.log.warning('InfluxDB configuration is present, '
                             'but no client library is found.')
        return None 
开发者ID:openstack,项目名称:openstacksdk,代码行数:27,代码来源:cloud_region.py

示例8: init_influx

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def init_influx():
    """ Initializes influx database. """
    from listenbrainz import config
    print("Connecting to Influx...")
    influx_client = InfluxDBClient(
        host=config.INFLUX_HOST,
        port=config.INFLUX_PORT,
        database=config.INFLUX_DB_NAME,
    )
    print("Connected to Influx!")

    print("Creating influx database...")
    influx_client.create_database(config.INFLUX_DB_NAME)
    influx_client.create_retention_policy("one_week", "1w", 1, "listenbrainz")

    print("Done!")


# Add other commands here 
开发者ID:metabrainz,项目名称:listenbrainz-server,代码行数:21,代码来源:manage.py

示例9: connect

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def connect(self):
        """
        Override from BaseDB.

        Create the connection to the influxdb database with the current
        configuration (hostname/port/db_name), then check if the connection has
        been created without failure.

        """

        # close connection if reload
        if self.client is not None:
            self.client.close()

        self.client = InfluxDBClient(host=self.uri, port=self.port, database=self.db_name)
        try:
            self.client.ping()
        except ConnectionError:
            raise CantConnectToInfluxDBException('connexion error')

        for db in self.client.get_list_database():
            if db['name'] == self.db_name:
                return

        self.client.create_database(self.db_name) 
开发者ID:powerapi-ng,项目名称:powerapi,代码行数:27,代码来源:influxdb.py

示例10: connect

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def connect() -> influxdb.InfluxDBClient:
        """
        Connect to InfluxDB using configuration parameters
        :return: InfluxDBClient object
        """
        return influxdb.InfluxDBClient(
            host=current_app.config["INFLUXDB_HOST"],
            port=current_app.config["INFLUXDB_PORT"],
            username=current_app.config["INFLUXDB_USER"],
            password=current_app.config["INFLUXDB_PASSWORD"],
            database=current_app.config["INFLUXDB_DATABASE"],
            ssl=current_app.config["INFLUXDB_SSL"],
            verify_ssl=current_app.config["INFLUXDB_VERIFY_SSL"],
            timeout=current_app.config["INFLUXDB_TIMEOUT"],
            retries=current_app.config["INFLUXDB_RETRIES"],
            use_udp=current_app.config["INFLUXDB_USE_UDP"],
            udp_port=current_app.config["INFLUXDB_UDP_PORT"],
            proxies=current_app.config["INFLUXDB_PROXIES"],
            pool_size=current_app.config["INFLUXDB_POOL_SIZE"],
        ) 
开发者ID:btashton,项目名称:flask-influxdb,代码行数:22,代码来源:flask_influxdb.py

示例11: connection

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def connection(self) -> influxdb.InfluxDBClient:
        """
        InfluxDBClient object
        :return:
        """
        ctx = _app_ctx_stack.top
        if ctx is None:
            raise RuntimeError(_app_ctx_err_msg)

        if not hasattr(ctx, "influxdb_db"):
            ctx.influxdb_db = self.connect()

        if ctx.influxdb_db is None:
            raise RuntimeError(_no_influx_msg)

        return ctx.influxdb_db 
开发者ID:btashton,项目名称:flask-influxdb,代码行数:18,代码来源:flask_influxdb.py

示例12: _get_influx_client

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def _get_influx_client():
        verify = CONF.storage_influxdb.use_ssl and not \
            CONF.storage_influxdb.insecure

        if verify and CONF.storage_influxdb.cafile:
            verify = CONF.storage_influxdb.cafile

        return influxdb.InfluxDBClient(
            username=CONF.storage_influxdb.username,
            password=CONF.storage_influxdb.password,
            host=CONF.storage_influxdb.host,
            port=CONF.storage_influxdb.port,
            database=CONF.storage_influxdb.database,
            ssl=CONF.storage_influxdb.use_ssl,
            verify_ssl=verify,
        ) 
开发者ID:openstack,项目名称:cloudkitty,代码行数:18,代码来源:influx.py

示例13: ship_points

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def ship_points(self, points):
        """Make a connection to InfluxDB and ship points."""

        if self.conf is not None:
            try:
                client = InfluxDBClient(
                    host=self.conf.influx_host,
                    port=self.conf.influx_port,
                    username=self.conf.influx_user,
                    password=self.conf.influx_pwd,
                    database=self.conf.influx_db,
                    timeout=self.conf.influx_timeout)
                if client:
                    if client.write_points(points=points, time_precision='s'):
                        return True
                    self.logger.warning(
                        '%s failed to update InfluxDB' % self.ship_error_prefix)
                else:
                    self.logger.warning(
                        '%s error connecting to InfluxDB' % self.ship_error_prefix)
            except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout,
                    InfluxDBClientError, InfluxDBServerError) as err:
                self.logger.warning('%s %s' % (self.ship_error_prefix, err))
        return False 
开发者ID:faucetsdn,项目名称:faucet,代码行数:26,代码来源:gauge_influx.py

示例14: connect_db

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def connect_db():
    '''
    Connects to Infludb.
    '''

    # returning InfluxDBClient object.
    try:
        conn = InfluxDBClient(var.db_host,
                              var.db_port,
                              var.db_user,
                              var.db_password,
                              var.db_name)

    except Exception as err:
        log("[ERROR] " + str(err), 0)
        sys.exit(1)

    return conn 
开发者ID:ivopetiz,项目名称:algotrading,代码行数:20,代码来源:aux.py

示例15: ship_points_to_influxdb

# 需要导入模块: import influxdb [as 别名]
# 或者: from influxdb import InfluxDBClient [as 别名]
def ship_points_to_influxdb(points):
    client = InfluxDBClient(
        host=INFLUXDB_HOST, port=INFLUXDB_PORT,
        username=INFLUXDB_USER, password=INFLUXDB_PASS,
        database=INFLUXDB_DB, timeout=10)
    return client.write_points(points=points, time_precision='s') 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:8,代码来源:gauge.py


注:本文中的influxdb.InfluxDBClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。