@cryptotaxi247 / netdata-1 / commits / 7dba68d0e

megacli: create separate chart for every bbu (needed for aralms)

lgz committed Jul 7, 2018 at 12:37 UTC 7dba68d0e2d815e85102fdb76a2d87c126b28347
1 file changed +32 -22
python.d/megacli.chart.py
+32 -22
@@ -58,26 +58,36 @@ def pd_charts(pds):
58
59
60 def battery_charts(bats):
61 - order = [
62 - 'relative_charge',
63 - 'cycle_count',
64 - ]
65 -
66 - def dims(k, bat):
67 - return [['battery_{0}_{1}'.format(b.id, k), 'adapter {0}'.format(b.id)] for b in bat]
68 -
69 - charts = {
70 - 'relative_charge': {
71 - 'options': [
72 - None, 'Relative State of Charge', '%', 'battery', 'megacli.relative_charge', 'line'],
73 - 'lines': dims("relative_charge", bats)
74 - },
75 - 'cycle_count': {
76 - 'options': [
77 - None, 'Cycle Count', 'cycle count', 'battery', 'megacli.cycle_count', 'line'],
78 - 'lines': dims("cycle_count", bats)
79 - },
80 - }
61 + order = list()
62 + charts = dict()
63 +
64 + for b in bats:
65 + order.append('bbu_{0}_relative_charge'.format(b.id))
66 + charts.update(
67 + {
68 + 'bbu_{0}_relative_charge'.format(b.id): {
69 + 'options': [
70 + None, 'Relative State of Charge', '%', 'battery', 'megacli.bbu_relative_charge', 'line'],
71 + 'lines': [
72 + ['bbu_{0}_relative_charge'.format(b.id), 'adapter {0}'.format(b.id)],
73 + ]
74 + }
75 + }
76 + )
77 +
78 + for b in bats:
79 + order.append('bbu_{0}_cycle_count'.format(b.id))
80 + charts.update(
81 + {
82 + 'bbu_{0}_cycle_count'.format(b.id): {
83 + 'options': [
84 + None, 'Cycle Count', 'cycle count', 'battery', 'megacli.bbu_cycle_count', 'line'],
85 + 'lines': [
86 + ['bbu_{0}_cycle_count'.format(b.id), 'adapter {0}'.format(b.id)],
87 + ]
88 + }
89 + }
90 + )
91
92 return order, charts
93
@@ -145,8 +155,8 @@ class Battery:
155
156 def data(self):
157 return {
148 - 'battery_{0}_relative_charge'.format(self.id): self.rel_charge,
149 - 'battery_{0}_cycle_count'.format(self.id): self.cycle_count,
158 + 'bbu_{0}_relative_charge'.format(self.id): self.rel_charge,
159 + 'bbu_{0}_cycle_count'.format(self.id): self.cycle_count,
160 }
161
162