保存好配置文件后,重启一下Zabbix本机的客户端和服务端:
pkill -9 -U zabbix
/usr/local/zabbix/sbin/zabbix_agentd
/usr/local/zabbix/sbin/zabbix_server
Zabbix服务器获取SQL语句执行后的返回值:
[root@centos8 ~]# /usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k command_3
8
[root@centos8 ~]#
[root@centos8 ~]# /usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k command_4
3
[root@centos8 ~]#
######
######
使用本地数据库用户zabbix@localhost登录MariaDB:(假如MariaDB的端口为默认的TCP 3306,就可以不写)
[root@centos8 ~]# mysql -u"zabbix" -p"168" -h"localhost" -P"3306"
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 540
Server version: 10.3.17-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
在库zabbix的表Table_1中更改数据:
MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zabbix]>
MariaDB [zabbix]> Update Table_1 set Age = 18 where Name = 'Zhuohua';
Query OK, 1 row affected (0.001 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [zabbix]>
MariaDB [zabbix]> Select Age from Table_1 where Name = 'Zhuohua';
+------+
| Age |
+------+
| 18 |
+------+
1 row in set (0.000 sec)
MariaDB [zabbix]>
Zabbix服务器再次获取SQL语句执行后的返回值:
[root@centos8 ~]# /usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k command_3
18
[root@centos8 ~]#
相关文章:
CentOS8_LAMP_编译安装Zabbix5.0.12CentOS8_在Docker中安装Zabbix5.0.12Zabbix5.0.12_使用Agent监控Windows2008R2Zabbix5.0.12_使用SNMP监控iKuai路由器(SNMPv2c+SNMP OID)Zabbix5.0.12_调用Python3脚本监控Linux下的MySQLZabbix5.0.12_调用Python3脚本监控Windows下的MSSQL