

def check(self, instance):
    if (rrdtool is None):
        raise Exception('Unable to import python rrdtool module')
    config = self._get_config(instance)
    connection = pymysql.connect(config.host, config.user, config.password, config.db)
    self.log.debug('Connected to MySQL to fetch Cacti metadata')
    patterns = self._get_whitelist_patterns(config.whitelist)
    rrd_meta = self._fetch_rrd_meta(connection, config.rrd_path, patterns, config.field_names)
    metric_count = 0
    for (hostname, device_name, rrd_path) in rrd_meta:
        m_count = self._read_rrd(rrd_path, hostname, device_name)
        metric_count += m_count
    self.gauge('cacti.metrics.count', metric_count)

dataset/ETHPy150Open serverdensity/sd-agent/checks.d/cacti.py Cacti.check/original