def check_cmk_config(report, conf_dir):
check_conf = report.add_check("configDirectory")
# Verify we can read the config directory
try:
c = config.Config(conf_dir)
except Exception:
check_conf.add_error("Unable to read the CMK configuration directory")
return # Nothing more we can check for now
# Ensure pool cpu lists are disjoint
with c.lock():
cpu_lists = [
{
"pool": p,
"list": cl,
"cpus": proc.unfold_cpu_list(cl)
}
for p in c.pools()
for cl in c.pool(p).cpu_lists()
]
# Subset of cartesian product without self-maplets:
# If a -> b is in the result then b -> a is not.
# Search the filtered product for overlapping CPU lists.
def same_list(a, b):
return a["pool"] is b["pool"] and a["list"] is b["list"]
def disjoint(a, b):
return not set(a["cpus"]).intersection(set(b["cpus"]))
for (a, b) in itertools.combinations_with_replacement(cpu_lists, 2):
if not same_list(a, b) and not disjoint(a, b):
check_conf.add_error(
"CPU list overlap detected in "
"{}:{} and {}:{} (in both: {})".format(
a["pool"], a["list"],
b["pool"], b["list"],
b["cpus"]))
nodereport.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录