青岛做网站公,任务发布平台,苏州产品网站建设,江西建设厅网站证书查询目录
一、监控mysql数据库及httpd服务
1、为server.Zabbix.com添加服务模板
2、server.zabbix.com服务端 操作
3、编辑chk_mysql.sh脚本
4、server.zabbix.com测试 二、监控apache
1、获取键值
2、服务器操作
3、zabbix监控web端导入监控模板
4、server.zabbix.com添加…目录
一、监控mysql数据库及httpd服务
1、为server.Zabbix.com添加服务模板
2、server.zabbix.com服务端 操作
3、编辑chk_mysql.sh脚本
4、server.zabbix.com测试 二、监控apache
1、获取键值
2、服务器操作
3、zabbix监控web端导入监控模板
4、server.zabbix.com添加apache模板 三、监控ftp
1、这里用agent.zabbix.com的主机
2、为ftp添加模板 一、监控mysql数据库及httpd服务
1、为server.Zabbix.com添加服务模板 2、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.147.135
ServerActive192.168.147.135
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
UserParametermysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1
UserParametermysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.147.135 ping | grep -c alive
#解释
#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.200.111 ping | grep #-c alive ///定义键值mysql.ping指定chk_mysql.sh脚本使用此脚本检查mysql的运行状态#使用mysqladmin命令指定agent端的数据库连接用户密码ip地址注意保证mysqladmin命令的链接3、编辑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.147.135# 端口
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)] 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 4、server.zabbix.com测试
[rootserver etc] zabbix_get -s 192.168.147.135 -k mysql.ping
1
[rootserver etc] zabbix_get -s 192.168.147.135 -k mysql.status[Com_update]
452二、监控apache
1、获取键值
[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
[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.200.111 -p 10050 -k httpd.status
[rootserve ~] which netstat
/usr/bin/netstat
[rootserve~] chmod us /usr/bin/netstat
[rootserver ~] zabbix_get -s 192.168.200.111 -p 10050 -k httpd.status
[rootserver ~]systemctl stop httpd2、服务器操作
首先在本机下载模板https://github.com/rdvn/zabbix-templates/archive/master.zip
该zip包有apache、memcache、redis、varnish模板,我们解压后使用其中的apache模板。
[rootserver ~] wget https://github.com/rdvn/zabbix-templates/archive/master.zip
[rootserver ~] ls
anaconda-ks.cfg jdk-8u91-linux-x64.tar.gz 图片
apache-tomcat-8.5.16.tar.gz master.zip 文档
catalina-jmx-remote.jar zabbix-3.4.11.tar.gz 下载
dead.letter 公共 音乐
grafana-4.2.0-1.x86_64.rpm 模板 桌面
initial-setup-ks.cfg 视频
[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_server3、zabbix监控web端导入监控模板 导入 自此模板就导入成功了 现在为server.zabbix.com添加我们导入的模板
4、server.zabbix.com添加apache模板 三、监控ftp
1、这里用agent.zabbix.com的主机
[rootagent ~] yum install -y vsftpd
[rootagent ~] systemctl start vsftpd //启动ftp服务
[rootagent ~] systemctl enable vsftpd //设置ftp服务开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.2、为ftp添加模板