diff options
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, |