Zabbix服务器监控系统部署之自定义监控项的添加及配置(二)
上一篇文章(Zabbix分布式服务器监控系统安装及部署(一))记录了Zabbix整套系统的安装及部署,其中包含Server端和client段,主要是说安装及配置的事儿了,本文章主要记录Zabbix的自定义监控项配置。 因为我用到只是监控mysql的一些数据等信息,所以也只记
上一篇文章(Zabbix分布式服务器监控系统安装及部署(一))记录了Zabbix整套系统的安装及部署,其中包含Server端和client段,主要是说安装及配置的事儿了,本文章主要记录Zabbix的自定义监控项配置。
因为我用到只是监控mysql的一些数据等信息,所以也只记录这一块儿的,按照官方帮助文档中的说法,Zabbix提供了mysql的监控的模板,需要用户自己下载导入,官方下载地址,或者下载我提供的备用的:template_MySql。
下载后在Zabbixweb管理页面中导入,Configuration— Templates — Import Templates.选择相应xml模板导入即可。
编辑 etc/zabbix 下的配置文件,zabbix_agentd.conf 最下方,将以下内容前面的#去掉,记得将mysql的账号跟密码换掉:
UserParameter=mysql.ping,mysqladmin -uroot -ppasswd ping|grep alive|wc -l UserParameter=mysql.uptime,mysqladmin -uroot -ppasswd status|cut -f2 -d":"|cut -f1 -d"T" UserParameter=mysql.threads,mysqladmin -uroot -ppasswd status|cut -f3 -d":"|cut -f1 -d"Q" UserParameter=mysql.questions,mysqladmin -uroot -ppasswd status|cut -f4 -d":"|cut -f1 -d"S" UserParameter=mysql.slowqueries,mysqladmin -uroot -ppasswd status|cut -f5 -d":"|cut -f1 -d"O" UserParameter=mysql.qps,mysqladmin -uroot -ppasswd status|cut -f9 -d":" UserParameter=mysql.version,mysql -V
以上自带的监控参数比较简单。
若不够的话,可以将在上述目录下执行以下命令:
vi mysql_status.py
创建这样一个新的文件,在里面输入以下内容:
#!/usr/bin/env python # -*- coding: utf-8 -*- #File:mysql_status.py import MySQLdb,sys user = 'root' passwd = 'passwd' a = sys.argv[1] try: conn = MySQLdb.connect(host = '127.0.0.1',user = user,passwd = passwd,connect_timeout = 2) cursor = conn.cursor() sql = "SHOW STATUS" cursor.execute(sql) alldata = cursor.fetchall() for data in alldata: if data[0] == a : #print data[0],data[1] print data[1] break cursor.close() conn.close() except Exception, e: print e sys.exit() '''''Open_tables Opened_tables Max_used_connections Threads_connected Qcache_free_blocks Qcache_total_blocks Handler_read_first Handler_read_key Handler_read_rnd_next Slow_queries'''
保存。然后在zabbix_agentd.conf下方加入以下内容:
UnsafeUserParameters=1 UserParameter=mysql.Open_tables,/etc/zabbix/mysql_status.py Open_tables UserParameter=mysql.Opened_tables,/etc/zabbix/mysql_status.py Opened_tables UserParameter=mysql.Max_used_connections,/etc/zabbix/mysql_status.py Max_used_connections UserParameter=mysql.Threads_connected,/etc/zabbix/mysql_status.py Threads_connected UserParameter=mysql.Qcache_free_blocks,/etc/zabbix/mysql_status.py Qcache_free_blocks UserParameter=mysql.Qcache_total_blocks,/etc/zabbix/mysql_status.py Qcache_total_blocks UserParameter=mysql.Handler_read_first,/etc/zabbix/mysql_status.py Handler_read_first UserParameter=mysql.Handler_read_key,/etc/zabbix/mysql_status.py Handler_read_key UserParameter=mysql.Handler_read_rnd_next,/etc/zabbix/mysql_status.py Handler_read_rnd_next UserParameter=mysql.Slow_queries,/etc/zabbix/mysql_status.py Slow_queries
接着便可以在web中添加图形之类的直观数据了。。。
下面记录添加自定义的监控,如:监控用户数的增长,或者某个端口的情况等…
在zabbix_agentd.conf中,加入以下内容:
UserParameter=myhost.user,mysql -u root -ppasswd -e "use you_dbname;select count(*) from user" |tail -1
解释:
myhost.user 为Key,回头web设置中需要用到;
-u root -ppasswd 为mysql的用户名密码;
you_dbname 你要操作的数据库;
select count(*) from user sql语句;
UserParameter=myhost.port1005,netstat -ant | sed -n '1,2!p'|awk '{ if($6!="LISTEN") {if(match($4,"'1005'")) c=c+1}} END{print c}'
以上一句为端口监听。将1005换成你需要监听的端口号就可以。
重启Zabbix-agentd服务。
sudo service zabbix-agent restart
然后可以在Zabbix Server服务器上测试下是否监听成功,命令:
zabbix_get -s 192.168.1.106 -k myhost.user
若成功的话,便会显示出查得的数据了。
接着在 web中添加items,操作步骤,找到:Configuration —— Hosts —— 点击相应host的itmes,进入后会列出当前该主机的itmes列表,点击右上角Create item。
完成后,在创建图表的时候,便可以选择这个监控项了。
相关阅读:
[备忘]Zabbix分布式服务器监控系统安装及部署(一)
原文地址:Zabbix服务器监控系统部署之自定义监控项的添加及配置(二), 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users are increasingly favoring the electronic ecosystem of Xiaomi smart home interconnection in modern life. After connecting to the Mijia APP, you can easily control the connected devices with your mobile phone. However, many users still don’t know how to add Mijia to their homes. app, then this tutorial guide will bring you the specific connection methods and steps, hoping to help everyone in need. 1. After downloading Mijia APP, create or log in to Xiaomi account. 2. Adding method: After the new device is powered on, bring the phone close to the device and turn on the Xiaomi TV. Under normal circumstances, a connection prompt will pop up. Select "OK" to enter the device connection process. If no prompt pops up, you can also add the device manually. The method is: after entering the smart home APP, click the 1st button on the lower left

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

