浪人 发表于 2019-1-18 09:31:38

zabbix监控(一)概念与部署

1.1 为什么要监控
       http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttp://s1.运维网.com/images/20180316/1521202392988589.png
1.2 监控什么东西
  监控一切需要监控的东西,只要能够想到,能够用命令实现的都能用来监控
1.2.1 监控范畴
http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttp://s1.运维网.com/images/20180318/1521380316728358.png
1.3 怎么来监控
1.3.1 远程管理服务器
http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttp://s1.运维网.com/images/20180316/1521202418353533.png
  如果想远程管理服务器就有远程管理卡
1.3.2 监控硬件
  查看硬件的温度/风扇转速,电脑有鲁大师,服务器就有ipmitool。
  使用ipmitool实现对服务器的命令行远程管理
  yum -y install OpenIPMI ipmitool #->IPMI在物理机可以成功,虚拟机不行
   ~]# ipmitool sdr type Temperature
  Temp | 01h | ns | 3.1 | Disabled
  Temp | 02h | ns | 3.2 | Disabled
  Temp | 05h | ns | 10.1 | Disabled
  Temp | 06h | ns | 10.2 | Disabled
  Ambient Temp | 0Eh | ok | 7.1 | 22 degrees C
  Planar Temp | 0Fh | ns | 7.1 | Disabled
  IOH THERMTRIP | 5Dh | ns | 7.1 | Disabled
  CPU Temp Interf | 76h | ns | 7.1 | Disabled
  Temp | 0Ah | ns | 8.1 | Disabled
  Temp | 0Bh | ns | 8.1 | Disabled
  Temp | 0Ch | ns | 8.1 | Disabled
1.3.3 查看cpu相关
    lscpu、uptime、top、htop vmstat mpstat
     其中htop需要安装,安装依赖与epel源。
  ]$lscpu
  Architecture: x86_64
  CPU op-mode(s): 32-bit, 64-bit
  Byte Order: Little Endian
  CPU(s): 1
  On-line CPU(s) list: 0
  Thread(s) per core: 1
  Core(s) per socket: 1
  Socket(s): 1
  NUMA node(s): 1
  Vendor ID: GenuineIntel
  CPU family: 6
  Model: 85
  Model name: Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
  Stepping: 4
  CPU MHz: 2494.150
  BogoMIPS: 4988.30
  Hypervisor vendor: KVM
  Virtualization type: full
  L1d cache: 32K
  L1i cache: 32K
  L2 cache: 1024K
  L3 cache: 33792K
  NUMA node0 CPU(s): 0
1.3.4 内存够不够可以用
    free
  $free -h
  total used free shared buffers cached
  Mem: 996M 867M 128M 712K 145M 450M
  -/+ buffers/cache: 271M 725M
  Swap: 1.0G 0B 1.0G
1.3.5 磁盘剩多少写的快不快可以用
    df、dd、iotop
  $df -h
  Filesystem Size Used Avail Use% Mounted on
  /dev/vda1 40G 24G 15G 62% /
  tmpfs 499M 20K 499M 1% /dev/shm
  /dev/vdb1 20G 4.4G 15G 24% /data
1.3.6 监控网络
    iftop nethogs
  iftop 监控主机间流量 -i 指定监控网卡
  nethogs 监控进程流量
1.4 监控工具总览
    mrtg 流量监控出图
    nagios 监控
    cacti流量监控出图
    zabbix 监控+出图
1.5 zabbix介绍
    Zabbix 是由 Alexei Vladishev 开发的一种网络监视、管理系统,基于 Server-Client 架构。可用于监视各种网络服务、服务器和网络机器等状态。
    使用各种 Database-end 如 MySQL, PostgreSQL, SQLite, Oracle 或 IBM DB2 储存资料。Server 端基于 C语言、Web 管理端 frontend 则是基于 PHP 所制作的。Zabbix 可以使用多种方式监视。可以只使用 Simple Check 不需要安装 Client 端,亦可基于 SMTP 或 HTTP ... 各种协定做死活监视。
    在客户端如 UNIX, Windows 中安装 Zabbix Agent 之后,可监视 CPU Load、网络使用状况、硬盘容量等各种状态。而就算没有安装 Agent 在监视对象中,Zabbix 也可以经由 SNMP、TCP、ICMP、利用 IPMI、SSH、telnet 对目标进行监视。
  另外,Zabbix 包含 XMPP 等各种 Item 警示功能。
1.5.1 zabbix的组成
  http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gif
http://s1.运维网.com/images/20180318/1521380342151023.png
  zabbix官网: https://www.zabbix.com
  zabbix 主要由2部分构成 zabbix server和 zabbix agent
  zabbix proxy是用来管理其他的agent,作为代理为服务端减轻压力
1.5.2 zabbix监控范畴
    ²硬件监控 :Zabbix IPMI Interface
    ²系统监控 :Zabbix Agent Interface
    ²Java 监控:Zabbix JMX Interface
    ²网络设备监控:Zabbix SNMP Interface
    ²应用服务监控:Zabbix Agent UserParameter
    ²MySQL 数据库监控:percona-monitoring-pldlgins
    ²URL监控:Zabbix Web监控
第2章 安装zabbix
2.1 环境检查
  # cat /etc/redhat-release
  CentOS Linux release 7.4.1708 (Core)
   ~]# uname -r
  3.10.0-693.el7.x86_64
   ~]# getenforceDisabled
   ~]# systemctl status firewalld.service
  ● firewalld.service - firewalld - dynamic firewall daemon
  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
  Active: inactive (dead)
  Docs: man:firewalld(1)
2.2 安装zabbix过程
这里采用zabbix3.0版本,相对稳定并长期支持,目前官方最新版本3.4
2.2.1 安装Zabbix服务端(下面脚本中已包括)
  1.安装Zabbix官方源
  rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
  2.安装zabbix,httpd,php
  yum install zabbix-server-mysql zabbix-web-mysql -y
2.2.2 服务端快速安装脚本
  #!/bin/bash
  #clsn
  #设置解析 注意:网络条件较好时,可以不用自建yum源
  # echo '192.168.16.200 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com' >> /etc/hosts
  #安装zabbix源、aliyun YUM源
  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
  #安装zabbix服务端和web页面
  yum install -y zabbix-server-mysql zabbix-web-mysql
  #安装启动 mariadb数据库
  yum install -y mariadb-server
  systemctl start mariadb.service
  #创建数据库
  mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
  mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'
  #导入数据(mysql -u用户 -p密码 数据库名称,如没有密码不加-p)
  zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz|mysql -uzabbix -pzabbix zabbix
  #配置zabbixserver连接mysql
  sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
  #添加时区(亚洲/上海)
  sed -i.ori '18a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
  #解决中文乱码
  yum -y install wqy-microhei-fonts
  \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
  #启动服务
  systemctl start zabbix-server
  systemctl start httpd
  #写入开机自启动
  chmod +x /etc/rc.d/rc.local
  cat >>/etc/rc.d/rc.local /etc/hosts
  #安装zabbix源、aliyu nYUM源
  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
  #安装zabbix客户端(指定zabbix服务端)
  yum install zabbix-agent -y
  sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.62#' /etc/zabbix/zabbix_agentd.conf
  systemctl start zabbix-agent.service
  #写入开机自启动
  chmod +x /etc/rc.d/rc.local
  cat >>/etc/rc.d/rc.local
页: [1]
查看完整版本: zabbix监控(一)概念与部署