Skip to content

Commit

Permalink
Merge pull request #58 from altor/change
Browse files Browse the repository at this point in the history
Cli support for influxdb
  • Loading branch information
altor authored Jun 6, 2019
2 parents 5580d22 + c99c74f commit 710eb90
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions powerapi/cli/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from powerapi.cli.parser import BadTypeException, BadContextException
from powerapi.cli.parser import UnknowArgException
from powerapi.report_model import HWPCModel, PowerModel
from powerapi.database import MongoDB, CsvDB
from powerapi.database import MongoDB, CsvDB, InfluxDB
from powerapi.puller import PullerActor
from powerapi.pusher import PusherActor

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


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


def parse_argv(self):
Expand Down Expand Up @@ -124,7 +129,8 @@ def parse_argv(self):

DB_FACTORY = {
'mongodb': lambda db_config: MongoDB(db_config['uri'], db_config['db'], db_config['collection']),
'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'])
'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']),
'influxdb': lambda db_config: InfluxDB(db_config['uri'], db_config['port'], db_config['db']),
}


Expand Down

0 comments on commit 710eb90

Please sign in to comment.