Code Duplication    Length = 17-20 lines in 4 locations

glances/exports/glances_opentsdb.py 1 location

@@ 36-54 (lines=19) @@
33
34
    """This class manages the OpenTSDB export module."""
35
36
    def __init__(self, config=None, args=None):
37
        """Init the OpenTSDB export IF."""
38
        super(Export, self).__init__(config=config, args=args)
39
40
        # Load the InfluxDB configuration file
41
        self.host = None
42
        self.port = None
43
        self.prefix = None
44
        self.tags = None
45
        self.export_enable = self.load_conf()
46
        if not self.export_enable:
47
            sys.exit(2)
48
49
        # Default prefix for stats is 'glances'
50
        if self.prefix is None:
51
            self.prefix = 'glances'
52
53
        # Init the OpenTSDB client
54
        self.client = self.init()
55
56
    def load_conf(self, section="opentsdb"):
57
        """Load the OpenTSDB configuration in the Glances configuration file."""

glances/exports/glances_rabbitmq.py 1 location

@@ 39-55 (lines=17) @@
36
37
    """This class manages the rabbitMQ export module."""
38
39
    def __init__(self, config=None, args=None):
40
        """Init the RabbitMQ export IF."""
41
        super(Export, self).__init__(config=config, args=args)
42
43
        # Load the rabbitMQ configuration file
44
        self.rabbitmq_host = None
45
        self.rabbitmq_port = None
46
        self.rabbitmq_user = None
47
        self.rabbitmq_password = None
48
        self.rabbitmq_queue = None
49
        self.hostname = socket.gethostname()
50
        self.export_enable = self.load_conf()
51
        if not self.export_enable:
52
            sys.exit(2)
53
54
        # Init the rabbitmq client
55
        self.client = self.init()
56
57
    def load_conf(self, section="rabbitmq"):
58
        """Load the rabbitmq configuration in the Glances configuration file."""

glances/exports/glances_influxdb.py 1 location

@@ 42-59 (lines=18) @@
39
40
    """This class manages the InfluxDB export module."""
41
42
    def __init__(self, config=None, args=None):
43
        """Init the InfluxDB export IF."""
44
        super(Export, self).__init__(config=config, args=args)
45
46
        # Load the InfluxDB configuration file
47
        self.host = None
48
        self.port = None
49
        self.user = None
50
        self.password = None
51
        self.db = None
52
        self.prefix = None
53
        self.tags = None
54
        self.export_enable = self.load_conf()
55
        if not self.export_enable:
56
            sys.exit(2)
57
58
        # Init the InfluxDB client
59
        self.client = self.init()
60
61
    def load_conf(self, section="influxdb"):
62
        """Load the InfluxDb configuration in the Glances configuration file."""

glances/exports/glances_statsd.py 1 location

@@ 36-55 (lines=20) @@
33
34
    """This class manages the Statsd export module."""
35
36
    def __init__(self, config=None, args=None):
37
        """Init the Statsd export IF."""
38
        super(Export, self).__init__(config=config, args=args)
39
40
        # Load the InfluxDB configuration file
41
        self.host = None
42
        self.port = None
43
        self.prefix = None
44
        self.export_enable = self.load_conf()
45
        if not self.export_enable:
46
            sys.exit(2)
47
48
        # Default prefix for stats is 'glances'
49
        if self.prefix is None:
50
            self.prefix = 'glances'
51
52
        # Init the Statsd client
53
        self.client = StatsClient(self.host,
54
                                  int(self.port),
55
                                  prefix=self.prefix)
56
57
    def load_conf(self, section="statsd"):
58
        """Load the Statsd configuration in the Glances configuration file."""