mirror of https://github.com/nicolargo/glances
InfluxDB module: Python 3 support
parent
fa765ed415
commit
ed6d3bd94d
|
@ -58,8 +58,10 @@ class GlancesExport(object):
|
|||
|
||||
def update(self, stats):
|
||||
"""Update stats to a server.
|
||||
The method buil two list: names and values
|
||||
and call the export method to export the stats"""
|
||||
|
||||
The method builds two lists: names and values
|
||||
and calls the export method to export the stats.
|
||||
"""
|
||||
if not self.export_enable:
|
||||
return False
|
||||
|
||||
|
@ -67,20 +69,17 @@ class GlancesExport(object):
|
|||
all_stats = stats.getAll()
|
||||
plugins = stats.getAllPlugins()
|
||||
|
||||
# Loop over available plugin
|
||||
i = 0
|
||||
for plugin in plugins:
|
||||
# Loop over available plugins
|
||||
for i, plugin in enumerate(plugins):
|
||||
if plugin in self.plugins_to_export():
|
||||
if type(all_stats[i]) is list:
|
||||
for item in all_stats[i]:
|
||||
export_names = map(
|
||||
lambda x: item[item['key']] + '.' + x, item.keys())
|
||||
export_values = item.values()
|
||||
export_names = list(map(lambda x: item[item['key']] + '.' + x, item.keys()))
|
||||
export_values = list(item.values())
|
||||
self.export(plugin, export_names, export_values)
|
||||
elif type(all_stats[i]) is dict:
|
||||
export_names = all_stats[i].keys()
|
||||
export_values = all_stats[i].values()
|
||||
export_names = list(all_stats[i].keys())
|
||||
export_values = list(all_stats[i].values())
|
||||
self.export(plugin, export_names, export_values)
|
||||
i += 1
|
||||
|
||||
return True
|
||||
|
|
|
@ -20,14 +20,18 @@
|
|||
"""InfluxDB interface class."""
|
||||
|
||||
# Import sys libs
|
||||
from influxdb import InfluxDBClient, client
|
||||
import sys
|
||||
try:
|
||||
from configparser import NoOptionError, NoSectionError
|
||||
except ImportError: # Python 2
|
||||
from ConfigParser import NoOptionError, NoSectionError
|
||||
|
||||
# Import Glances lib
|
||||
from glances.core.glances_logging import logger
|
||||
from ConfigParser import NoSectionError, NoOptionError
|
||||
from glances.exports.glances_export import GlancesExport
|
||||
|
||||
from influxdb import InfluxDBClient, client
|
||||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
|
|
Loading…
Reference in New Issue