Skip to content

Commit

Permalink
just pass the value - do not try to encode/decode them
Browse files Browse the repository at this point in the history
  • Loading branch information
vrdel committed Feb 6, 2020
1 parent 52b61ca commit 3ef17ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pymod/metrictoqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def build_msg(args, *headers):

timestamp, service, hostname, metric, status, nagioshost = headers

msg.header.update({'timestamp': timestamp.encode('utf-8')})
msg.header.update({'service': service.encode('utf-8')})
msg.header.update({'hostname': hostname.encode('utf-8')})
msg.header.update({'metric': metric.encode('utf-8')})
msg.header.update({'status': status.encode('utf-8')})
msg.header.update({'monitoring_host': nagioshost.encode('utf-8')})
msg.header.update({'timestamp': timestamp})
msg.header.update({'service': service})
msg.header.update({'hostname': hostname})
msg.header.update({'metric': metric})
msg.header.update({'status': status})
msg.header.update({'monitoring_host': nagioshost})

for bs in ['summary', 'message', 'vofqan', 'voname', 'roc', 'actual_data', 'site']:
code = "msg.body += '%s: ' + args.%s.encode(\'utf-8\') + '\\n' if args.%s else ''" % (bs, bs, bs)
code = "msg.body += '%s: ' + args.%s + '\\n' if args.%s else ''" % (bs, bs, bs)
exec code

msg.text = True
Expand Down
2 changes: 1 addition & 1 deletion pymod/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _extract_body(self, body, fields, maps=None):
if maps and key in maps:
key = maps[key]

msg[key] = value.decode('utf-8', 'replace')
msg[key] = value

return msg

Expand Down

0 comments on commit 3ef17ac

Please sign in to comment.