zabbix 监控软件

zabbix 监控软件

自带图形化界面,通过网页就可以监控所有的服务器的状态。

事件告警,邮箱通知(噩梦)。

zabbix是什么?

web界面提供的分布式监控以及网络监控功能的开源的企业级的软件解决方案。

服务端

监控端 客户端

zabbix开以提供各种类型的监控模板,保证服务器的正常运行,灵活的通知机制可以让管理员快速定位。

zabbix由两部分组成:

1、zabbix-server 在server上可选安装zabbix-agent

2、收集数据的模式c/s模式

client/server

客户端到服务端

展示数据和配置数据

B/S

browes/server

页面配置

zabbix-server 服务端 收集数据 提供网页和配置数据

zabbix-agent 客户端 把收集到的数据发给服务端

zabbix的五大组件:

1、zabbix-server

2、zabbix-agent

3、zabbix_proxy 代理? 代理服务器的作用,如果所有的客户端都向服务器一起发数据,服务器的压力会比较大,发送到代理服务器,代理服务器处理完之后再发给server,减轻主服务器的压力

4、zabbix-get zabbix-get是zabbix的命令行工具

5、zabbix sender 发送器,可以将客户端的数据进行自定义操作之后再发送到服务端,也可以通过脚本,把脚本处理过的数据发送到客户端。

部署:zabbix 5.0

部署步骤:

服务端: 192.168.60.70 test7

#获取zabbix的下载源
[root@test7 ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm 
[root@test7 ~]# cd /etc/yum.repos.d/
[root@test7 yum.repos.d]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' zabbix.repo
[root@test7 yum.repos.d]# yum clean all && yum makecache
[root@test7 yum.repos.d]# yum install -y zabbix-server-mysql zabbix-agent
[root@test7 yum.repos.d]# vim CentOS-SCLo-scl-rh.repo
  [centos-sclo-rh]
  name=CentOS-7 - SCLo rh
  baseurl=http://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
  gpgcheck=0
  enabled=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@test7 yum.repos.d]# yum clean all && yum makecache
[root@test7 yum.repos.d]# vim zabbix.repo
   11 enabled=1         #将11行的0改为1
