Code Duplication    Length = 18-22 lines in 3 locations

glances/exports/glances_opentsdb/__init__.py 1 location

@@ 25-46 (lines=22) @@
22
23
    """This class manages the OpenTSDB export module."""
24
25
    def __init__(self, config=None, args=None):
26
        """Init the OpenTSDB export IF."""
27
        super(Export, self).__init__(config=config, args=args)
28
29
        # Mandatory configuration keys (additional to host and port)
30
        # N/A
31
32
        # Optionals configuration keys
33
        self.prefix = None
34
        self.tags = None
35
36
        # Load the configuration file
37
        self.export_enable = self.load_conf('opentsdb', mandatories=['host', 'port'], options=['prefix', 'tags'])
38
        if not self.export_enable:
39
            exit('Missing OPENTSDB config')
40
41
        # Default prefix for stats is 'glances'
42
        if self.prefix is None:
43
            self.prefix = 'glances'
44
45
        # Init the OpenTSDB client
46
        self.client = self.init()
47
48
    def init(self):
49
        """Init the connection to the OpenTSDB server."""

glances/exports/glances_statsd/__init__.py 1 location

@@ 24-44 (lines=21) @@
21
22
    """This class manages the Statsd export module."""
23
24
    def __init__(self, config=None, args=None):
25
        """Init the Statsd export IF."""
26
        super(Export, self).__init__(config=config, args=args)
27
28
        # Mandatory configuration keys (additional to host and port)
29
        # N/A
30
31
        # Optional configuration keys
32
        self.prefix = None
33
34
        # Load the configuration file
35
        self.export_enable = self.load_conf('statsd', mandatories=['host', 'port'], options=['prefix'])
36
        if not self.export_enable:
37
            exit('Missing STATSD config')
38
39
        # Default prefix for stats is 'glances'
40
        if self.prefix is None:
41
            self.prefix = 'glances'
42
43
        # Init the Statsd client
44
        self.client = self.init()
45
46
    def init(self):
47
        """Init the connection to the Statsd server."""

glances/exports/glances_zeromq/__init__.py 1 location

@@ 27-44 (lines=18) @@
24
25
    """This class manages the ZeroMQ export module."""
26
27
    def __init__(self, config=None, args=None):
28
        """Init the ZeroMQ export IF."""
29
        super(Export, self).__init__(config=config, args=args)
30
31
        # Mandatory configuration keys (additional to host and port)
32
        self.prefix = None
33
34
        # Optionals configuration keys
35
        # N/A
36
37
        # Load the ZeroMQ configuration file section ([export_zeromq])
38
        self.export_enable = self.load_conf('zeromq', mandatories=['host', 'port', 'prefix'], options=[])
39
        if not self.export_enable:
40
            exit('Missing ZEROMQ config')
41
42
        # Init the ZeroMQ context
43
        self.context = None
44
        self.client = self.init()
45
46
    def init(self):
47
        """Init the connection to the CouchDB server."""