zoukankan      html  css  js  c++  java
  • zabbix 判断添加是否成功

    def addMonitor(req):
         print req.get_full_path()
         host=req.GET['monitor_name']
         ip=req.GET['monitor_ip']
         group=req.GET['group']
         temp=req.GET['temp']
         a=add_host(host,ip,group,temp)
         print '---------------------'
         print a
         print type(a)
         try:
          code= a['error']
          print '---------------------'
          return HttpResponse(code['data'])
         except:
          return HttpResponse('add success')
    
    
    /api/addMonitor/?env=pro&temp=10001&group=1&monitor_ip=1.1.1.1&monitor_name=2000
    ---------------------
    {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'Invalid params.', u'code': -32602, u'data': u'Host with the same name "2000" already exists.'}}
    <type 'dict'>
    ---------------------
    [13/Dec/2017 10:42:25] "GET /api/addMonitor/?env=pro&temp=10001&group=1&monitor_ip=1.1.1.1&monitor_name=2000 HTTP/1.1" 200 46
    [13/Dec/2017 10:42:35] "GET /api/addMonitor?env=pro&temp=10001&group=1&monitor_ip=1.1.1.1&monitor_name=3000 HTTP/1.1" 301 0
    /api/addMonitor/?env=pro&temp=10001&group=1&monitor_ip=1.1.1.1&monitor_name=3000
    ---------------------
    {u'jsonrpc': u'2.0', u'result': {u'hostids': [u'10114']}, u'id': 1}
    <type 'dict'>
    [13/Dec/2017 10:42:36] "GET /api/addMonitor/?env=pro&temp=10001&group=1&monitor_ip=1.1.1.1&monitor_name=3000 HTTP/1.1" 200 11
    
    zabbix 判断主机添加是否成功
    
    a=[1,2,3,4]
    try:
        code=a[9]
        print '1111111'
    except:
        print '2222222'
    
    C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/templates/a11.py
    2222222
    
    
    a=[1,2,3,4]
    try:
        code=a[1]
        print '1111111'
    except:
        print '2222222'
    
    C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/templates/a11.py
    1111111

  • 相关阅读:
    Linux 普通用户su命令切换控制
    Linux上的文件管理类命令(2)
    系统内存管理
    ssh 安全配置
    redhat系统安装部署
    Unity截屏
    Unity场景道具模型拓展自定义编辑器
    Unity优化之减少Drawcall
    Unity安卓连接profile调试
    Unity游戏数据用Json保存
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349370.html
Copyright © 2011-2022 走看看