Skip to content

Commit 710eb90

Browse files
authored
Merge pull request #58 from altor/change
Cli support for influxdb
2 parents 5580d22 + c99c74f commit 710eb90

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

powerapi/cli/tools.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from powerapi.cli.parser import BadTypeException, BadContextException
3939
from powerapi.cli.parser import UnknowArgException
4040
from powerapi.report_model import HWPCModel, PowerModel
41-
from powerapi.database import MongoDB, CsvDB
41+
from powerapi.database import MongoDB, CsvDB, InfluxDB
4242
from powerapi.puller import PullerActor
4343
from powerapi.pusher import PusherActor
4444

@@ -88,7 +88,12 @@ def __init__(self):
8888
subparser_csv_output.add_argument('m', 'model', help='specify data type that will be storen in the database', default='power_report')
8989
self.add_component_subparser('output', subparser_csv_output, help_str='specify a database input : --db_output database_name ARG1 ARG2 ... ')
9090

91-
91+
subparser_influx_output = ComponentSubParser('influxdb')
92+
subparser_influx_output.add_argument('u', 'uri', help='sepcify InfluxDB uri')
93+
subparser_influx_output.add_argument('d', 'db', help='specify InfluxDB database name')
94+
subparser_influx_output.add_argument('p', 'port', help='specify InfluxDB connection port', type=int)
95+
subparser_influx_output.add_argument('m', 'model', help='specify data type that will be storen in the database', default='power_report')
96+
self.add_component_subparser('output', subparser_influx_output, help_str='specify a database input : --db_output database_name ARG1 ARG2 ... ')
9297

9398

9499
def parse_argv(self):
@@ -124,7 +129,8 @@ def parse_argv(self):
124129

125130
DB_FACTORY = {
126131
'mongodb': lambda db_config: MongoDB(db_config['uri'], db_config['db'], db_config['collection']),
127-
'csv': lambda db_config: CsvDB(current_path=os.getcwd() if 'directory' not in db_config else db_config['directory'], files=[] if 'files' not in db_config else db_config['files'])
132+
'csv': lambda db_config: CsvDB(current_path=os.getcwd() if 'directory' not in db_config else db_config['directory'], files=[] if 'files' not in db_config else db_config['files']),
133+
'influxdb': lambda db_config: InfluxDB(db_config['uri'], db_config['port'], db_config['db']),
128134
}
129135

130136

0 commit comments

Comments
 (0)