zabbix server update监控

简介:

 用来衡量zabbix server和proxy的update 性能,在数据delay比较严重的时候,update percent会比较低。可以做成item用来监控性能。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import  MySQLdb
import  sys
import  time
class  dbUtil:
         def __init__(self,host,user,passwd,db):
                 self.host = host
                 self.user = user
                 self.passwd = passwd
                 self.db = db
         def db_connect(self):
                 self.conn = MySQLdb.connect(host=self.host,user=self.user,passwd=self.passwd,db=self.db)
                 self.cursor = self.conn.cursor()
         def db_fetch_one(self,sql):
                 self.cursor.execute(sql)
                 try :
                         result = float(self.cursor.fetchone()[ 0 ])
                 except:
                         result =  "-1"
                 return  result
         def db_close(self):
                 self.cursor.close()
                 self.conn.close()
def getData(sql):
         #print sql
         conn = dbUtil(ip,user,password,db)
         conn.db_connect()
         re = conn.db_fetch_one(sql)
         return  re
         conn.db_close()
def getPercent(hostname):
         if  hostname ==  "server_hostname" :
                 sql =  "" " select round(a.aa* 100 /b.bb, 2 ) from
       (select count(*)  as  aa from items
         where lastclock > UNIX_TIMESTAMP()- 1800  and delay <  900
             and hostid  in  (select hostid from hosts where status= 0 )
             and status =  0
       ) a,
       (select count(*)  as  bb from items
         where delay <  900  and status =  0
             and hostid  in  (select hostid from hosts where status= 0 )
        ) b "" "
                 print getData(sql)
         else :
                 hostsql=  "select hostid from hosts where host='%s'"  % (hostname)
                 hostid = getData(hostsql)
                 sql =  "" " select round(a.aa* 100 /b.bb, 2 ) from
       (select count(*)  as  aa from items
         where lastclock > UNIX_TIMESTAMP()- 1800  and delay <  900
             and hostid  in  (select hostid from hosts where status= 0  and proxy_hostid = %s)
             and status =  0
       ) a,
       (select count(*)  as  bb from items
         where delay <  900  and status =  0
             and hostid  in  (select hostid from hosts where status= 0  and proxy_hostid = %s)
        ) b "" " % (hostid,hostid)
                 print getData(sql)
if  __name__ ==  "__main__" :
         hostname = sys.argv[ 1 ]
         getPercent(hostname)


调用方法:

脚本 hostname.

监控配置文件:

UserParameter=zabbix_percent[*],python /apps/sh/zabbix_scripts/zabbix/zabbix_percent.py $1


本文转自菜菜光 51CTO博客,原文链接:http://blog.51cto.com/caiguangguang/1344832,如需转载请自行联系原作者
相关文章
|
2月前
|
监控 应用服务中间件 nginx
基于Zabbix的SLA监控体系构建与实践
本文由Zabbix社区专家褚凤彬分享,详解SLA在Zabbix中的应用。通过Trigger与Service联动,构建Web应用的多层级监控体系,并介绍SLA计算规则、维护期处理及升级注意事项,助力企业精准掌控服务可用性。
333 36
|
8月前
|
运维 监控 安全
【案例分享】中国通号卡斯柯公司:ZABBIX如何破解轨道交通监控难题
本文根据2023上海峰会上朱林贤的演讲整理,聚焦中国通号卡斯柯公司如何借助Zabbix实现轨道交通信号系统的智能化管理。作为中外合资企业,卡斯柯通过统一平台整合设备监控,大幅降低成本并提升灵活性,成功应用于国内外项目。文章探讨了传统监控系统的痛点、研发维护经验及国产化与开源技术挑战,为行业转型提供了宝贵启示。未来,开放协作将是推动轨道交通智能化发展的关键。
380 8
|
监控 安全 Linux
在Linux中,zabbix如何监控脑裂?
在Linux中,zabbix如何监控脑裂?
|
10月前
|
存储 缓存 监控
|
11月前
|
监控 Java 应用服务中间件
tomcat相关概念与部署tomcat多实例-zabbix监控(docker部署)
通过上述步骤,您可以在Ubuntu系统上成功编译并安装OpenCV 4.8。这种方法不仅使您能够定制OpenCV的功能,还可以优化性能以满足特定需求。确保按照每一步进行操作,以避免常见的编译问题。
163 23
|
11月前
|
监控 Java 应用服务中间件
tomcat相关概念与部署tomcat多实例-zabbix监控(docker部署)
通过上述步骤,您可以在Ubuntu系统上成功编译并安装OpenCV 4.8。这种方法不仅使您能够定制OpenCV的功能,还可以优化性能以满足特定需求。确保按照每一步进行操作,以避免常见的编译问题。
250 25
|
11月前
|
监控 Java 应用服务中间件
tomcat相关概念与部署tomcat多实例-zabbix监控(docker部署)
通过上述步骤,您可以在Ubuntu系统上成功编译并安装OpenCV 4.8。这种方法不仅使您能够定制OpenCV的功能,还可以优化性能以满足特定需求。确保按照每一步进行操作,以避免常见的编译问题。
297 22
|
12月前
|
监控 安全 前端开发
使用 Zabbix 监控堆外应用
使用 Zabbix 监控堆外应用
218 9
|
12月前
|
监控 数据可视化 Java
zabbix全面的监控能力
zabbix全面的监控能力
431 7
|
监控 Java Shell
监控堆外第三方监控工具Zabbix
监控堆外第三方监控工具Zabbix
303 5

热门文章

最新文章

推荐镜像

更多