1

我正在设置一个使用 python 编写的脚本的监控系统。(仅供参考其带有 check_mk 的 OMD linux 发行版)。

无论如何,这是我要使用的脚本

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# WARN num, CRIT num
eximq_default_levels = (100, 200) 

def inventory_eximq(info):
if len(info) > 0 and info[0] != '':
    return [(None, 'eximq_default_levels')]

def check_eximq(item, params, info):
for line in info:
    if line[0] == '0':
        return (0, 'OK - The mailqueue is empty ', [ ('length', 0, params[0], params[1]),
                                                     ('size', '0') ])
    else:
        len     = int(line[0])

        perfdata = [ ('length', len, params[0], params[1])]

        if len > params[1]:
            return (2, 'CRIT - Mailqueue length is %d '
                       '(More than threshold: %d)' % (len, params[0]), perfdata)
        elif len > params[0]:
            return (1, 'WARN - Mailqueue length is %d '
                       '(More than threshold: %d)' % (len, params[0]), perfdata)
        else:
            return (0, 'OK - Mailqueue length is %d ' % len, perfdata)

return (3, 'UNKNOWN - Could not find summarizing line in output')

check_info['eximq'] = (check_eximq, "Exim Queue", 1, inventory_eximq)
checkgroup_of["eximq"] = "mailqueue_length"

当我从此脚本编译/创建包时,出现以下错误

插件文件 /omd/sites/infonet/local/share/check_mk/checks/eximq-1.0.mkp 中的错误:文件 /omd/sites/infonet/local/share/check_mk/checks 中的非 >ASCII 字符“\x8b” /eximq-1.0.mkp > 在第 1 行,但未声明编码;请参阅http://www.python.org/peps/pep-0263.html了解 >详情(eximq-1.0.mkp,第 1 行)

我尝试将编码更改为编码,完全删除它,在 #!/usr/bin/python 之前添加它,但没有任何帮助。我还通过 vi 使用选项检查了文件以显示所有字符,但在这些位置我没有发现任何奇怪的字符。

操作系统是 Centos,python 是 2.6

还有什么我可以尝试解决这个问题的吗?

ps 如果它有任何相关性,这是从脚本 https://mathias-kettner.de/checkmk_packaging.html创建包的指南

4

0 回答 0