Added loadavg to RRD data

master
Thomas Hooge 2020-01-16 18:10:24 +01:00
parent c0cce374c6
commit 1e7c7f7b7b
1 changed files with 12 additions and 10 deletions

View File

@ -8,16 +8,13 @@ class NodeRRD(RRD):
ds_list = [ ds_list = [
DS('upstate', 'GAUGE', 120, 0, 1), DS('upstate', 'GAUGE', 120, 0, 1),
DS('clients', 'GAUGE', 120, 0, float('NaN')), DS('clients', 'GAUGE', 120, 0, float('NaN')),
DS('loadavg', 'GAUGE', 120, 0, float('NaN')),
] ]
rra_list = [ rra_list = [
# 2 hours of 1 minute samples RRA('AVERAGE', 0.5, 1, 120), # 2 hours of 1 minute samples
RRA('AVERAGE', 0.5, 1, 120), RRA('AVERAGE', 0.5, 5, 1440), # 5 days of 5 minute samples
# 5 days of 5 minute samples RRA('AVERAGE', 0.5, 60, 720), # 30 days of 1 hour samples
RRA('AVERAGE', 0.5, 5, 1440), RRA('AVERAGE', 0.5, 720, 730), # 1 year of 12 hour samples
# 30 days of 1 hour samples
RRA('AVERAGE', 0.5, 60, 720),
# 1 year of 12 hour samples
RRA('AVERAGE', 0.5, 720, 730),
] ]
def __init__(self, filename, node=None): def __init__(self, filename, node=None):
@ -37,8 +34,13 @@ class NodeRRD(RRD):
# TODO: fix this, python does not support function overloading # TODO: fix this, python does not support function overloading
def update(self): def update(self):
super().update({'upstate': int(self.node['flags']['online']), values = {
'clients': self.node['statistics']['clients']}) '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): def graph(self, directory, timeframe):
""" """