保定市制作网站公司,怎么做小程序推广,湖北网络推广,网站 弹出目录 一、Zabbix监控mysql数据库
1、为server.Zabbix.com添加服务模板 2、创建mysql服务图形 二、server.zabbix.com服务器操作
编辑chk_mysql.sh脚本
三、server.Zabbix.com测试
四、查看web效果 五、Zabbix监控apache#xff08;httpd服务#xff09;
安装master
六、…目录 一、Zabbix监控mysql数据库
1、为server.Zabbix.com添加服务模板 2、创建mysql服务图形 二、server.zabbix.com服务器操作
编辑chk_mysql.sh脚本
三、server.Zabbix.com测试
四、查看web效果 五、Zabbix监控apachehttpd服务
安装master
六、Zabbix监控web端导入监控模板
七、Server.zabbix.com添加apache模板 八、查看zabbix出图效果 一、Zabbix监控mysql数据库
1、为server.Zabbix.com添加服务模板 2、创建mysql服务图形 添加图形的操作 二、server.zabbix.com服务器操作
[rootserver ~]# cd /usr/local/zabbix/etc/[rootserver etc]# vim zabbix_agentd.conf
PidFile/tmp/zabbix_agentd.pid
Server127.0.0.1,192.168.2.20
ServerActive192.168.2.20
Hostnameserver.zabbix.com
LogFile/usr/local/zabbix/logs/zabbix_agentd.log
Include/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters1 #允许所有字符的参数传递给用户定义的参数。
UserParametermysql.version,mysql -V #定义键值mysql.version以及键值的值mysql -V
UserParametermysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1 #定义键值mysql.status[*]
UserParametermysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.2.20 ping | grep -c alive #定义键值mysql.ping指定chk_mysql.sh脚本使用此脚本检查mysql的运行状态使用mysqladmin命令指定agent端的数据库连接用户密码ip地址注意保证mysqladmin命令的链接
编辑chk_mysql.sh脚本
[rootserver etc]# pwd
/usr/local/zabbix/etc
[rootserver etc]# vim chk_mysql.sh
#!/bin/bash
#FileName: check_mysql.sh
# Revision: 1.0
# Date: 2015/06/09
# Author: DengYun
# Email: dengyunttlsa.com
# Website: www.ttlsa.com
# Description:
# Notes: ~
# -------------------------------------------------------------------------------
# Copyright: 2015 (c) DengYun
# License: GPL# 用户名
MYSQL_USERroot# 密码
MYSQL_PWD123123# 主机地址/IP
MYSQL_HOST192.168.2.20# 端口
MYSQL_PORT3306# 数据连接
MYSQL_CONN/usr/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PWD} -h${MYSQL_HOST} -P${MYSQL_PORT}# 参数是否正确
if [ $# -ne 1 ];then echo arg error!
fi # 获取数据
case $1 in Uptime) result${MYSQL_CONN} status|cut -f2 -d:|cut -f1 -dT echo $result ;; Com_update) result${MYSQL_CONN} extended-status |grep -w Com_update|cut -d| -f3 echo $result ;; Slow_queries) result${MYSQL_CONN} status |cut -f5 -d:|cut -f1 -dO echo $result ;; Com_select) result${MYSQL_CONN} extended-status |grep -w Com_select|cut -d| -f3 echo $result ;; Com_rollback) result${MYSQL_CONN} extended-status |grep -w Com_rollback|cut -d| -f3 echo $result ;; Questions) result${MYSQL_CONN} status|cut -f4 -d:|cut -f1 -dS echo $result ;; Com_insert) result${MYSQL_CONN} extended-status |grep -w Com_insert|cut -d| -f3 echo $result ;; Com_delete) result${MYSQL_CONN} extended-status |grep -w Com_delete|cut -d| -f3 echo $result ;; Com_commit) result${MYSQL_CONN} extended-status |grep -w Com_commit|cut -d| -f3 echo $result ;; Bytes_sent) result${MYSQL_CONN} extended-status |grep -w Bytes_sent |cut -d| -f3 echo $result ;; Bytes_received) result${MYSQL_CONN} extended-status |grep -w Bytes_received |cut -d| -f3 echo $result ;; Com_begin) result${MYSQL_CONN} extended-status |grep -w Com_begin|cut -d| -f3 echo $result ;; *) echo Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin) ;;
esac[rootserver etc]# chmod 777 chk_mysql.sh #为脚本加权[rootserver etc]# mysql -u root -p123123 #mysql授权
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4111
Server version: 5.5.56-MariaDB MariaDB ServerCopyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type help; or \h for help. Type \c to clear the current input statement.MariaDB [(none)] grant all on *.* to rootserver.zabbix.com identified by 123123;
Query OK, 0 rows affected (0.10 sec)MariaDB [(none)] UPDATE mysql.user SET PasswordPASSWORD(123123) WHERE Userroot;MariaDB [(none)] flush privileges;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)] \q
Bye[rootserver etc]# killall -9 zabbix_agentd
[rootserver etc]# killall -9 zabbix_server[rootserver etc]# /usr/local/zabbix/sbin/zabbix_agentd
[rootserver etc]# /usr/local/zabbix/sbin/zabbix_server[rootserver etc]# netstat -anpt | egrep :10050|10051
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 34683/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 34691/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 34683/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 34691/zabbix_server
三、server.Zabbix.com测试
[rootserver etc]# ln -s /usr/local/zabbix/bin/* /usr/local/bin/[rootserver etc]# zabbix_get -s 192.168.2.20 -k mysql.ping
1[rootserver etc]# zabbix_get -s 192.168.2.20 -k mysql.status[Com_update]
3164
四、查看web效果 五、Zabbix监控apachehttpd服务
[rootserver ~]# vim /opt/check_httpd.sh#!/bin/bash
#
netstat -lnpt |grep -q :80
if [ $? -eq 0 ]
thenecho 1
elseecho 0
fi
[rootserver ~]#chmod x /opt/check_httpd.sh anaconda-ks.cfg [rootserver ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
UnsafeUserParameters1
UserParameterhttpd.status,/opt/check_httpd.sh [rootserver ~]#killall -9 zabbix_agentd[rootserver ~]#zabbix_agentd[rootserver ~]# ln -s /usr/local/zabbix/bin/zabbix_get /usr/local/bin/zabbix_get[rootserver ~]# zabbix_get -s 192.168.2.20 -p 10050 -k httpd.status[rootserve ~]# which netstat
/usr/bin/netstat[rootserve~]# chmod us /usr/bin/netstat[rootserver ~]# zabbix_get -s 192.168.2.20 -p 10050 -k httpd.status[rootserver ~]#systemctl stop httpd
安装master
master源码包提取链接https://pan.baidu.com/s/1OxG63zP6niAOAoavUDX6Sw?pwdvwds 提取码vwds
[rootserver ~]# ls
master.zip[rootserver ~]# mv master.zip /usr/local/src/ #该文件夹没有文件方便查看[rootserver ~]# cd /usr/local/src/[rootserver src]# unzip master.zip #解压下载的zip压缩包[rootserver src]# ls
master.zip zabbix-templates-master[rootserver src]# cd zabbix-templates-master/[rootserver zabbix-templates-master]# ls
apache memcached README redis varnish #apache中有我们需要的文件[rootserver zabbix-templates-master]# cd apache/[rootserver apache]# ls
apache_status.sh apache.xml README #apache_status.sh 该文件时apache的agent监控需要的脚本文件#apache.xml文件是zabbix需要的模板[rootserver apache]# cp apache_status.sh /usr/local/zabbix/sbin/[rootserver apache]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
UserParameterapache[*],/usr/local/zabbix/sbin/apache_status.sh $1 #末行追加引用apache_status.sh的监控脚本[rootserver apache]# cd[rootserver ~]# chmod x /usr/local/zabbix/sbin/apache_status.sh //为脚本加执行权限[rootserver ~]# ll /usr/local/zabbix/sbin/
总用量 7264
-rwxr-xr-x 1 zabbix zabbix 248 8月 9 14:03 apache_status.sh
-rwxr-xr-x 1 zabbix zabbix 1477216 8月 7 15:00 zabbix_agentd
drwxr-xr-x 4 zabbix zabbix 84 8月 8 05:57 zabbix_java
-rwxr-xr-x 1 zabbix zabbix 5954120 8月 7 15:00 zabbix_server[rootserver ~]# sz /usr/local/src/zabbix-templates-master/apache/apache.xml #将apache.xml文件传到windows端
六、Zabbix监控web端导入监控模板 自此模板就导入成功了 现在为server.zabbix.com添加我们导入的模板
七、Server.zabbix.com添加apache模板 八、查看zabbix出图效果 apche监控成功