diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2023-12-29 20:54:27 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2023-12-29 20:54:27 +0100 |
commit | fb92c041389d2eb39eb1f4192ba77ddf90e364b4 (patch) | |
tree | 628a58c5b6718202953047f59f61eeee1cbbaec3 /rrd | |
parent | cd5fbeb4b35408a8bfbb92e0d675880a71f0f01c (diff) |
Add a ds_name property
Diffstat (limited to 'rrd')
-rw-r--r-- | rrd/models.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rrd/models.py b/rrd/models.py index 1d1e5e9..3cace0c 100644 --- a/rrd/models.py +++ b/rrd/models.py @@ -60,7 +60,11 @@ class DataSource(ModelWithPerms): log.warning("Failure reading from ds: %s", e) return (None, None) else: - return last["date"], last["ds"][self.topic.split("/")[-1]] + return last["date"], last["ds"][self.ds_name] + + @property + def ds_name(self): + return self.topic.split("/")[-1] def update(self, ts, value): rrd_path = os.path.join(settings.RRD_DB_PATH, self.path) @@ -69,7 +73,7 @@ class DataSource(ModelWithPerms): os.path.join(settings.RRD_DB_PATH, self.path), "--no-overwrite", self.rrd_config.format( - ds_name=self.topic.split("/")[-1] + ds_name=self.ds_name ).strip().split('\n'), ) try: @@ -108,7 +112,7 @@ class Graph(ModelWithPerms): for ds in self.data_sources.all(): rrd_paths.append(os.path.join(settings.RRD_DB_PATH, ds.path)) rrd_topics.append(ds.topic) - rrd_ds_names.append(ds.topic.split("/")[-1]) + rrd_ds_names.append(ds.ds_name) opts = self.rrd_config.format( topics=rrd_topics, ds_names=rrd_ds_names, |