From 1e7c7f7b7be0185920bca0b56f8291c37197cc9d Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Thu, 16 Jan 2020 18:10:24 +0100 Subject: [PATCH] Added loadavg to RRD data --- lib/NodeRRD.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/NodeRRD.py b/lib/NodeRRD.py index afabe6f..714b0f2 100644 --- a/lib/NodeRRD.py +++ b/lib/NodeRRD.py @@ -8,16 +8,13 @@ class NodeRRD(RRD): ds_list = [ DS('upstate', 'GAUGE', 120, 0, 1), DS('clients', 'GAUGE', 120, 0, float('NaN')), + DS('loadavg', 'GAUGE', 120, 0, float('NaN')), ] rra_list = [ - # 2 hours of 1 minute samples - RRA('AVERAGE', 0.5, 1, 120), - # 5 days of 5 minute samples - RRA('AVERAGE', 0.5, 5, 1440), - # 30 days of 1 hour samples - RRA('AVERAGE', 0.5, 60, 720), - # 1 year of 12 hour samples - RRA('AVERAGE', 0.5, 720, 730), + RRA('AVERAGE', 0.5, 1, 120), # 2 hours of 1 minute samples + RRA('AVERAGE', 0.5, 5, 1440), # 5 days of 5 minute samples + RRA('AVERAGE', 0.5, 60, 720), # 30 days of 1 hour samples + RRA('AVERAGE', 0.5, 720, 730), # 1 year of 12 hour samples ] def __init__(self, filename, node=None): @@ -37,8 +34,13 @@ class NodeRRD(RRD): # TODO: fix this, python does not support function overloading def update(self): - super().update({'upstate': int(self.node['flags']['online']), - 'clients': self.node['statistics']['clients']}) + values = { + 'upstate': int(self.node['flags']['online']), + 'clients': self.node['statistics']['clients'] + } + if 'loadavg' in self.node['statistics']: + values['loadavg'] = float(self.node['statistics']['loadavg']) + super().update(values) def graph(self, directory, timeframe): """