check_mk通用应用检测插件

客户端mk_tvmapp

import jsonfilename = '/tmp/tvmapp.json'print '<<<tvmapp>>>'
for a in json.load(open(filename)):print 'item_name %s' % a['item_name']print 'timestamp %s' % a['timestamp']print 'check_type %s' % a['check_type']if a['check_type'] == '0':print 'status %s' % a['status'] print 'message %s' % a['message']else:print 'unit %s' % a['unit']print 'current_value %s' % a['current_value']print 'threhold_value %s' % a['threhold_value']#output
<<<tvmapp>>>
item_name mtq_unique_visitor
timestamp 1499320801
check_type 0
status 1
message this is a status message - current status is 1
item_name mtq_page_view
timestamp 1499320801
check_type 1
unit %
current_value 92
threhold_value >90|<60

/tmp/tvmapp.json

[{"check_type": "0", "item_name": "mtq_unique_visitor", "message": "this is a status message - current status is 1", "status": "1", "timestamp": "1499320801"}, {"check_type": "1", "item_name": "mtq_page_view", "current_value": "92", "threhold_value": ">90|<60", "unit": "%", "timestamp": "1499320801"}
]

服务端tvmapp

import time, redef inventory_app(info):inventory = []for line in info:if line[0] == 'item_name':inventory.append((' '.join(line[1:]), None))return inventorydef parse_app(info):'''data:{'mtq_unique_visitor': { 'timestamp': '', 'check_type': '', 'status': '', 'message': '' },'mtq_page_view': { 'timestamp': '', 'check_type': '', 'unit': '', 'current_value': '', 'threhold_value': ''}}'''data = {}tmp = ''for line in info:if line[0] == 'item_name':tmp = ' '.join(line[1:])data[tmp] = {}else:data[tmp][line[0]] = ' '.join(line[1:])return datadef check_app(item, params, info):data = parse_app(info)if data[item] is None: return 2, 'The data is not exist.', [(item, 1)]elif int(time.time()) - int(data[item]['timestamp']) >= 300:return 2, 'The data is not update.', [(item, 1)]elif data[item]['check_type'] == '0':if data[item]['status'] == '0':return 0, data[item]['message'], [(item, 0)]else:return 2, data[item]['message'], [(item, 1)]elif data[item]['check_type'] == '1': exp = re.sub('([!<>]=?|=)', \lambda x: data[item]['current_value'] + '=' + x.group(0) if x.group(0) == '=' else data[item]['current_value'] + x.group(0), data[item]['threhold_value']) \.replace('|', ' or ').replace('&', ' and ')if eval(exp):return 0, 'threhold is %s, current value is %s%s' % (data[item]['threhold_value'], data[item]['current_value'], data[item]['unit']), [(item, int(data[item]['current_value']))]else:return 2, 'threhold is %s, current value is %s%s' % (data[item]['threhold_value'], data[item]['current_value'], data[item]['unit']), [(item, int(data[item]['current_value']))]check_info['tvmapp'] = {'inventory_function'  : inventory_app,'check_function'      : check_app,'has_perfdata'        : True,'service_description' : 'tvmapp %s',
}

posted on 2017-07-19 11:05 北京涛子 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/7204630.html

