예제 #1
0
    def __init__(self, cli_args=None):
        self.domains = defaultdict(Domain)

        if cli_args:
            self.interactive = cli_args.interactive
            self.verbose = cli_args.verbose

            self.influxdb = parse_handle(cli_args.influxdb)
            self.influxdb.update({
                "group_fields": cli_args.group_fields,
            })
            self.paths = {
                "munin": cli_args.munin_path,
                "datafile": os.path.join(cli_args.munin_path, 'datafile'),
                "fetch_config": cli_args.fetch_config_path,
                "www": cli_args.www,
                "xml": cli_args.xml_temp_path,
            }
            self.grafana = {
                "create": cli_args.grafana,
                "filename": cli_args.grafana_file,
                "title": cli_args.grafana_title,
                "graph_per_row": cli_args.grafana_cols,
                "tags": cli_args.grafana_tags,
                "show_minmax": cli_args.show_minmax,
            }
        else:
            self.interactive = True
            self.verbose = 1

            self.influxdb = parse_handle("root@localhost:8086/db/munin")
            self.influxdb.update({"group_fields": True})
            self.paths = {
                "munin": Defaults.MUNIN_VAR_FOLDER,
                "datafile": os.path.join(Defaults.MUNIN_VAR_FOLDER, 'datafile'),
                "fetch_config": Defaults.FETCH_CONFIG,
                "www": Defaults.MUNIN_WWW_FOLDER,
                "xml": Defaults.MUNIN_XML_FOLDER,
            }
            self.grafana = {
                "create": True,
                "filename": "/tmp/munin-influxdb/munin-grafana.json",
                "title": "Munin Dashboard",
                "graph_per_row": 2,
                "tags": "grafana munin",
                "show_minmax": True,
            }


        self.nb_plugins = 0
        self.nb_fields = 0
        self.nb_rrd_files = 0
    def __init__(self, cli_args=None):
        self.domains = defaultdict(Domain)

        if cli_args:
            self.interactive = cli_args.interactive
            self.verbose = cli_args.verbose

            self.influxdb = parse_handle(cli_args.influxdb)
            self.influxdb.update({
                "group_fields": cli_args.group_fields,
            })
            self.paths = {
                "munin": cli_args.munin_path,
                "datafile": os.path.join(cli_args.munin_path, 'datafile'),
                "fetch_config": cli_args.fetch_config_path,
                "www": cli_args.www,
                "xml": cli_args.xml_temp_path,
            }
            self.grafana = {
                "create": cli_args.grafana,
                "filename": cli_args.grafana_file,
                "title": cli_args.grafana_title,
                "graph_per_row": cli_args.grafana_cols,
                "tags": cli_args.grafana_tags,
                "show_minmax": cli_args.show_minmax,
            }
        else:
            self.interactive = True
            self.verbose = 1

            self.influxdb = parse_handle("root@localhost:8086/db/munin")
            self.influxdb.update({"group_fields": True})
            self.paths = {
                "munin": Defaults.MUNIN_VAR_FOLDER,
                "datafile": os.path.join(Defaults.MUNIN_VAR_FOLDER,
                                         'datafile'),
                "fetch_config": Defaults.FETCH_CONFIG,
                "www": Defaults.MUNIN_WWW_FOLDER,
                "xml": Defaults.MUNIN_XML_FOLDER,
            }
            self.grafana = {
                "create": True,
                "filename": "/tmp/munin-influxdb/munin-grafana.json",
                "title": "Munin Dashboard",
                "graph_per_row": 2,
                "tags": "grafana munin",
                "show_minmax": True,
            }

        self.nb_plugins = 0
        self.nb_fields = 0
        self.nb_rrd_files = 0
예제 #3
0
    def prompt_setup(self):
        setup = self.settings.influxdb
        print("\n{0}InfluxDB: Please enter your connection information{1}".format(Color.BOLD, Color.CLEAR))
        while not self.client:
            hostname = raw_input("  - host/handle [{0}]: ".format(setup['host'])) or setup['host']

            # I miss pointers and explicit references :(
            setup.update(parse_handle(hostname))
            if setup['port'] is None:
                setup['port'] = 8086

            # shortcut if everything is in the handle
            if self.connect(silent=True):
                break

            setup['port'] = raw_input("  - port [{0}]: ".format(setup['port'])) or setup['port']
            setup['user'] = raw_input("  - user [{0}]: ".format(setup['user'])) or setup['user']
            setup['password'] = InfluxdbClient.ask_password()

            self.connect()

        while True:
            if setup['database'] == "?":
                self.list_db()
            else:
                if self.test_db(setup['database']):
                    break
            setup['database'] = raw_input("  - database [munin]: ") or "munin"

        group = raw_input("Group multiple fields of the same plugin in the same time series? [y]/n: ") or "y"
        setup['group_fields'] = group in ("y", "Y")
예제 #4
0
    def __init__(self, cli_args):
        self.domains = defaultdict(Domain)

        self.interactive = cli_args.interactive
        self.verbose = cli_args.verbose

        self.influxdb = parse_handle(cli_args.influxdb)
        self.influxdb.update({
            "group_fields": cli_args.group_fields,
        })
        self.paths = {
            "munin": cli_args.munin_path,
            "datafile": os.path.join(cli_args.munin_path, 'datafile'),
            "fetch_config": cli_args.fetch_config_path,
            "www": cli_args.www,
            "xml": cli_args.xml_temp_path,
        }
        self.grafana = {
            "create": cli_args.grafana,
            "filename": cli_args.grafana_file,
            "title": cli_args.grafana_title,
            "graph_per_row": cli_args.grafana_cols,
            "tags": cli_args.grafana_tags,
            "show_minmax": cli_args.show_minmax,
        }

        self.nb_plugins = 0
        self.nb_fields = 0
        self.nb_rrd_files = 0
    def prompt_setup(self):
        setup = self.settings.influxdb
        print("\n{0}InfluxDB: Please enter your connection information{1}".
              format(Color.BOLD, Color.CLEAR))
        while not self.client:
            #hostname = raw_input("  - host/handle [{0}]: ".format(setup['host'])) or setup['host']
            print("----Autolization...-----")
            hostname = setup['host']
            # I miss pointers and explicit references :(
            setup.update(parse_handle(hostname))
            if setup['port'] is None:
                setup['port'] = 8086

            # shortcut if everything is in the handle
            if self.connect(silent=True):
                break

            #setup['port'] = raw_input("  - port [{0}]: ".format(setup['port'])) or setup['port']
            #setup['user'] = raw_input("  - user [{0}]: ".format(setup['user'])) or setup['user']
            setup['port'] = setup['port']
            setup['user'] = '******'
            setup['password'] = InfluxdbClient.ask_password()

            self.connect()

        while True:
            if setup['database'] == "?":
                self.list_db()
            else:
                if self.test_db(setup['database']):
                    break
            #setup['database'] = raw_input("  - database [munin]: ") or "munin"
            setup['database'] = "munin"
            print("---------_Auto_---------")

        #group = raw_input("Group multiple fields of the same plugin in the same time series? [y]/n: ") or "y"
        print(
            "Group multiple fields of the same plugin in the same time series?"
        )
        print("-----------_Auto_------------")
        group = 'y'
        setup['group_fields'] = group in ("y", "Y")
예제 #6
0
 class MockSettings:
     influxdb = parse_handle("[email protected]:8086/db/munin")
     influxdb.update({"group_fields": True})