Skip to content

Commit

Permalink
Use agent 8 signature (#9519)
Browse files Browse the repository at this point in the history
* Use agent 8 signature
  • Loading branch information
hithwen authored and alexandre-normand committed Jun 23, 2021
1 parent cdf1f2c commit 0ce131b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions cacti/datadog_checks/cacti/cacti.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pymysql

from datadog_checks.base import AgentCheck
from datadog_checks.base import AgentCheck, ConfigurationError

try:
import rrdtool
Expand Down Expand Up @@ -40,17 +40,17 @@ def __init__(self, name, init_config, instances):
super(CactiCheck, self).__init__(name, init_config, instances)
self.last_ts = {}
# Load the instance config
self._config = self._get_config(instances[0])
self._config = self._get_config()

@staticmethod
def get_library_versions():
if rrdtool is not None:
return {"rrdtool": rrdtool.__version__}
return {"rrdtool": "Not Found"}

def check(self, instance):
def check(self, _):
if rrdtool is None:
raise Exception("Unable to import python rrdtool module")
raise ConfigurationError("Unable to import python rrdtool module")

connection = self._get_connection()

Expand Down Expand Up @@ -91,22 +91,21 @@ def _get_whitelist_patterns(self, whitelist=None):

return patterns

@classmethod
def _get_config(cls, instance):
def _get_config(self):
required = ['mysql_host', 'mysql_user', 'rrd_path']
for param in required:
if not instance.get(param):
raise Exception("Cacti instance missing %s. Skipping." % (param))

host = instance.get('mysql_host')
user = instance.get('mysql_user')
password = instance.get('mysql_password', '') or ''
db = instance.get('mysql_db', 'cacti')
port = instance.get('mysql_port')
rrd_path = instance.get('rrd_path')
whitelist = instance.get('rrd_whitelist')
field_names = instance.get('field_names', ['ifName', 'dskDevice'])
tags = instance.get('tags', [])
if not self.instance.get(param):
raise ConfigurationError("Cacti instance missing %s. Skipping." % param)

host = self.instance.get('mysql_host')
user = self.instance.get('mysql_user')
password = self.instance.get('mysql_password', '') or ''
db = self.instance.get('mysql_db', 'cacti')
port = self.instance.get('mysql_port')
rrd_path = self.instance.get('rrd_path')
whitelist = self.instance.get('rrd_whitelist')
field_names = self.instance.get('field_names', ['ifName', 'dskDevice'])
tags = self.instance.get('tags', [])

Config = namedtuple(
'Config', ['host', 'user', 'password', 'db', 'port', 'rrd_path', 'whitelist', 'field_names', 'tags']
Expand Down

0 comments on commit 0ce131b

Please sign in to comment.