Skip to content

Commit 01cad78

Browse files
committed
style: changed style formatting for system plugins
1 parent 388e505 commit 01cad78

File tree

8 files changed

+31
-42
lines changed

8 files changed

+31
-42
lines changed

mamonsu/plugins/system/linux/disk_sizes.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from mamonsu.plugins.system.plugin import SystemPlugin as Plugin
33

44

5-
6-
75
class DiskSizes(Plugin):
86
AgentPluginType = 'sys'
97

@@ -145,9 +143,8 @@ def discovery_rules(self, template):
145143
rule=rule, conditions=conditions, items=items, graphs=graphs, triggers=triggers)
146144

147145
def keys_and_queries(self, template_zabbix):
148-
result = []
149-
result.append('system.vfs.discovery,{0}{1}'.format(Plugin.PATH, self.query_agent_discovery))
150-
result.append('system.vfs.used[*],{0}'.format(self.query_agent_used))
151-
result.append('system.vfs.free[*],{0}'.format(self.query_agent_free))
152-
result.append('system.vfs.percent_free[*],{0}'.format(self.query_agent_percent_free))
146+
result = ['system.vfs.discovery,{0}{1}'.format(Plugin.PATH, self.query_agent_discovery),
147+
'system.vfs.used[*],{0}'.format(self.query_agent_used),
148+
'system.vfs.free[*],{0}'.format(self.query_agent_free),
149+
'system.vfs.percent_free[*],{0}'.format(self.query_agent_percent_free)]
153150
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/disk_stats.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from mamonsu.plugins.system.plugin import SystemPlugin as Plugin
33

44

5-
6-
75
class DiskStats(Plugin):
86
# todo yaxis right 100%
97
# bold line
@@ -47,7 +45,8 @@ def run(self, zbx):
4745
continue
4846
val = [int(x) for x in val.split()]
4947
read_op, read_sc, write_op, write_sc, ticks = val[0], val[2], val[4], val[6], val[9]
50-
read_b, write_b = read_sc * 512, write_sc * 512 # https://github.com/sysstat/sysstat/blob/v11.5.2/iostat.c#L940
48+
read_b, write_b = read_sc * 512, write_sc * 512
49+
# https://github.com/sysstat/sysstat/blob/v11.5.2/iostat.c#L940
5150

5251
zbx.send('system.disk.read[{0}]'.format(
5352
dev), read_op, self.DELTA_SPEED)
@@ -200,15 +199,14 @@ def discovery_rules(self, template):
200199
return template.discovery_rule(rule=rule, conditions=conditions, items=items, graphs=graphs)
201200

202201
def keys_and_queries(self, template_zabbix):
203-
result = []
204-
result.append('system.disk.discovery,{0}{1}'.format(Plugin.PATH, self.query_agent_discovery))
205-
result.append('system.disk.utilization[*],{0}'.format(self.agent_query_ticks))
206-
result.append('system.disk.read[*],{0}'.format(self.agent_query_read_op))
207-
result.append('system.disk.write[*],{0}'.format(self.agent_query_write_op))
208-
result.append('system.disk.read_b[*],{0}'.format(self.agent_query_read_sc))
209-
result.append('system.disk.write_b[*],{0}'.format(self.agent_query_write_sc))
210-
result.append('system.disk.all_read,{0}{1}'.format(Plugin.PATH, self.agent_query_read_op_all))
211-
result.append('system.disk.all_write,{0}{1}'.format(Plugin.PATH, self.agent_query_write_op_all))
212-
result.append('system.disk.all_read_b,{0}{1}'.format(Plugin.PATH, self.agent_query_read_sc_all))
213-
result.append('system.disk.all_write_b,{0}{1}'.format(Plugin.PATH, self.agent_query_write_sc_all))
214-
return template_zabbix.key_and_query(result)
202+
result = ['system.disk.discovery,{0}{1}'.format(Plugin.PATH, self.query_agent_discovery),
203+
'system.disk.utilization[*],{0}'.format(self.agent_query_ticks),
204+
'system.disk.read[*],{0}'.format(self.agent_query_read_op),
205+
'system.disk.write[*],{0}'.format(self.agent_query_write_op),
206+
'system.disk.read_b[*],{0}'.format(self.agent_query_read_sc),
207+
'system.disk.write_b[*],{0}'.format(self.agent_query_write_sc),
208+
'system.disk.all_read,{0}{1}'.format(Plugin.PATH, self.agent_query_read_op_all),
209+
'system.disk.all_write,{0}{1}'.format(Plugin.PATH, self.agent_query_write_op_all),
210+
'system.disk.all_read_b,{0}{1}'.format(Plugin.PATH, self.agent_query_read_sc_all),
211+
'system.disk.all_write_b,{0}{1}'.format(Plugin.PATH, self.agent_query_write_sc_all)]
212+
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/la.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ def graphs(self, template):
2323
return template.graph(graph)
2424