[root@test7 yum.repos.d]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
​
[root@test7 yum.repos.d]# yum install -y mariadb-server mariade
[root@test7 yum.repos.d]# systemctl restart mariadb.service
[root@test7 yum.repos.d]# mysql_secure_installation 
#设置密码一路Y就行
[root@test7 yum.repos.d]# mysql -u root -p123456
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
MariaDB [(none)]> flush privileges;
[root@test7 yum.repos.d]# rpm -ql zabbix-server-mysql 
[root@test7 yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql-5.0.42/create.sql.gz | mysql -u root -p123456 zabbix
​
[root@test7 yum.repos.d]# vim /etc/zabbix/zabbix_server.conf
  124 DBPassword=zabbix         #将124行取消注释,并加一个zabbix
[root@test7 yum.repos.d]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 
   25 php_value[date.timezone] = Asia/Shanghai
​
#重启
[root@test7 yum.repos.d]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
#设置为开机自启
[root@test7 yum.repos.d]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
​
#浏览器访问192.168.60.70/zabbix
​
#安装解决乱码的工具
[root@test7 zabbix]# yum install -y wqy-microhei-fonts
[root@test7 zabbix]# \cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
​
#服务端安装get
[root@test7 zabbix]# yum -y install zabbix-get
#查看get通不通,1就是通,0就是不通
[root@test7 zabbix]# zabbix_get -s '192.168.60.80' -p 10050 -k 'agent.ping'
  1
[root@test7 zabbix]# vim /etc/zabbix/zabbix_agentd.conf
 117 Server=192.168.60.70
 163 ServerActive=192.168.60.70
 174 Hostname=test7
[root@test7 zabbix]# systemctl restart zabbix-agent.service 
​

客户端 192.168.60.80 test8

[root@test8 ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm 
[root@test8 ~]# cd /etc/yum.repos.d/
[root@test8 yum.repos.d]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' zabbix.repo
[root@test8 yum.repos.d]# yum makecache 
[root@test8 yum.repos.d]# yum install -y zabbix-agent2
[root@test8 yum.repos.d]# vim /etc/zabbix/zabbix_agent2.conf
  80 Server=192.168.60.70
  125 ServerActive=192.168.60.70
  136 Hostname=test8
​
#重启
[root@test8 yum.repos.d]# systemctl restart zabbix-agent2.service 
#设置开机自启
[root@test8 yum.repos.d]# systemctl enable zabbix-agent2.service
​
[root@test8 yum.repos.d]# netstat -antp | grep 10050
tcp6       0      0 :::10050                :::*                    LISTEN      12569/zabbix_agent2 
​

ZBX:ZABBIX的缩写,默认模式,监控网络和设备,服务。大部分情况都是默认模式。

SNMP:simple network mangenment protocal 简单网络管理协议,用来管理和监控网络设备的协议。

JMX:专门监控java程序的

IPMI:管理服务器硬件,服务器的电源,温度,风扇速度等等

test8 客户端

#登录当前系统的不能超过3个,大于3个告警   发邮件
#显示当前主机数量
[root@test8 zabbix]# who | wc -l
2
[root@test8 zabbix]# vim /etc/zabbix/zabbix_agent2.conf
 273 Include=/etc/zabbix/zabbix_agent2.d/*.conf
 #这个路径就是来保存监控脚本的默认路径,文件名可以自定义,但是必须是以.conf结尾
[root@test8 zabbix_agent2.d]# vim user_login.conf
  UserParameter=login.user,who | wc -l
#重启
[root@test8 zabbix_agent2.d]# systemctl restart zabbix-agent2.service 
[root@test7 zabbix]#  zabbix_get -s '192.168.60.80' -p 10050 -k 'login.user'
2

test8

#安装一个nginx
[root@test8 zabbix_agent2.d]# vim /etc/nginx/nginx.conf
location /nginx_status {
                     stub_status on;
                     access_log off;
                      }
[root@test8 opt]# vim test-nginx.sh
#!/bin/bash
#Description:Automated monitoring nginx performance and process nginx_status scripts
 
HOST="localhost"
PORT=80
stub_status="stub_status"
NGINX_COMMAND=$1
 
nginx_check() {
    if [ -f /sbin/pidof ]; then
       /sbin/pidof nginx | wc -w
    else
       ps aux | grep -v "grep" | grep -c "nginx:"
    fi
}
 
nginx_active(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk '/Active/ {print $NF}'
}
 
nginx_reading(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk '/Reading/ {print $2}'
}
 
nginx_writing(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk '/Writing/ {print $4}'
}
 
nginx_waiting(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk '/Waiting/ {print $6}'
}
 
nginx_accepts(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk 'NR==3 {print $1}'
}
 
nginx_handled(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk 'NR==3 {print $2}'
}
 
nginx_requests(){
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2> /dev/null | awk 'NR==3 {print $3}'
}
 
case $NGINX_COMMAND in
    check)
        nginx_check
        ;;
    active)
        nginx_active
        ;;
    reading)
        nginx_reading
        ;;
    writing)
        nginx_writing
        ;;
    waiting)
        nginx_waiting
        ;;
    accepts)
        nginx_accepts
        ;;
    handled)
        nginx_handled
        ;;
    requests)
        nginx_requests
        ;;
    *)
        echo $"USAGE:$0 {check|active|reading|writing|waiting|accepts|handled|requests}"
esac
​
[root@test8 opt]# chmod 777 test-nginx.sh 
[root@test8 zabbix_agent2.d]# vim nginx_test.conf
UserParameter=nginx.status[*],/opt/test-nginx.sh $1
[root@test8 zabbix_agent2.d]# systemctl restart zabbix-agent2.service 
#服务端测试
[root@test7 yum.repos.d]# zabbix_get -s '192.168.65.44' -p 10050 -k 'nginx.status[check]'
5
[root@test8 zabbix_agent2.d]# systemctl stop nginx
#客户端的nginx挂了,测试返回码为0
[root@test7 yum.repos.d]# zabbix_get -s '192.168.65.44' -p 10050 -k 'nginx.status[check]'
0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值