check_mk通用应用检测插件相关推荐

  1. 基于锚框与无需锚框的通用物体检测算法

    物体检测通常是指在图像中检测出物体出现的位置及对应的类别,是计算机视觉的根本问题,也是最基础的问题.它广泛应用于日常生活中,如浏览器的拍照识图.自动驾驶行人车辆检测.道路目标检测(人行道检测)及图像分 ...

  2. 通用目标检测的review

    今晚去蹭了超强师姐的讲座,以下是今晚的笔记. 目前存在的目标检测可以分为以下几类: One-short, few-short, weakly supervised object detection:这 ...

  3. 中科院张士峰:基于深度学习的通用物体检测算法对比探索

    https://www.toutiao.com/a6674792954369933838/ 人工智能论坛如今浩如烟海,有硬货.有干货的讲座却百里挑一.由中国科学院大学主办,中国科学院大学学生会承办,读 ...

  4. Vim之代码异步检测插件 ALE -- 实时检查verilog等代码的正确性

    Vim之代码异步检测插件 ALE 前言 知名的 vim 代码检测插件主要是两个 syntastic neomake ALE ALE 虽是后起之秀,但目前是功能最强大的一个 实时检测.为了让代码可以在编 ...

  5. 【Android 插件化】VAHunt 检测插件化引擎的具体细节

    文章目录 一.VAHunt 检测插件引擎具体细节 一.VAHunt 检测插件引擎具体细节 上图的执行顺序是 ⑤ -> ④ -> ③ -> ② -> ① ; 存在 222 个 I ...

  6. Sublime Text编辑工具带有 PEP 8 格式检测插件

    Sublime Text编辑工具带有 PEP 8 格式检测插件 转载于:https://www.cnblogs.com/dsdr/p/6045905.html

  7. 大小仅1MB,超轻量级通用人脸检测模型登上GitHub趋势榜

    机器之心报道 项目作者:Linzaer 近日,用户 Linzaer 在 Github 上推出了一款适用于边缘计算设备.移动端设备以及 PC 的超轻量级通用人脸检测模型,该模型文件大小仅 1MB,320 ...

  8. ale插件 vim_Vim之代码异步检测插件 ALE -- 实时检查verilog等代码的正确性

    Vim之代码异步检测插件 ALE 前言 知名的 vim 代码检测插件主要是两个 syntastic neomake ALE ALE 虽是后起之秀,但目前是功能最强大的一个 实时检测.为了让代码可以在编 ...

  9. 悬剑武器库之5种工具学习(shiro检测插件、子域名、信息收集、暴力破解等)

    工具目录 1.BurpShiroPassiveScan是一款基于BurpSuite的被动式shiro检测插件2.reconftw是对具有多个子域的目标执行全面检查的脚本3.CTFR是一款不适用字典攻击 ...

最新文章

  1. Java拾遗:001 - 重写 equals 和 hashCode 方法
  2. python的类写法_Python3 类静态数据的写法
  3. C#执行cmd [转载]
  4. Hive的安装-Hive的交互方式
  5. 使用网真和WAD热部署Kubernetes
  6. jQuery 实现Ajax
  7. linux验证cuda安装成功_linux # centos # 安装cuda
  8. CSS-fishc学习笔记
  9. 亿图图示11.0新版本全新上线 助力个人及企业降本增效
  10. python车辆型号识别_基于Tensorflow的车辆检测和车型识别
  11. 英特尔服务器主板g41性能,英特尔g41显卡好用吗 英特尔g41显卡评测【详解】
  12. win10 右键菜单管理
  13. 笔试题——团队活动分组
  14. html新浪短域名api,新浪短网址官方api接口
  15. c# mailgun 发送邮件测试
  16. 实现人rou搜索的10个经典方法
  17. 面向对象程序有哪些优点呢?
  18. 研华工控机linux改win7,嵌入式工控机研华工控机用u盘装系统如何设置bios?在虚拟机中的Linux系统中咋挂u盘 我的虚拟机上都没有USB 显示5...
  19. Fitbit被谷歌21亿美元收购 品牌启用英文域名Fitbit.com
  20. 关于IO流和String常见的一些面试题

热门文章

  1. IOS-资源最小化之点九图片的使用
  2. ubuntu上建立mini2440 qt编译环境
  3. button,submit, image的区别 点onclick后隐藏行
  4. 《LeetCode力扣练习》第6题 C语言版 (做出来就行,别问我效率。。。。)
  5. 加州伯克利计算机专业录取条件,2020加州大学伯克利分校的计算机专业条件是什么?...
  6. animate用法 js原生_用 原生Javascript 创建带动画的固顶导航菜单
  7. golang中base64编码_Go语言教程:Base64编码
  8. thinkcmf 去掉index.php,​ThinkCMF5.0如何修改入口文件 解决方法
  9. php 下载脱离服务器,php – 强制从外部服务器下载并重命名
  10. 阿拉德之怒显示服务器错误,阿拉德之怒网络异常怎么办 安装失败怎么办