@@ 56-84 (lines=29) @@ | ||
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.""" |
|
58 | if self.config is None: |
|
59 | return False |
|
60 | try: |
|
61 | self.host = self.config.get_value(section, 'host') |
|
62 | self.port = self.config.get_value(section, 'port') |
|
63 | except NoSectionError: |
|
64 | logger.critical("No OpenTSDB configuration found") |
|
65 | return False |
|
66 | except NoOptionError as e: |
|
67 | logger.critical("Error in the OpenTSDB configuration (%s)" % e) |
|
68 | return False |
|
69 | else: |
|
70 | logger.debug("Load OpenTSDB from the Glances configuration file") |
|
71 | ||
72 | # Prefix is optional |
|
73 | try: |
|
74 | self.prefix = self.config.get_value(section, 'prefix') |
|
75 | except NoOptionError: |
|
76 | pass |
|
77 | ||
78 | # Tags are optional, comma separated key:value pairs. |
|
79 | try: |
|
80 | self.tags = self.config.get_value(section, 'tags') |
|
81 | except NoOptionError: |
|
82 | pass |
|
83 | ||
84 | return True |
|
85 | ||
86 | def init(self): |
|
87 | """Init the connection to the OpenTSDB server.""" |
@@ 57-77 (lines=21) @@ | ||
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.""" |
|
59 | if self.config is None: |
|
60 | return False |
|
61 | try: |
|
62 | self.host = self.config.get_value(section, 'host') |
|
63 | self.port = self.config.get_value(section, 'port') |
|
64 | except NoSectionError: |
|
65 | logger.critical("No Statsd configuration found") |
|
66 | return False |
|
67 | except NoOptionError as e: |
|
68 | logger.critical("Error in the Statsd configuration (%s)" % e) |
|
69 | return False |
|
70 | else: |
|
71 | logger.debug("Load Statsd from the Glances configuration file") |
|
72 | # Prefix is optional |
|
73 | try: |
|
74 | self.prefix = self.config.get_value(section, 'prefix') |
|
75 | except NoOptionError: |
|
76 | pass |
|
77 | return True |
|
78 | ||
79 | def init(self, prefix='glances'): |
|
80 | """Init the connection to the Statsd server.""" |
@@ 53-68 (lines=16) @@ | ||
50 | # Init the Riemann client |
|
51 | self.client = self.init() |
|
52 | ||
53 | def load_conf(self, section="riemann"): |
|
54 | """Load the Riemann configuration in the Glances configuration file.""" |
|
55 | if self.config is None: |
|
56 | return False |
|
57 | try: |
|
58 | self.riemann_host = self.config.get_value(section, 'host') |
|
59 | self.riemann_port = int(self.config.get_value(section, 'port')) |
|
60 | except NoSectionError: |
|
61 | logger.critical("No riemann configuration found") |
|
62 | return False |
|
63 | except NoOptionError as e: |
|
64 | logger.critical("Error in the Riemann configuration (%s)" % e) |
|
65 | return False |
|
66 | else: |
|
67 | logger.debug("Load Riemann from the Glances configuration file") |
|
68 | return True |
|
69 | ||
70 | def init(self): |
|
71 | """Init the connection to the Riemann server.""" |
@@ 51-68 (lines=18) @@ | ||
48 | # Init the ES client |
|
49 | self.client = self.init() |
|
50 | ||
51 | def load_conf(self, section="elasticsearch"): |
|
52 | """Load the ES configuration in the Glances configuration file.""" |
|
53 | if self.config is None: |
|
54 | return False |
|
55 | try: |
|
56 | self.host = self.config.get_value(section, 'host') |
|
57 | self.port = self.config.get_value(section, 'port') |
|
58 | self.index = self.config.get_value(section, 'index') |
|
59 | except NoSectionError: |
|
60 | logger.critical("No ElasticSearch configuration found") |
|
61 | return False |
|
62 | except NoOptionError as e: |
|
63 | logger.critical("Error in the ElasticSearch configuration (%s)" % e) |
|
64 | return False |
|
65 | else: |
|
66 | logger.debug("Load ElasticSearch from the Glances configuration file") |
|
67 | ||
68 | return True |
|
69 | ||
70 | def init(self): |
|
71 | """Init the connection to the ES server.""" |