check_mk通用应用检测插件
客户端mk_tvmapp
import json
filename = '/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, re
def inventory_app(info):
inventory = []
for line in info:
if line[0] == 'item_name':
inventory.append((' '.join(line[1:]), None))
return inventory
def 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 data
def 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',
}
check_mk通用应用检测插件的更多相关文章
- check_mk检测插件编写
参考 Writing Checks (Introduction) Writing agent based checks The New Check API http://www2.steinkogle ...
- Sublime Text编辑工具带有 PEP 8 格式检测插件
Sublime Text编辑工具带有 PEP 8 格式检测插件
- 浏览器特性检测插件Feature.js
<script src="js/feature.js"></script> if (feature.webGL) { console.log("你 ...
- Java代码规范与质量检测插件SonarLint
1. SonarLint SonarLint是一个代码质量检测插件,可以帮助我们检测出代码中的坏味道 下载与安装 在需要检测的单个文件或者单个项目上右键 --> Analyze --> ...
- 《阿里巴巴 Java 开发规约》自动化检测插件安装及体验
2017 开春之际,有助于提高行业编码规范化水平的<阿里巴巴 Java 开发手册>首次面世.汇聚阿里集团近万名技术精英的经验知识,这套高含金量的手册一经公开,便引起业界普遍关注和学习. 历 ...
- FCOS论文复现:通用物体检测算法
摘要:本案例代码是FCOS论文复现的体验案例,此模型为FCOS论文中所提出算法在ModelArts + PyTorch框架下的实现.本代码支持FCOS + ResNet-101在MS-COCO数据集上 ...
- check_mk检测插件 - raid监控
mk_raidstatus python版本 #!/usr/bin/env python # -*- encoding: utf-8; py-indent-offset: 4 -*- import s ...
- spring-boot | 整合通用Mabatis 分页插件PageHelper
Mybatis通用Mapper介绍 Mybatis 通用 Mapper 极其方便的使用 Mybatis 单表的增删改查,支持单表操作,不支持通用的多表联合查询 优点: 通用 Mapper 可以极大的方 ...
- laravel administrator 一款通用的后台插件(PHP框架扩展)
前几天我看了一下zend framework 2的一些官方文档,也找了一些例子,可惜所有的资料少之甚少.于是我就开始去找这国外用的比较流行的PHP框架laravel,希望能够找到其合适的例子,而且我本 ...
随机推荐
- P3243 [HNOI2015]菜肴制作
传送门 把时间看成数,菜肴看成位置 考虑一个位置填什么数很麻烦 考虑一个数放在什么位置 一开始我想的是,对于一个限制 $(a,b)$ ,从 $a$ 往 $b$ 连一条边,然后如果有解则所有的限制构成了 ...
- 109th LeetCode Weekly Contest Number of Recent Calls
Write a class RecentCounter to count recent requests. It has only one method: ping(int t), where t r ...
- Python入门(1)
1.编程语言 机器语言:直接用计算机能听懂的二进制指令去编写程序,需要了解硬件的细节 汇编语言:用英文标签取代二进制指令去编写程序,同样需要了解硬件的细节 高级语言:直接用人类能理解的表达方式去编写程 ...
- Linux kvm虚拟机的基本操作命令
Linux 虚拟化kvm virsh常用命令篇 1.创建虚拟机 virsh define damo.xml //创建的虚拟机不是活动的 virsh create damo.xml //创建的虚拟机是活 ...
- PIE SDK栅格拉伸控制
1. 功能简介 在我们的实际应用中,对于一般16bit或者更大比特深度的影像,像元值都是大于255的.这种情况下,RGB的显示器是不能够直接使用像元值进行显示的,需要将像元值换算到0~255的区间内以 ...
- 采用MQTT协议实现android消息推送(4)选fusesource-mqtt-client为客户端
1.简介 一个java写的mqtt客户端.项目地址: https://github.com/fusesource/mqtt-client 2.引入fusesource-mqtt-client库 Fil ...
- oracle 查看一个表中的记录是否被锁住
SELECT a.object_id, a.session_id, b.object_nameFROM v$locked_object a, dba_objects bWHERE a.object_i ...
- springboot项目中引用其他springboot项目jar
1. 剔除要引入的springboot项目中不需要的文件:如Application和ApplicationTests等 2.打包 不能使用springboot项目自带的打包插件进行打包: 3.打包 4 ...
- innosetup卸载软件后,删除定时任务schedule task
代码如下: //innosetup自带的方法,当卸载软件时,根据卸载的状态改变时而触发 procedure CurUninstallStepChanged(CurUninstallStep: TUni ...
- Python远程连接Windows,并调用Windows命令(类似于paramiko)
import winrm win2012 = winrm.Session(')) r = win2012.run_cmd('D: &' ' cd python &' ' type s. ...