check.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:icinga2checks 作者: c-store 项目源码 文件源码
def check_network(i_warning, i_critical):
    test_int(i_warning, i_critical)

    s_perfdata    = ''
    s_output      = ''
    i_max         = 0
    s_maxdesc     = ''
    d_io_counters = psutil.net_io_counters(pernic=True)

    for s_device, nt_counters in d_io_counters.items():
        d_counters = nt_counters._asdict()
        # add all io_counters to perfdata
        for key, value in d_counters.items():
            if 'err' in key or 'drop' in key:
                if value > i_max: 
                    i_max = value
                    s_maxdesc = '{} has {} {} packets.'.format(s_device, value, key)
            s_perfdata = add_perfdata(s_perfdata, s_device, key, value)

    s_output = check_status(i_warning, i_critical, i_max)

    if not 'OK' in s_output: s_output += s_maxdesc

    s_output += ' | {}'.format(s_perfdata)

    return s_output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号