本文整理汇总了Python中utils.dockerutil.DockerUtil._drop方法的典型用法代码示例。如果您正苦于以下问题:Python DockerUtil._drop方法的具体用法?Python DockerUtil._drop怎么用?Python DockerUtil._drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.dockerutil.DockerUtil
的用法示例。
在下文中一共展示了DockerUtil._drop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_healthcheck
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import _drop [as 别名]
def test_healthcheck(self):
config = {
"init_config": {},
"instances": [{
"url": "unix://var/run/docker.sock",
"health_service_check_whitelist": ["docker_image:nginx", "docker_image:redis"],
},
],
}
DockerUtil().set_docker_settings(config['init_config'], config['instances'][0])
self.run_check(config, force_reload=True)
self.assertServiceCheck('docker.container_health', count=2)
config = {
"init_config": {},
"instances": [{
"url": "unix://var/run/docker.sock",
"health_service_check_whitelist": [],
},
],
}
DockerUtil._drop()
DockerUtil(init_config=config['init_config'], instance=config['instances'][0])
self.run_check(config, force_reload=True)
self.assertServiceCheck('docker.container_health', count=0)
示例2: test_include_filter
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import _drop [as 别名]
def test_include_filter(self):
expected_metrics = [
('docker.containers.running', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.containers.running', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.containers.stopped', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.containers.stopped', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.cpu.system', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.cpu.user', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.image.size', ['image_name:redis', 'image_tag:latest']),
('docker.image.size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:redis', 'image_tag:latest']),
('docker.images.available', None),
('docker.images.intermediate', None),
('docker.io.read_bytes', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.io.write_bytes', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.mem.cache', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.mem.rss', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.net.bytes_rcvd', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.net.bytes_sent', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest'])
]
config = {
"init_config": {},
"instances": [{
"url": "unix://var/run/docker.sock",
"include": ["image_name:redis"],
"exclude": [".*"],
"collect_images_stats": True,
"collect_image_size": True,
},
],
}
DockerUtil._drop()
DockerUtil(init_config=config['init_config'], instance=config['instances'][0])
self.run_check_twice(config, force_reload=True)
for mname, tags in expected_metrics:
self.assertMetric(mname, tags=tags, count=1, at_least=1)
perf_metrics = [
"docker.cpu.system",
"docker.cpu.user",
"docker.io.read_bytes",
"docker.io.write_bytes",
"docker.mem.cache",
"docker.mem.rss",
"docker.net.bytes_rcvd",
"docker.net.bytes_sent"
]
nginx_tags = ['container_name:test-new-nginx-latest', 'docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']
for m in perf_metrics:
self.assertMetric(mname, tags=nginx_tags, count=0)
示例3: test_histogram
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import _drop [as 别名]
def test_histogram(self):
metric_suffix = ["count", "avg", "median", "max", "95percentile"]
expected_metrics = [
('docker.containers.running', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.containers.running', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.containers.stopped', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.containers.stopped', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.image.size', ['image_name:redis', 'image_tag:latest']),
('docker.image.size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:redis', 'image_tag:latest']),
('docker.images.available', None),
('docker.images.intermediate', None),
]
histo_metrics = [
('docker.mem.cache', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.mem.cache', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.mem.rss', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.mem.rss', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.mem.limit', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
('docker.mem.in_use', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest']),
]
config = {
"init_config": {},
"instances": [{
"url": "unix://var/run/docker.sock",
"collect_image_size": True,
"collect_images_stats": True,
"use_histogram": True,
},
],
}
DockerUtil._drop()
DockerUtil(init_config=config['init_config'], instance=config['instances'][0])
self.run_check(config, force_reload=True)
for mname, tags in expected_metrics:
self.assertMetric(mname, tags=tags, count=1, at_least=1)
for mname, tags in histo_metrics:
for suffix in metric_suffix:
self.assertMetric(mname + "." + suffix, tags=tags, at_least=1)
示例4: test_tags_options
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import _drop [as 别名]
def test_tags_options(self):
expected_metrics = [
('docker.containers.running', ["container_command:nginx -g 'daemon off;'"]),
('docker.containers.running', ['container_command:docker-entrypoint.sh redis-server']),
('docker.containers.stopped', ["container_command:nginx -g 'daemon off;'"]),
('docker.containers.stopped', ['container_command:docker-entrypoint.sh redis-server']),
('docker.cpu.system', ["container_command:nginx -g 'daemon off;'"]),
('docker.cpu.system', ['container_command:docker-entrypoint.sh redis-server']),
('docker.cpu.user', ['container_command:docker-entrypoint.sh redis-server']),
('docker.cpu.user', ["container_command:nginx -g 'daemon off;'"]),
('docker.image.size', ['image_name:redis', 'image_tag:latest']),
('docker.image.size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:redis', 'image_tag:latest']),
('docker.images.available', None),
('docker.images.intermediate', None),
('docker.io.read_bytes', ["container_command:nginx -g 'daemon off;'"]),
('docker.io.read_bytes', ['container_command:docker-entrypoint.sh redis-server']),
('docker.io.write_bytes', ['container_command:docker-entrypoint.sh redis-server']),
('docker.io.write_bytes', ["container_command:nginx -g 'daemon off;'"]),
('docker.mem.cache', ["container_command:nginx -g 'daemon off;'"]),
('docker.mem.cache', ['container_command:docker-entrypoint.sh redis-server']),
('docker.mem.rss', ['container_command:docker-entrypoint.sh redis-server']),
('docker.mem.rss', ["container_command:nginx -g 'daemon off;'"]),
('docker.net.bytes_rcvd', ['container_command:docker-entrypoint.sh redis-server']),
('docker.net.bytes_rcvd', ["container_command:nginx -g 'daemon off;'"]),
('docker.net.bytes_sent', ["container_command:nginx -g 'daemon off;'"]),
('docker.net.bytes_sent', ['container_command:docker-entrypoint.sh redis-server'])
]
config = {
"init_config": {},
"instances": [{
"url": "unix://var/run/docker.sock",
"performance_tags": ["container_command"],
"container_tags": ["container_command"],
"collect_images_stats": True,
"collect_image_size": True,
},
],
}
DockerUtil._drop()
DockerUtil(init_config=config['init_config'], instance=config['instances'][0])
self.run_check_twice(config, force_reload=True)
for mname, tags in expected_metrics:
self.assertMetric(mname, tags=tags, count=1, at_least=1)
示例5: test_docker_are_tags_filtered
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import _drop [as 别名]
def test_docker_are_tags_filtered(self):
with mock.patch.object(DockerUtil, 'is_k8s', side_effect=lambda: True):
DockerUtil._drop()
du = DockerUtil()
self.assertTrue(du.is_k8s())
pause_containers = [
"docker_image:gcr.io/google_containers/pause-amd64:0.3.0",
"docker_image:asia.gcr.io/google_containers/pause-amd64:3.0",
"docker_image:k8s.gcr.io/pause-amd64:latest",
"image_name:openshift/origin-pod",
"image_name:kubernetes/pause",
]
for image in pause_containers:
self.assertTrue(du.are_tags_filtered([image]))
self.assertTrue(pause_containers)
self.assertFalse(du.are_tags_filtered(["docker_image:quay.io/coreos/etcd:latest"]))
self.assertFalse(du.are_tags_filtered(["image_name:redis"]))
示例6: test_labels_collection
# 需要导入模块: from utils.dockerutil import DockerUtil [as 别名]
# 或者: from utils.dockerutil.DockerUtil import _drop [as 别名]
def test_labels_collection(self):
expected_metrics = [
('docker.containers.running', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest', 'label1:nginx']),
('docker.containers.running', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.containers.stopped', ['docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.containers.stopped', ['docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest', 'label1:nginx']),
('docker.image.size', ['image_name:redis', 'image_tag:latest']),
('docker.image.size', ['image_name:nginx', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:redis', 'image_tag:latest']),
('docker.image.virtual_size', ['image_name:nginx', 'image_tag:latest']),
('docker.images.available', None),
('docker.images.intermediate', None),
('docker.mem.cache', ['container_name:test-new-nginx-latest', 'docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest', 'label1:nginx']),
('docker.mem.cache', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.mem.rss', ['container_name:test-new-nginx-latest', 'docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest', 'label1:nginx']),
('docker.mem.rss', ['container_name:test-new-redis-latest', 'docker_image:redis:latest', 'image_name:redis', 'image_tag:latest']),
('docker.mem.limit', ['container_name:test-new-nginx-latest', 'docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest', 'label1:nginx']),
('docker.mem.in_use', ['container_name:test-new-nginx-latest', 'docker_image:nginx:latest', 'image_name:nginx', 'image_tag:latest', 'label1:nginx']),
]
config = {
"init_config": {},
"instances": [{
"url": "unix://var/run/docker.sock",
"collect_labels_as_tags": ["label1"],
"collect_image_size": True,
"collect_images_stats": True,
"collect_container_count": True,
"collect_dead_container_count": True,
"collect_exited_container_count": True,
"collect_volume_count": True,
"collect_dangling_volume_count": True,
},
],
}
DockerUtil._drop()
DockerUtil(init_config=config['init_config'], instance=config['instances'][0])
self.run_check(config, force_reload=True)
for mname, tags in expected_metrics:
self.assertMetric(mname, tags=tags, count=1, at_least=1)