Open gomex opened 9 years ago
At the moment I'm testing a replacement py-zabbix on a simple function which will send the metrics package to the server. Maybe it will speed up the processing. In addition, this method allows to avoid unnecessary dependence on external package and works on Python 2 and Python 3. Here is a draft of the function:
packet = [
{'host': Name,
'key': 'user.docker[cpu_used_percent]',
'value': round(CPUPercent, 2)},
{'host': Name,
'key': 'user.docker[memory_used_percent]',
'value': PercentMemoryUsed},
{'host': Name,
'key': 'user.docker[bytes_received]',
'value': stats['network']['rx_bytes']},
{'host': Name,
'key': 'user.docker[bytes_sent]',
'value': stats['network']['tx_bytes']},
{'host': Name,
'key': 'user.docker[packets_received]',
'value': stats['network']['rx_packets']},
{'host': Name,
'key': 'user.docker[packets sent]',
'value': stats['network']['tx_packets']},
{'host': Name,
'key': 'user.docker[packets_received_dropped]',
'value': stats['network']['rx_dropped']},
{'host': Name,
'key': 'user.docker[packets_sent_dropped]',
'value': stats['network']['tx_dropped']},
{'host': Name,
'key': 'user.docker[packets_received_erros]',
'value': stats['network']['rx_errors']},
{'host': Name,
'key': 'user.docker[packets_sent_erros]',
'value': stats['network']['tx_errors']}
]
data = {}
data['request'] = 'sender data'
data['data'] = packet
import json
import socket
jdata = json.dumps(data)
jdata = jdata.encode('utf-8')
s = socket.socket()
s.connect(('95.31.15.45', 10051))
s.send(jdata)
s.close()
Great job! There is good one thing that this library does that your code don't do it yet: Get IP Address of zabbix server from zabbix_agent conf, but I think it is simple or we can pass this information using parameter.
What you think about it?
The check spend almost 12 seconds to get all information. We need to improve it.