2525
def keys_and_queries(self, template_zabbix):
26-
result = []
27-
result.append('system.la.1,{0}'.format(self.query_agent))
26+
result = ['system.la.1,{0}'.format(self.query_agent)]
2827
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/memory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ def keys_and_queries(self, template_zabbix):
112112
for item in self.Items:
113113
if item[1] is None and item[0] == 'apps':
114114
result.append('{0},{1}'.format(self.key.format('.' + item[0]),
115-
self.query_agent_apps))
115+
self.query_agent_apps))
116116
elif item[1] is None and item[0] == 'swap':
117117
result.append('{0},{1}'.format(self.key.format('.' + item[0]),
118-
self.query_agent_swap))
118+
self.query_agent_swap))
119119
else:
120120
result.append('{0},{1}{2}'.format(self.key.format('.' + item[0]),
121-
self.query_agent.format(item[1]), "{ print $2*1024 }'"))
122-
return template_zabbix.key_and_query(result)
121+
self.query_agent.format(item[1]), "{ print $2*1024 }'"))
122+
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/net.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from mamonsu.plugins.system.plugin import SystemPlugin as Plugin
22

33

4-
5-
64
class Net(Plugin):
75
query_agent_discovery = "/net.sh -j NETDEVICE"
86
query_agent = "expr `grep -Ei '$1' /proc/net/dev | awk '{print $$"
@@ -78,11 +76,10 @@ def discovery_rules(self, template):
7876
'color': '0000CC',
7977
'key': 'system.net.tx_bytes[{#NETDEVICE}]'}]
8078
}]
81-
return template.discovery_rule(rule=rule,conditions=conditions, items=items, graphs=graphs)
79+
return template.discovery_rule(rule=rule, conditions=conditions, items=items, graphs=graphs)
8280

8381
def keys_and_queries(self, template_zabbix):
84-
result = []
85-
result.append('system.net.discovery,{0}{1}'.format(Plugin.PATH, self.query_agent_discovery))
82+
result = ['system.net.discovery,{0}{1}'.format(Plugin.PATH, self.query_agent_discovery)]
8683
for item in self.Items:
8784
result.append('{0}[*], {1}'.format(item[1], self.query_agent + str(item[0] + 2) + "}'`"))
8885
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/open_files.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ def graphs(self, template):
2424
return template.graph(graph)
2525

2626
def keys_and_queries(self, template_zabbix):
27-
result = []
28-
result.append('{0},{1}'.format("system.open_files", self.query_agent))
27+
result = ['{0},{1}'.format("system.open_files", self.query_agent)]
2928
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/proc_stat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def keys_and_queries(self, template_zabbix):
142142
keys = item[1].split('[')
143143
result.append(
144144
'{0},{1}'.format('{0}{1}.{2}'.format(self.key.format(""), keys[0], keys[1][:-1]),
145-
self.query_agent_procs[i]))
145+
self.query_agent_procs[i]))
146146
for i, item in enumerate(self.CpuItems):
147147
# split each item to get values for keys of both agent type and mamonsu type
148148
keys = item[1].split('[')
149149
result.append(
150150
'{0},{1}'.format('{0}{1}.{2}'.format(self.key.format(""), keys[0], keys[1][:-1]),
151-
self.query_agent_cpu + str(i + 2) + "}'`"))
151+
self.query_agent_cpu + str(i + 2) + "}'`"))
152152
return template_zabbix.key_and_query(result)

mamonsu/plugins/system/linux/uptime.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def run(self, zbx):
1515
def items(self, template):
1616
return template.item({
1717
'name': 'System up_time',
18-
'key': self.right_type(self.key),
18+
'key': self.right_type(self.key),
1919
'value_type': Plugin.VALUE_TYPE.numeric_unsigned,
2020
'delay': self.plugin_config('interval'),
2121
'units': Plugin.UNITS.uptime
@@ -31,10 +31,9 @@ def triggers(self, template):
3131
'name': 'System was restarted on '
3232
'{HOSTNAME} (up_time={ITEM.LASTVALUE})',
3333
'expression': '{#TEMPLATE:' + self.right_type(self.key) + '.last'
34-
'()}<' + self.plugin_config('up_time')
34+
'()}<' + self.plugin_config('up_time')
3535
})
3636

3737
def keys_and_queries(self, template_zabbix):
38-
result = []
39-
result.append('system.up_time,{0}'.format(self.query_agent))
40-
return template_zabbix.key_and_query(result)
38+
result = ['system.up_time,{0}'.format(self.query_agent)]
39+
return template_zabbix.key_and_query(result)

0 commit comments

Comments
 (0)