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,希望能够找到其合适的例子,而且我本 ...
随机推荐
- C++_函数1-编程的基本模块函数
以下是<C++ Primer Plus>中第七章的内容: 使用C++函数的3个步骤: 提供函数定义 提供函数原型 调用函数 7.1.1 定义函数 函数分成两类:没有返回值的函数.有返回值的 ...
- HDU - 2276 位运算矩阵快速幂
挺有意思的一道题 要会运用一些常见的位运算操作进行优化 题目的本质就是要求下面的式子 \(dp[i][j+1]=(dp[i-1][j]+dp[i][j]) \mod 2\) (第\(i\)个字符在\( ...
- 字典树+map
Problem Description Carryon最近喜欢上了一些奇奇怪怪的字符,字符都是英文小写字母,但奇怪的是a可能比b小,也可能比b大,好奇怪.与此同时,他拿到了好多的字符串,可是看着很不顺 ...
- shell编程下
第1章 Whicle 1.1 while循环语句 在编程语言中,while循环(英语:while loop)是一种控制流程的陈述.利用一个返回结果为布林值(Boolean)的表达式作为循环条件,当这个 ...
- css 小知识点
苹果浏览默认表单 单选 多选 下拉列表 效果的去除 提交按钮-webkit-appearance: none;-moz-appearance: none;-ms-appearance: none;ap ...
- python 爬虫系列05--丑事百科
丑事百科爬虫 import re import requests def parse_page(url): headers = { 'User-Agent':'user-agent: Mozilla/ ...
- mongoDB--万能的$关键字
之前哥的博客写了增删改查的基本用法,其中$set是关键字用来修改值的,但是不关只有set这一个关键字,下面我们就来说一个万能的$关键字 1.常见的等于 大于 小于 大于等于 小于等于 #等于---&g ...
- 【CAD】自定义实体的步骤(转)
本文介绍了构造自定义实体的步骤.必须继承的函数和必须注意的事项 1.新建一个从AcDbEntity继承的类,如EntTest,必须添加的头文件: "stdarx.h"," ...
- (转)Unity 之 UGUI 小总结
转自:http://www.jianshu.com/p/5b6f5022662e 开发过程中对UGUI的一个小总结. 首先从原画师拿到效果图,美术切图,拿到碎图后打成大图. 我们先来说一下图:RGBA ...
- elasticsearch 2.4.0执行update的时候发现的一个问题
请关注inline参数的变化 正确: POST /test/type1/1/_update{ "script" : { "inline": "ctx. ...