code: def _fetch_rrd_meta(self, connection, rrd_path_root, whitelist, field_names, tags):
          ''' Fetch metadata about each RRD in this Cacti DB, returning a list of
              tuples of (hostname, device_name, rrd_path)
          '''
  
          def _in_whitelist(rrd):
              path = rrd.replace('<path_rra>/', '')
              for p in whitelist:
                  if fnmatch(path, p):
                      return True
              return False
  
          c = connection.cursor()
  
          and_parameters = " OR ".join(["hsc.field_name = '%s'" % field_name for field_name in field_names])
  
          # Check for the existence of the `host_snmp_cache` table
          rrd_query = .format(
              and_parameters
          )
  
          c.execute(rrd_query)
          res = []
          for hostname, device_name, rrd_path in c.fetchall():
              if not whitelist or _in_whitelist(rrd_path):
                  if hostname in ('localhost', '127.0.0.1'):
                      hostname = self.hostname
                  rrd_path = rrd_path.replace('<path_rra>', rrd_path_root)
                  device_name = device_name or None
                  res.append((hostname, device_name, rrd_path))
  
          # Collect stats
          num_hosts = len(set([r[0] for r in res]))
          self.gauge('cacti.rrd.count', len(res), tags=tags)
          self.gauge('cacti.hosts.count', num_hosts, tags=tags)
  
          return res
docs: Fetch metadata about each RRD in this Cacti DB, returning a list of
              tuples of (hostname, device_name, rrd_path)