本文整理汇总了Python中pyzabbix.ZabbixSender._create_request方法的典型用法代码示例。如果您正苦于以下问题:Python ZabbixSender._create_request方法的具体用法?Python ZabbixSender._create_request怎么用?Python ZabbixSender._create_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyzabbix.ZabbixSender
的用法示例。
在下文中一共展示了ZabbixSender._create_request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_request_failed
# 需要导入模块: from pyzabbix import ZabbixSender [as 别名]
# 或者: from pyzabbix.ZabbixSender import _create_request [as 别名]
def test_create_request_failed(self):
message = [
'{"clock": "1457445366", "host: \
"host1", "value": "1", "key": "key1"}',
'{"clock": "1457445366", "host": \
"host2", "value": "2", "key": "key2"}']
zs = ZabbixSender()
result = zs._create_request(message)
with self.assertRaises(Exception):
result = json.loads(result.decode())
示例2: test_create_request
# 需要导入模块: from pyzabbix import ZabbixSender [as 别名]
# 或者: from pyzabbix.ZabbixSender import _create_request [as 别名]
def test_create_request(self):
message = [
'{"clock": "1457445366", "host": "host1",\
"value": "1", "key": "key1"}',
'{"clock": "1457445366", "host": "host2",\
"value": "2", "key": "key2"}']
zs = ZabbixSender()
result = zs._create_request(message)
self.assertIsInstance(result, bytes)
result = json.loads(result.decode())
self.assertEqual(result['request'], 'sender data')
self.assertEqual(len(result['data']), 2)
示例3: test_create_packet
# 需要导入模块: from pyzabbix import ZabbixSender [as 别名]
# 或者: from pyzabbix.ZabbixSender import _create_request [as 别名]
def test_create_packet(self):
message = [
'{"clock": "1457445366", "host": "host1",\
"value": "1", "key": "key1"}',
'{"clock": "1457445366", "host": "host2",\
"value": "2", "key": "key2"}']
zs = ZabbixSender()
request = zs._create_request(message)
result = zs._create_packet(request)
data_len = struct.pack('<Q', len(request))
self.assertEqual(result[5:13], data_len)
self.assertEqual(result[:13],
b'ZBXD\x01\xc4\x00\x00\x00\x00\x00\x00\x00')