In network data transmission, IP proxy servers play an important role, helping users hide their real IP addresses, protect privacy, and improve access speeds. In this article, we will introduce the best practice guide on how to build an IP proxy server with PHP and provide specific code examples. What is an IP proxy server? An IP proxy server is an intermediate server located between the user and the target server. It acts as a transfer station between the user and the target server, forwarding the user's requests and responses. By using an IP proxy server

1. The picture below is the default screen layout of edius. The default EDIUS window layout is a horizontal layout. Therefore, in a single-monitor environment, many windows overlap and the preview window is in single-window mode. 2. You can enable [Dual Window Mode] through the [View] menu bar to make the preview window display the playback window and recording window at the same time. 3. You can restore the default screen layout through [View menu bar>Window Layout>General]. In addition, you can also customize the layout that suits you and save it as a commonly used screen layout: drag the window to a layout that suits you, then click [View > Window Layout > Save Current Layout > New], and in the pop-up [Save Current Layout] Layout] enter the layout name in the small window and click OK

What should I do if I can’t enter the game when the epic server is offline? This problem must have been encountered by many friends. When this prompt appears, the genuine game cannot be started. This problem is usually caused by interference from the network and security software. So how should it be solved? The editor of this issue will explain I would like to share the solution with you, I hope today’s software tutorial can help you solve the problem. What to do if the epic server cannot enter the game when it is offline: 1. It may be interfered by security software. Close the game platform and security software and then restart. 2. The second is that the network fluctuates too much. Try restarting the router to see if it works. If the conditions are OK, you can try to use the 5g mobile network to operate. 3. Then there may be more

Tampermonkey Chrome extension is a user script management plug-in that improves user efficiency and browsing experience through scripts. So how does Tampermonkey add new scripts? How to delete the script? Let the editor give you the answer below! How to add a new script to Tampermonkey: 1. Take GreasyFork as an example. Open the GreasyFork web page and enter the script you want to follow. The editor here chooses one-click offline download. 2. Select a script. , after entering the script page, you can see the button to install this script. 3. Click to install this script to come to the installation interface. Just click here to install. 4. We can see the installed one-click in the installation script.

1. Introduction Over the past few years, YOLOs have become the dominant paradigm in the field of real-time object detection due to its effective balance between computational cost and detection performance. Researchers have explored YOLO's architectural design, optimization goals, data expansion strategies, etc., and have made significant progress. At the same time, relying on non-maximum suppression (NMS) for post-processing hinders end-to-end deployment of YOLO and adversely affects inference latency. In YOLOs, the design of various components lacks comprehensive and thorough inspection, resulting in significant computational redundancy and limiting the capabilities of the model. It offers suboptimal efficiency, and relatively large potential for performance improvement. In this work, the goal is to further improve the performance efficiency boundary of YOLO from both post-processing and model architecture. to this end
![Outlook stuck on adding account [Fixed]](https://img.php.cn/upload/article/000/887/227/171116770937641.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
When you encounter problems adding accounts in Outlook, you can try the following solutions to resolve it. Typically this can be caused by a faulty network connection, corrupted user profiles, or other temporary issues. Through the methods provided in this article, you can easily solve these problems and ensure that your Outlook can run normally. Outlook stuck on adding account If your Outlook is stuck on adding account, then use these fixes mentioned below: Disconnect and reconnect the internet Temporarily disable antivirus software Create a new Outlook profile Try adding account in safe mode Disable IPv6 Run Microsoft Support and Recovery Assistant Repair Office Application Outlook Add Account Required
