Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
*.egg-info
*.swp
__pycache__

tags
Expand Down
7 changes: 7 additions & 0 deletions mamonsu/lib/zbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import struct
import socket
import json
import logging

import mamonsu.lib.platform as platform
from mamonsu.lib.plugin import Plugin
Expand All @@ -25,6 +26,8 @@ def __init__(self, config):
self.max_queue_size = config.fetch('sender', 'queue', int)
self.fqdn = config.fetch('zabbix', 'client')
self.queue = Queue()
self.log = logging.getLogger(
'ZBX-{0}:{1}'.format(self.host, self.port))

def json(self, val):
return json.dumps(val)
Expand Down Expand Up @@ -75,6 +78,10 @@ def _send_data(self, data):
resp_body_len = struct.unpack('<Q', resp_header[5:])[0]
resp_body = self._receive(sock, resp_body_len)
self.log.debug('response: {0}'.format(resp_body))
if 'failed: 0' not in str(resp_body):
self.log.error(
'Response from server'
' with failed items: {0}'.format(resp_body))
finally:
sock.close()

Expand Down