Comments (12)
If use decode
method to convert bytes to string it might help:
data_len = struct.pack('<Q', len(request))
packet = 'ZBXD\x01' + data_len.decode() + request
Need to verify on 2 and 3 version of python
from py-zabbix.
PR updated: #15
from py-zabbix.
Decode was not applied yet. But I will test it soon
from py-zabbix.
@blacked your advice works on python 2 and 3 but I got this new error:
File "/usr/local/lib/python3.4/dist-packages/zabbix/sender.py", line 225, in send
packet = self.__create_packet(request)
File "/usr/local/lib/python3.4/dist-packages/zabbix/sender.py", line 175, in __create_packet
':'.join(x.encode('hex') for x in packet))
File "/usr/local/lib/python3.4/dist-packages/zabbix/sender.py", line 175, in
':'.join(x.encode('hex') for x in packet))
LookupError: 'hex' is not a text encoding; use codecs.encode() to handle arbitrary codecs
from py-zabbix.
What is objective of this code?
logger.debug('%s.__create_packet (hex): %s', self.cn,
':'.join(x.encode('hex') for x in packet))
from py-zabbix.
This is just output debug info about packet in HEX.
I think binascii
will help add python2\3 compatibility:
import binascii
logger.debug('%s.__create_packet (hex): %s', self.cn,
':'.join(binascii.hexlify(x.encode()) for x in packet))
from py-zabbix.
Python3 don't works :(
TypeError: sequence item 0: expected str instance, bytes found
I tried put:
':'.join(binascii.hexlify(x) for x in packet))
But I got this error:
TypeError: 'str' does not support the buffer interface
I am confuse :(
from py-zabbix.
I fixed! :)
Please take a look: #15
from py-zabbix.
@gomex i updated version in pip, now it's 0.6.0
:
pip install --upgrade py-zabbix
from py-zabbix.
This actually broke the functionality on Python 2.7.10 (Mac OS X).
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/zabbix/sender.py", line 177, in __create_packet
packet = 'ZBXD\x01' + data_len.decode() + request
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd9 in position 0: ordinal not in range(128)
I haven't tested other architectures.
from py-zabbix.
@danielbenzvi can you try with?
packet = 'ZBXD\x01' + data_len.decode('utf-8') + request
Actually I tested on 2.7.9, and it works. Also what metric you try to send?
from py-zabbix.
fixed #17
from py-zabbix.
Related Issues (20)
- any easy way to enable debug of zabbix sender? HOT 1
- TLS PSK usage with ZabbixSender HOT 5
- Zabbix Sender add old data
- UserParameters in config HOT 2
- Why always recieve {"failed": 1, "chunk": 1, "total": 1, "processed": 0, "time": "0.000045"},Pls help on this HOT 2
- Cert-based TLS support
- Release 1.1.5 and git regression HOT 1
- Include ignored on zabbix_agentd.conf when using use_config
- Namespace conflict HOT 4
- not possible to insert via zabbix send HOT 1
- Stub File
- "'bool' object has no attribute 'get'" error occurs in ZabbixSender.send() function HOT 2
- Create Stub File for Type Annotation
- Exclude auth from "user.checkauthentication" method
- support to new auth token HOT 8
- Feature request: Request timeout
- py-zabbix and pyzabbix conflict
- Feature request: Support for nanosecond part when using trapper HOT 1
- Zabbix 6.0 support
- support zabbix 6.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-zabbix.