• 第一章作业


    具体内容:
    一、硬件、系统、网络监控
    所有集群节点(所有虚拟机)都监控上;
    二、应用服务监控

    1. 监控备份服务器,简单方法是监控rsync端口,如果有其他更佳方案可以说明;
    2. 监控NFS服务器,使用监控NFS进程来判断NFS服务器正常,如果有其他更佳方案可以说明;
    3. 监控MySQL服务器,简单方法监控mysql的3306端口,或者使用zabbix提供的Mysql模板,如果有其他更佳方案可以说明;
    4. 监控2台web服务器,简单方法监控80端口,如果有其他更佳方案可以说明;
    5. 监控URL地址来更精确的监控我们的网站运行正常;
    6. 监控反向代理服务器,PPTP服务器等你在期中架构部署的服务;
    7. 监控Nginx的7种连接状态;
    8. 监控tomcat状态;
    9. 监控memcached状态:get命中率。

    解答

    在zabbix服务器上进行配置,使用zabbix自带模板进行配置(zabbix服务器已安装完成,此处省略)
    

    1. 监控备份服务器,简单方法是监控rsync端口,如果有其他更佳方案可以说明;

    第一步:在rsync服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    [root@backup ~]# egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=backup
    /etc/init.d/zabbix-agent start
    
    第二步:在网页上进行配置

    创建主机-创建应用集-创建监控项-创建触发器-创建图形




    第三步:关闭rsync服务,进行测试监控
    [root@backup ~]# pkill rsync
    [root@backup ~]# netstat -ntulp |grep rsync
    

    2. 监控NFS服务器,使用监控NFS进程来判断NFS服务器正常,如果有其他更佳方案可以说明;

    第一步:在NFS服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=nfs01
    #添加一条监控命令,统计nfs的进程总数
    [root@nfs01 ~]# grep -n "nfs.pro" /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf 19:UserParameter=nfs.proc,ps -ef|grep nfs|grep -v grep|wc -l
    /etc/init.d/zabbix-agent start
    
    第二步:在网页上进行配置,添加主机-添加应用集-添加监控项-添加触发器-添加图形





    第三步:测试,关闭nfs服务
    [root@nfs01 ~]# /etc/init.d/nfs stop
    

    3. 监控MySQL服务器,简单方法监控mysql的3306端口,或者使用zabbix提供的Mysql模板,如果有其他更佳方案可以说明;

    第一步:在mysql服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=db01
    /etc/init.d/zabbix-agent start
    
    第二步:在网页上进行配置,添加主机-添加应用集-添加监控项-添加触发器-添加图形








    第三步:测试,关闭mysql服务
    [root@db01 zabbix]# /etc/init.d/mysqld stop
    

    4. 监控2台web服务器,简单方法监控80端口,如果有其他更佳方案可以说明;

    第一步:在web服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=db01
    /etc/init.d/zabbix-agent start
    
    第二步:在网页上进行配置,添加主机-添加应用集-添加监控项-添加触发器-添加图形






    第三步:测试,关闭web服务器80端口
    /application/nginx/sbin/nginx -s stop
    

    5. 监控URL地址来更精确的监控我们的网站运行正常;
    以部署好的web02为例
    
    第一步:选择web检测,选择创建web场景





    第二步:创建触发器



    第三步:测试,注释服务器上的hosts文件解析域名



    6. 监控反向代理服务器,PPTP服务器等你在期中架构部署的服务;

    第一步:在代理服务器与VPN服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=lb01
    /etc/init.d/zabbix-agent start
    
    第二步:在网页上进行配置,创建主机-创建监控项-创建触发器-创建图形(以端口进行监控)





    第三步:关闭pptp服务与nginx服务进行测试
    [root@ntp ~]# systemctl stop pptpd.service
    [root@ntp ~]# ss -ntulp|grep pptp
    [root@lb01 ~]# /application/nginx/sbin/nginx -s stop
    

    7. 监控Nginx的7种连接状态;

    在web02上进行nginx的7种连接状态监控
    
    第一步:先在nginx配置文件中添加status状态,重启nginx服务

    第二步:使用curl -s 访问
        [root@web02 ~]# curl 10.0.0.8/status
    Active connections: 1 
    server accepts handled requests
     777 777 560 
    Reading: 0 Writing: 1 Waiting: 0 
    
    第三步:创建连接状态脚步,并写入到zabbix配置文件中
    [root@web02 scripts]# cat nginx_accepts.sh  nginx_handled.sh  nginx_requests.sh  n
    ginx_writing.sh nginx_active.sh   nginx_reading.sh  nginx_waiting.sh
    #!/bin/bash
    NGINX_SERVER=http://10.0.0.8/status
    curl -s $NGINX_SERVER|awk -F "[ ]" 'NR==3{print $2}'
    #!/bin/bash
    NGINX_SERVER=http://10.0.0.8/status
    curl -s $NGINX_SERVER|awk -F "[ ]" 'NR==3{print $3}'
    #!/bin/bash
    NGINX_SERVER=http://10.0.0.8/status
    curl -s $NGINX_SERVER|awk -F "[ ]" 'NR==3{print $4}'
    #!/bin/bash
    NGINX_SERVER=http://10.0.0.8/status
    curl -s $NGINX_SERVER|awk -F "[: ]+" 'NR==4 {print $4}'
    #!/bin/bash
    NGINX_SERVER="http://10.0.0.8/status"
    curl -s  $NGINX_SERVER|awk -F ":" 'NR==1 {print $2}'
    #!/bin/bash
    NGINX_SERVER=http://10.0.0.8/status
    curl -s $NGINX_SERVER|awk -F "[: ]+" 'NR==4 {print $2}'
    #!/bin/bash
    NGINX_SERVER=http://10.0.0.8/status
    curl -s $NGINX_SERVER|awk -F "[: ]+" 'NR==4 {print $6}'
    #添加key
    [root@web02 scripts]# vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
    UserParameter=nginx.active,/bin/sh /server/scripts/nginx_active.sh
    UserParameter=nginx.accepts,/bin/sh /server/scripts/nginx_accepts.sh
    UserParameter=nginx.reading,/bin/sh /server/scripts/nginx_reading.sh
    UserParameter=nginx.writing,/bin/sh /server/scripts/nginx_writing.sh
    UserParameter=nginx.waiting,/bin/sh /server/scripts/nginx_waiting.sh
    UserParameter=nginx.handled,/bin/sh /server/scripts/nginx_handled.sh
    UserParameter=nginx.requests,/bin/sh /server/scripts/nginx_requests.sh
    #重启服务
    [root@web02 scripts]# /etc/init.d/zabbix-agent restart
    
    第四步:在网页上进行配置,添加监控项与图形



    第五步:打开图形进行监控


    8. 监控tomcat状态;

    第一步:在tomcat服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=lb01
    /etc/init.d/zabbix-agent start
    
    第二步:在网页上进行配置,创建主机,创建监控项,创建触发器,创建图形





    第三步:测试,关闭tomcat服务
    [root@web03 logs]# ../bin/shutdown.sh
    

    9. 监控memcached状态:get命中率。

    第一步:在缓存服务器安装客户端,并进行修改配置文件
    rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-release-4.1-1.el6.noarch.rpm
    yum -y install zabbix-agent
    egrep -n "^Server|^Hostname" /etc/zabbix/zabbix_agentd.conf 
    98:Server=172.16.1.22
    139:ServerActive=172.16.1.22
    150:Hostname=cache01
    /etc/init.d/zabbix-agent start
    
    第二步:编写脚步,算出get命中率(get_hits/cmd_get)
    [root@cache01 scripts]# vim hit_rate.sh 
    #!/bin/bash
    cmd_get=`memcached-tool 172.16.1.21:11211 stats|grep cmd_get|awk '{print $2+""}'`
    get_hits=`memcached-tool 172.16.1.21:11211 stats|grep get_hits|awk '{print $2+""}'`
    hit_rate=`awk 'BEGIN{print ('$get_hits'/'$cmd_get')*100}'|awk -F "." '{print $1}'`
    echo $hit_rate
    
    第三步:编写agent配置文件,添加key值
    [root@cache01 scripts]# vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
    UserParameter=hit.rate,/bin/sh /server/scripts/hit_rate.sh
    
    第四步:在网页上进行配置,创建主机,创建监控项,创建图形



    第五步:查看结果

  • 相关阅读:
    Day-10: 错误、调试和测试
    Day-9: 面对对象高级编程
    json文件解析
    sqlite3入门之sqlite3_get_table,sqlite3_free_table
    sqlite3入门之sqlite3_open,sqlite3_exec,slite3_close
    字符集编码与字符大小
    让ubuntu下的eclipse支持GBK编码
    使用virtualbox安装unbuntu开启共享文件夹时遇到的权限问题
    QT--信号与槽
    QT--初识
  • 原文地址:https://www.cnblogs.com/yjiu1990/p/10669034.html
Copyright © 2020-2023  润新知