客户端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通用应用检测插件的更多相关文章

  1. check_mk检测插件编写

    参考 Writing Checks (Introduction) Writing agent based checks The New Check API http://www2.steinkogle ...

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

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

  3. 浏览器特性检测插件Feature.js

    <script src="js/feature.js"></script> if (feature.webGL) { console.log("你 ...

  4. Java代码规范与质量检测插件SonarLint

    1.  SonarLint SonarLint是一个代码质量检测插件,可以帮助我们检测出代码中的坏味道 下载与安装 在需要检测的单个文件或者单个项目上右键 --> Analyze --> ...

  5. 《阿里巴巴 Java 开发规约》自动化检测插件安装及体验

    2017 开春之际,有助于提高行业编码规范化水平的<阿里巴巴 Java 开发手册>首次面世.汇聚阿里集团近万名技术精英的经验知识,这套高含金量的手册一经公开,便引起业界普遍关注和学习. 历 ...

  6. FCOS论文复现:通用物体检测算法

    摘要:本案例代码是FCOS论文复现的体验案例,此模型为FCOS论文中所提出算法在ModelArts + PyTorch框架下的实现.本代码支持FCOS + ResNet-101在MS-COCO数据集上 ...

  7. check_mk检测插件 - raid监控

    mk_raidstatus python版本 #!/usr/bin/env python # -*- encoding: utf-8; py-indent-offset: 4 -*- import s ...

  8. spring-boot | 整合通用Mabatis 分页插件PageHelper

    Mybatis通用Mapper介绍 Mybatis 通用 Mapper 极其方便的使用 Mybatis 单表的增删改查,支持单表操作,不支持通用的多表联合查询 优点: 通用 Mapper 可以极大的方 ...

  9. laravel administrator 一款通用的后台插件(PHP框架扩展)

    前几天我看了一下zend framework 2的一些官方文档,也找了一些例子,可惜所有的资料少之甚少.于是我就开始去找这国外用的比较流行的PHP框架laravel,希望能够找到其合适的例子,而且我本 ...

随机推荐

  1. Home Web Server 1.9.1 build 164 - CGI Remote Code Execution复现

    一.  Home Web Server 1.9.1 build 164 - CGI Remote Code Execution复现 漏洞描述: Home Web Server允许调用CGI程序来通过P ...

  2. C++ GUI Qt4编程(08)-3.2spreadsheet-resource

    1. C++ GUI Qt4编程第三章,图片使用资源机制法. 2. 步骤: 2-1. 在resource文件夹下,新建images文件,存放图片. 2-2. 新建spreadsheet.qrc文件,并 ...

  3. shell 操作环境

    一.路径与命令查找顺序 命令的运行程序可以这样看: 1.以相对/绝对的路径执行命令,例“/bin/ls”或“ls” 2.由alias乍到该命令来执行 3.由bash内置的(builtin)命令来执行 ...

  4. PIE SDK符号选择器

    1. 功能简介 符号选择器可以根据不同的需求进行改变图层的符号形状以及颜色,下面基于PIE SDK介绍如何使用符号选择器. 2. 功能实现说明 2.1.  实现思路及原理说明 第一步 加载图层 第二步 ...

  5. gulp打包css/image/Less/Sass

    其他的和打包前一篇随笔(打包js) http://www.cnblogs.com/teersky/p/7251329.html 相同,本篇文章主要写gulpFile.js的配置: 安装CSS打包插件: ...

  6. spark第七篇:Spark SQL, DataFrame and Dataset Guide

    预览 Spark SQL是用来处理结构化数据的Spark模块.有几种与Spark SQL进行交互的方式,包括SQL和Dataset API. 本指南中的所有例子都可以在spark-shell,pysp ...

  7. web安全漏洞种类

    (参考知道创宇) SQL注入: SQL注入(SQL Injection),是一个常见的发生于应用程序和数据库之间的web安全漏洞,由于在开发过程中的设计不当导致程序中忽略了检查,没有有效的过滤用户的输 ...

  8. linux 拓展之linux纯命令行界面变为图形界面

    使用版本为6.x 1, 连接网络  没网络就下载不了哦 2,设置下yum源,我本机原来的yum源是网易的但是我用不了,我设置阿里云可以下载, 你们有这问题的可以试试    3, yum groupin ...

  9. 【Tensorflow】 Object_detection之训练PASCAL VOC数据集

    参考:Running Locally 1.检查数据.config文件是否配置好 可参考之前博客: Tensorflow Object_detection之配置Training Pipeline Ten ...

  10. 抓包来看ftp状态码

    1.quit退出 客户端输入退出命令: 退出的抓包数据交换过程: 2.用户登录,输入正确用户名和错误用户名都是返回331请求输入密码,这里不再将错误用户名的抓包数据交换过程截图. 数据交换过程: 服务 ...