Ejemplo n.º 1
0
 def stat_metrics(self):
     data = read_data_from_file(dump_file=self._dump_files["stat"])
     for metric, value in data["stats"].items():
         if not isinstance(value, (int, float)):
             continue
         gauge = GaugeMetricFamily(
             f"synology_stats_{metric}",
             f"Synology Stats Metrics",
             labels=["dsm"]
         )
         gauge.add_metric([self.name], value)
         yield gauge
Ejemplo n.º 2
0
 def share_metrics(self):
     data = read_data_from_file(dump_file=self._dump_files["share"])
     for metric, value in data["shares"][0].items():
         if not isinstance(value, (int, float)):
             continue
         gauge = GaugeMetricFamily(
             f"synology_share_{metric}",
             f"Synology Share Metrics",
             labels=["dsm", "uuid", "path"]
         )
         for share in data["shares"]:
             tags = [self.name, share["uuid"], share["path"]]
             gauge.add_metric(tags, share[metric])
         yield gauge
Ejemplo n.º 3
0
 def disk_metrics(self):
     data = read_data_from_file(dump_file=self._dump_files["storage"])
     for metric, value in data["disks"][0].items():
         if not isinstance(value, (int, float)):
             continue
         gauge = GaugeMetricFamily(
             f"synology_disk_{metric}",
             f"Synology Disk Metrics",
             labels=["dsm", "id", "name"]
         )
         for disk in data["disks"]:
             tags = [self.name, disk["id"], disk["name"]]
             gauge.add_metric(tags, disk[metric])
         yield gauge
Ejemplo n.º 4
0
 def volume_metrics(self):
     data = read_data_from_file(dump_file=self._dump_files["storage"])
     for metric, value in data["volumes"][0].items():
         if not isinstance(value, (int, float)):
             continue
         gauge = GaugeMetricFamily(
             f"synology_volume_{metric}",
             f"Synology Volume Metrics",
             labels=["dsm", "id"]
         )
         for volume in data["volumes"]:
             tags = [self.name, volume["id"]]
             gauge.add_metric(tags, volume[metric])
         yield gauge
Ejemplo n.º 5
0
 def get_collect_status(self, metric_type):
     data = read_data_from_file(dump_file=self._dump_files[metric_type])
     return bool(data.get("collect_status", 0))