-def _get_ip(url):
- return urlsplit(url).hostname
-
-
-def _write_data(measurement, field, timestamp, tags):
- point = {
- 'measurement': measurement,
- 'fields': field,
- 'time': timestamp,
- 'tags': tags
- }
-
- try:
- client = get_data_db_client()
-
- logger.debug('Start to write data: %s', point)
- client.write_points([point])
- except RuntimeError:
- logger.debug('dispatcher is not influxdb')
+def _get_client(parser):
+ ip = _get_ip(parser.get('dispatcher_influxdb', 'target'))
+ user = parser.get('dispatcher_influxdb', 'username')
+ password = parser.get('dispatcher_influxdb', 'password')
+ db_name = parser.get('dispatcher_influxdb', 'db_name')
+ return InfluxDBClient(ip, consts.INFLUXDB_PORT, user, password, db_name)