本文整理汇总了Python中diamond.handler.tsdb.TSDBHandler.process方法的典型用法代码示例。如果您正苦于以下问题:Python TSDBHandler.process方法的具体用法?Python TSDBHandler.process怎么用?Python TSDBHandler.process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diamond.handler.tsdb.TSDBHandler
的用法示例。
在下文中一共展示了TSDBHandler.process方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_single_metric
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_single_metric(self, mock_urlopen, mock_request):
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
metric = Metric('servers.myhostname.cpu.cpu_count',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "cpu.cpu_count", "value": '
'123, "tags": {"hostname": "myhostname"}}]')
header = {'Content-Type': 'application/json'}
mock_urlopen.assert_called_with(self.url, body, header)
示例2: test_HTTPError
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_HTTPError(self, mock_urlopen, mock_request):
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
metric = Metric('servers.myhostname.cpu.cpu_count',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
header = {'Content-Type': 'application/json'}
exception = urllib2.HTTPError(url=self.url, code=404, msg="Error",
hdrs=header, fp=None)
handler.side_effect = exception
handler.process(metric)
示例3: test_user_password
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_user_password(self, mock_urlopen, mock_request):
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['user'] = 'John Doe'
config['password'] = '123456789'
metric = Metric('servers.myhostname.cpu.cpu_count',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "cpu.cpu_count", "value": '
'123, "tags": {"hostname": "myhostname"}}]')
header = {'Content-Type': 'application/json',
'Authorization': 'Basic Sm9obiBEb2U6MTIzNDU2Nzg5'}
mock_urlopen.assert_called_with(self.url, body, header)
示例4: test_cpu_metrics_taghandling_default2
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_cpu_metrics_taghandling_default2(self, mock_urlopen, mock_request):
"""
aggregate default
"""
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['tags'] = ['myFirstTag=myValue']
metric = Metric('servers.myhostname.cpu.total.user',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
assert not mock_urlopen.called, "should not process"
示例5: test_compression
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_compression(self, mock_urlopen, mock_request):
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['compression'] = 1
metric = Metric('servers.myhostname.cpu.cpu_count',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "cpu.cpu_count", "value": '
'123, "tags": {"hostname": "myhostname"}}]')
passed_headers = mock_urlopen.call_args[0][2]
passed_body = mock_urlopen.call_args[0][1]
assert passed_headers['Content-Encoding'] == 'gzip'
assert passed_headers['Content-Type'] == 'application/json'
assert self.decompress(passed_body) == body
示例6: test_cpu_metrics_taghandling_default
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_cpu_metrics_taghandling_default(self, mock_urlopen, mock_request):
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['tags'] = ['myFirstTag=myValue']
metric = Metric('servers.myhostname.cpu.cpu0.user',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "cpu.user", "value": '
'123, "tags": {"cpuId": "cpu0", "myFirstTag": "myValue", '
'"hostname": "myhostname"}}]')
header = {'Content-Type': 'application/json'}
mock_urlopen.assert_called_with(self.url, body, header)
示例7: test_network_metrics_default
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_network_metrics_default(self, mock_urlopen, mock_request):
"""
taghandling default
"""
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['tags'] = ['myFirstTag=myValue']
metric = Metric('servers.myhostname.network.IF.rx_packets',
80, raw_value=80, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "network.rx_packets", '
'"value": 80, "tags": {"interface": "IF", "myFirstTag": '
'"myValue", "hostname": "myhostname"}}]')
header = {'Content-Type': 'application/json'}
mock_urlopen.assert_called_with(self.url, body, header)
示例8: test_iostat_metrics
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_iostat_metrics(self, mock_urlopen, mock_request):
"""
taghandling deactivate
"""
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['tags'] = ['myFirstTag=myValue']
config['cleanMetrics'] = False
metric = Metric('servers.myhostname.iostat.DEV.io_in_progress',
80, raw_value=80, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "iostat.DEV.io_in_progress"'
', "value": 80, "tags": {"myFirstTag": "myValue", "hostname": '
'"myhostname"}}]')
header = {'Content-Type': 'application/json'}
mock_urlopen.assert_called_with(self.url, body, header)
示例9: test_diskspace_metrics_default
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_diskspace_metrics_default(self, mock_urlopen, mock_request):
"""
taghandling default
"""
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['tags'] = ['myFirstTag=myValue']
metric = Metric('servers.myhostname.diskspace.MOUNT_POINT.byte_percent'
'free',
80, raw_value=80, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "diskspace.'
'byte_percentfree", "value": 80, "tags": {"mountpoint": '
'"MOUNT_POINT", "myFirstTag": "myValue", "hostname": '
'"myhostname"}}]')
header = {'Content-Type': 'application/json'}
mock_urlopen.assert_called_with(self.url, body, header)
示例10: test_haproxy_metrics
# 需要导入模块: from diamond.handler.tsdb import TSDBHandler [as 别名]
# 或者: from diamond.handler.tsdb.TSDBHandler import process [as 别名]
def test_haproxy_metrics(self, mock_urlopen, mock_request):
"""
taghandling deactivate
"""
config = configobj.ConfigObj()
config['host'] = '127.0.0.1'
config['port'] = '4242'
config['tags'] = ['myFirstTag=myValue']
config['cleanMetrics'] = False
metric = Metric('servers.myhostname.haproxy.SOME-BACKEND.SOME-SERVER.'
'bin',
123, raw_value=123, timestamp=1234567,
host='myhostname', metric_type='GAUGE')
handler = TSDBHandler(config)
handler.process(metric)
body = ('[{"timestamp": 1234567, "metric": "haproxy.SOME-BACKEND.SOME-'
'SERVER.bin", "value": 123, "tags": {"myFirstTag": "myValue", '
'"hostname": "myhostname"}}]')
header = {'Content-Type': 'application/json'}
mock_urlopen.assert_called_with(self.url, body, header)