hx0011yy 发表于 2019-1-18 10:44:20

zabbix3.0监控详解


第1章 前言
1.1 我们的职责
  1.    保障企业数据的安全可靠。
  2.    为客户提供7*24小时服务。
  3.    不断提升用户的体验。
  http://blog.csdn.net/pan_tian/article/details/23270119
  网站可用性
所谓网站可用性(availability)也即网站正常运行时间的百分比,业界用 N 个9 来量化可用性, 最常说的就是类似 “4个9(也就是99.99%)” 的可用性。
  描述    通俗叫法    可用性级别年度停机时间
  基本可用性2个9   99% 87.6小时
  较高可用性3个9   99.9%   8.8小时
  具有故障自动恢复能力的可用性    4个9   99.99%53分钟
  极高可用性5个9   99.999% 5分钟
1.2 通过命令监控服务器
  如果想远程管理服务器就有远程管理卡,比如Dell idRAC,HP ILO,IBM IMM
  查看硬件的温度/风扇转速,电脑有撸大师,服务器就有ipmitool。使用ipmitool实现对服务器的命令行远程管理
  查看硬件的温度/风扇转速,电脑有撸大师,服务器就有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 | Disabled1.2.1 查看cpu的信息
# lscpu
Architecture:          x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             2
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:               78
Model name:            Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Stepping:            3
CPU MHz:               2400.001
BogoMIPS:            4800.00
Hypervisor vendor:   VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:            256K
L3 cache:            3072K
NUMA node0 CPU(s):   0,1
#1.2.2 查看系统负载
# uptime
03:17:33 up1:03,2 users,load average: 0.18, 0.05, 0.01
当前系统时间up 运行时间 2users登录的用户数 平均负载 1,5,15minutes  

  最佳负载:过去一分钟的平均负载等于CPU的核数(或者两倍)
  怎么判断服务器的负载过高:就是看你的过去1分钟的平均负载是否超过CPU的核数(或者2倍)
1.2.3 top实时动态
top - 03:27:14 up1:13,2 users,load average: 0.00, 0.02, 0.00
#第一行和uptime一样
Tasks:90 total,   1 running,89 sleeping,   0 stopped,   0 zombie
#第二行 显示当前进程统计信息
Cpu(s):0.0%us,0.2%sy,0.0%ni, 99.8%id,0.0%wa,0.0%hi,0.0%si,#第三行 CPU的统计信息0.0%us,用户使用的cpu百分比 0.2%sy,系统使用CPU百分比 %id空闲的CPU百分比
Mem:   1004112k total,   395132k used,   608980k free,    26712k buffer #第四行:内存的统计信息
Swap:   786428k total,      0k used,   786428k free,   256904k cached
#第五行:swap统计信息
   PID USER      PRNIVIRTRESSHR S %CPU %MEM    TIME+COMMAND
   1 root      20   0 19352 1528 1228 S0.00.2   0:01.70 init   
   2 root      20   0   0    0    0 S0.00.0   0:00.00 kthreadd
   3 root      RT   0   0    0    0 S0.00.0   0:00.87 migration/
   4 root      20   0   0    0    0 S0.00.0   0:00.01 ksoftirqd/
   5 root      RT   0   0    0    0 S0.00.0   0:00.00 stopper/0
   6 root      RT   0   0    0    0 S0.00.0   0:00.00 watchdog/0
   7 root      RT   0   0    0    0 S0.00.0   0:00.53 migration/
   8 root      RT   0   0    0    0 S0.00.0   0:00.00 stopper/1
   9 root      20   0   0    0    0 S0.00.0   0:00.00 ksoftirqd/ 快捷键 z 加颜色 x高亮显示 > 向右> /etc/hosts
wget -O /etc/yum.repos.d/CentOS-Base.repo http://192.168.12.200/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://192.168.12.200/repo/epel-6.repo
yum clean all
yum -y install htophttp://s1.运维网.com/images/20171226/1514286258382478.png
1.2.6 显示磁盘信息
# df -h
Filesystem      SizeUsed Avail Use% Mounted on
/dev/sda3       8.8G1.1G7.4G13% /
tmpfs         491M   0491M   0% /dev/shm
/dev/sda1       190M   35M146M19% /boot
#
# dd if=/dev/zero of=tese.data bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.0389443 s, 269 MB/s
# if input file输入文件 /dev/zero 这是系统的特殊设备,能够源源不断的产生0字符流 ofoutput file 输出设备
bs block size 块大小
count block 快的数量 总结:产生的test.data文件大小 bs * count 经验:最佳测试磁盘写的速度的测试文件1.2.7 iotop实时查看系统io(输入输出)负载
Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s
TIDPRIOUSER   DISK READDISK WRITESWAPIN      IO   COMMAND<
1308 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 % -bash
2488 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 % -bash
   50 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   51 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   22 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   33 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   34 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   35 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   25 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
773 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   19 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   52 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   53 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 %
   66 be/4 root      0.00 B/s    0.00 B/s0.00 %0.00 % 1.2.8 网络太卡找iftop nethogs
yum -y install iftop nethogs
iftop:查看网卡流量(默认监控网卡eth0)
# iftop
interface: eth0
IP address is: 10.0.0.61
MAC address is: 00:0c:29:ab:6f:34
            12.5Kb         25.0Kb      37.5Kb         50.0Kb   62.5Kb
└─────────────┴──────────────┴─────────────┴──────────────┴──────────────
10.0.0.61            => 10.0.0.253               992b   1.17Kb1.50Kb
                        10.0.0.253               0b      0b      0b
                        public1.alidns.com         0b   55b   91b
                     >/etc/httpd/conf/httpd.conf
      /etc/init.d/httpd start
      /etc/init.d/zabbix-server start
    服务开机启动顺序:必须先启动mysql,然后启动zabbix server
    # tail -4 /etc/rc.local
    /etc/init.d/mysqld start
    /etc/init.d/zabbix-server start
    /etc/init.d/httpd start
    /etc/init.d/zabbix-agent start
    # tail -1 /etc/rc.local
    /etc/init.d/zabbix-agent start3.2 zabbix客户端
客户端服务端都需要安装agent程序
      rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.9-1.el6.x86_64.rpm
客户端配置
    修改配置文件
    sed -i 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf
    启动agent
    /etc/init.d/zabbix-agent start
    在服务端执行检查命令
    # zabbix_get -s 172.16.1.61 -p 10050 -k &quot;system.cpu.load&quot;
    0.000000
    # zabbix_get -s 172.16.1.8 -p 10050 -k &quot;system.cpu.load&quot;
    0.000000   
总结图示  

http://s1.运维网.com/images/20171226/1514286401395701.png
3.3 网页进行安装
第一步:
http://10.0.0.61/zabbix/setup.phphttp://s1.运维网.com/images/20171226/1514286426716315.png
  第二步:点击下一步
  http://s1.运维网.com/images/20171226/1514286463438127.png
  第三步:点击下一步
  http://s1.运维网.com/images/20171226/1514286474307625.png
  第四步:点击下一步
  http://s1.运维网.com/images/20171226/1514286492734174.png
  第五步
  http://s1.运维网.com/images/20171226/1514286502717960.png
  第六步:点击完成
  http://s1.运维网.com/images/20171226/1514286511649341.png
  第七步:点击完成后安装结束
  设置中文显示中文界面
http://s1.运维网.com/images/20171226/1514286524629104.png
  最后界面就是中文的界面了。
http://s1.运维网.com/images/20171226/1514286556358220.png
3.4 添加监控主机
  主机名称:zabbix程序识别用的名字
  可见的名称:给人看,显示在网页上的
  群组:同学(主机)与小组(群组)方便管理
agent代理程序的接口
  agent代理程序的接口:指定客户端IP地址
http://s1.运维网.com/images/20171226/1514286593235576.png
http://s1.运维网.com/images/20171226/1514286605699812.png
  检查客户端是否被监控的命令
# zabbix_get -s 172.16.1.61 -p 10050 -k &quot;system.cpu.load&quot;
0.090000
# zabbix_get -s 172.16.1.8 -p 10050 -k &quot;system.cpu.load&quot;
0.000000
#3.5 添加监控主机模板
http://s1.运维网.com/images/20171226/1514286623141170.png
3.6 查看最新数据
  监控出现图形了,但是可能会出现乱码
解决中文乱码
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
    yum -y install wqy-microhei-fonts
    \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttfhttp://s1.运维网.com/images/20171226/1514286649293605.png
第4章 zabbix自定义监控
4.1 被监控主机修改配置文件
web01客户端执行
# sed -i '293a UserParameter=login-user,who|wc -l' /etc/zabbix/zabbix_agentd.conf # /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                              
Starting Zabbix agent:                                    
#
服务端操作
# zabbix_get -s 172.16.1.8 -p 10050 -k &quot;login-user&quot;
1
#4.2 网页上添加自定义监控
4.2.1 添加模板
  模板的功能:一处创建,处处使用
http://s1.运维网.com/images/20171226/1514286686836108.png
http://s1.运维网.com/images/20171226/1514286694383395.png
4.2.2 添加应用集:一个目录,统一存放具有相关性的监控项
  http://s1.运维网.com/images/20171226/1514286722853554.png
  http://s1.运维网.com/images/20171226/1514286728164800.png
  http://s1.运维网.com/images/20171226/1514286738732974.png
4.2.3 添加监控项
  告诉服务端server你该去哪里获取什么方面数据
http://s1.运维网.com/images/20171226/1514286789928149.png
http://s1.运维网.com/images/20171226/1514286794826738.png
http://s1.运维网.com/images/20171226/1514286802761975.png
4.2.4 添加触发器
  需要报警的监控项设置触发器
  严重性:
²警告级别的报警发给初级运维
²一般严重级别的报警发给初级运维,中级运维
²严重级别的报警发给初级运维,中级运维,高级运维
²灾难级别的报警发给初级运维,中级运维,高级运维,总监
http://s1.运维网.com/images/20171226/1514286871963474.png
http://s1.运维网.com/images/20171226/1514286878454252.png
http://s1.运维网.com/images/20171226/1514286887325123.png
http://s1.运维网.com/images/20171226/1514286895189494.png
http://s1.运维网.com/images/20171226/1514286902344355.png
4.2.5 添加图形
http://s1.运维网.com/images/20171226/1514286922678925.png
http://s1.运维网.com/images/20171226/1514286929553714.png
http://s1.运维网.com/images/20171226/1514286936761885.png
http://s1.运维网.com/images/20171226/1514286943497715.png
4.2.6 使用模板
http://s1.运维网.com/images/20171226/1514286957729585.png
http://s1.运维网.com/images/20171226/1514286965990973.png
第5章 报警
5.1 报警种类
  邮件报警:存在收不到的风险
  微信报警:通知及时
  短信报警:不依赖网络
  电话报警:有信号就可以报警
  APP报警
5.2 安装报警客户端
2安装 Agent
1.切换到zabbix脚本目录(如何查看zabbix脚本目录):
vi /etc/zabbix/zabbix_server.conf
查看AlertScriptsPath
cd /usr/lib/zabbix/alertscripts/
2.获取OneITSM agent包:
wget http://www.iyunv.com/agent/release/oneitsm_zabbix_release-1.0.0.tar.gz tar -zxf oneitsm_zabbix_release-1.0.0.tar.gz
cd oneitsm/bin
bash install.sh 7145112f-7f7a-8cfb-cd26-810036d6d479 start to create config file...
Zabbix管理地址: 10.0.0.61/zabbix
Zabbix管理员账号: Admin
Zabbix管理员密码:
start to auth by zabbix admin user and password...
% Total    % Received % XferdAverage Speed   Time    Time   TimeCurrent
                                 DloadUpload   Total   Spent    LeftSpeed
0    70    0    70    0   125    847   1514 --:--:-- --:--:-- --:--:--   0
auth success!
start to create mediatype...
% Total    % Received % XferdAverage Speed   Time    Time   TimeCurrent
                                 DloadUpload   Total   Spent    LeftSpeed
397   130130   130    0   267   2706   5559 --:--:-- --:--:-- --:--:--   0
media type resonse:{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;error&quot;:{&quot;code&quot;:-32602,&quot;message&quot;:&quot;Invalid params.&quot;,&quot;data&quot;:&quot;Media type \&quot;oneitsm media\&quot; already exists.&quot;},&quot;id&quot;:1}
create media type failed! error message:{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;error&quot;:{&quot;code&quot;:-32602,&quot;message&quot;:&quot;Invalid params.&quot;,&quot;data&quot;:&quot;Media type \&quot;oneitsm media\&quot; already exists.&quot;},&quot;id&quot;:1}
#http://s1.运维网.com/images/20171226/1514286986418653.png
第6章 监控可视化
6.1 聚合图形
  聚合图形:将同一类型的监控放在一起看,容易对比分析
http://s1.运维网.com/images/20171226/1514287002545442.png
http://s1.运维网.com/images/20171226/1514287010458946.png
http://s1.运维网.com/images/20171226/1514287021412252.png
http://s1.运维网.com/images/20171226/1514287032999153.png
http://s1.运维网.com/images/20171226/1514287038391825.png

6.2 幻灯片演示
幻灯片:轮流播放聚合图形
       . 模板的共享
       https://github.com/zhangyao8/zabbix-community-repos
       https://share.zabbix.com/http://s1.运维网.com/images/20171226/1514287072777146.png
http://s1.运维网.com/images/20171226/1514287080104185.png
第7章 应用服务监控
7.1 监控rsync服务端口
1.      创建一个监控认识有哪些服务端口的模板
http://s1.运维网.com/images/20171226/1514287105350294.png
http://s1.运维网.com/images/20171226/1514287113729805.png
2.      添加一个应用集
http://s1.运维网.com/images/20171226/1514287121376103.png
http://s1.运维网.com/images/20171226/1514287128874971.png
3.      新建一个监控项
http://s1.运维网.com/images/20171226/1514287137297639.png
4.      添加触发器
http://s1.运维网.com/images/20171226/1514287146407939.png
http://s1.运维网.com/images/20171226/1514287153967926.png
7.2 监控NFS服务器,使用监控NFS进程来判断NFS服务器正常
  
怎么监控进程?
      proc.num[,,,]   进程数。返回整数
      zabbix_get -s 172.16.1.8 -p 10050 -k 'proc.num'
# zabbix_get -s 172.16.1.31 -p 10050 -k &quot;proc.num&quot;
8
#  怎么监控端口?
      net.tcp.listen    检查 TCP 端口 是否处于侦听状态。返回 0 - 未侦听;1 - 正在侦听
      net.tcp.port[,port] 检查是否能建立 TCP 连接到指定端口。返回 0 - 不能连接;1 - 可以连接 # zabbix_get -s 172.16.1.8 -p 10050 -k 'net.tcp.port[,80]'
      1
      # zabbix_get -s 172.16.1.8 -p 10050 -k 'net.tcp.port[,873]'
      1
      # zabbix_get -s 172.16.1.8 -p 10050 -k 'net.tcp.port'
      ZBX_NOTSUPPORTED: Invalid second parameter.7.3 监控3台web服务器
网页创建模板进行监控80端口
三个web服务器中进行web检测
写脚本
# cat/server/scripts/nginx_check.sh
char=`curl -s http://10.0.0.8/test.html`
[ &quot;$char&quot; == &quot;oldboy&quot; ] && echo 1 ||echo 0
#
写模板文件
# cat/etc/zabbix/zabbix_agentd.d/userparameter_nginx.conf
UserParameter=nginx_check,/bin/sh /server/scripts/nginx_check.sh
#
重启客户端
# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                              
Starting Zabbix agent:                                    
监控机进行测试
# zabbix_get -s 172.16.1.8 -p 10050 -k &quot;nginx_check&quot;
1
# zabbix_get -s 172.16.1.7 -p 10050 -k &quot;nginx_check&quot;
1
# zabbix_get -s 172.16.1.9 -p 10050 -k &quot;nginx_check&quot;
1
#
# zabbix_get -s 172.16.1.7 -p 10050 -k &quot;nginx_check&quot;
0#0是不正常1是正常
#7.4 监控mysql
  如何排查自定义监控报错:
UserParameter=key,shell command
1. 现在命令行测试你的shell command的结果和你的期望是否一致
# mysqladmin -uroot -poldboy123 ping 2>/dev/null|grep -c alive
1
2. 将符合预期的shell command写入到我们的自定义监控文件中
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
改为
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin -uroot -poldboy123 ping 2>/dev/null|grep -c alive
3. 改完配置文件记住重启生效
4. 在服务端用zabbix_get命令
# tail -2 userparameter_mysql.conf
UserParameter=mysql.ping,/application/mysql/bin/mysqladmin -uroot -p123456ping 2>/dev/null | grep -c alive
UserParameter=mysql.version,mysql -V
重启
# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                              
Starting Zabbix agent:                                    
服务端测试
# zabbix_get -s 172.16.1.51 -p 10050 -k 'mysql.ping'
0#发现mysql命令找不到 在客户端模板配置文件里面命令使用绝对路径
# zabbix_get -s 172.16.1.51 -p 10050 -k 'mysql.ping'
1
#7.5 监控URL地址来更精确的监控我们的网站运行正常
http://s1.运维网.com/images/20171226/1514287231337880.png
http://s1.运维网.com/images/20171226/1514287238688696.png
http://s1.运维网.com/images/20171226/1514287245409957.png
http://s1.运维网.com/images/20171226/1514287251304639.png
http://s1.运维网.com/images/20171226/1514287259422917.png
  最后在监测中查看web监测
http://s1.运维网.com/images/20171226/1514287276283715.png
7.6 监控Nginx的7种连接状态
修改配置加入server标签
# cat /application/nginx/conf/nginx.conf
worker_processes1;
events {
    worker_connections1024;
}
http {
    include       mime.types;
    default_typeapplication/octet-stream;
    sendfile      on;
    keepalive_timeout65;
######status#########
    server {
      listen       127.0.0.1:80;
            stub_status on;
            access_log off;
      }
server {
      listen       10.0.0.9;
      location / {
            root   html;
            indexindex.html index.htm;
                   }
      }
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
}
重启服务
检查状态
# curl 127.0.0.1/nginx_status
Active connections: 1
server accepts handled requests
8 8 8
Reading: 0 Writing: 1 Waiting: 0
#
# cat >> /etc/zabbix/zabbix_agentd.d/userparameter_nginx_status.confUserParameter=nginx_accepts,curl -s127.0.0.1/nginx_status|awk 'NR==3 {print $1}'
> UserParameter=nginx_handled,curl -s127.0.0.1/nginx_status|awk 'NR==3 {print $2}'
> UserParameter=nginx_requests,curl -s127.0.0.1/nginx_status|awk 'NR==3 {print $3}'
> UserParameter=nginx_reading,curl -s127.0.0.1/nginx_status|awk 'NR==4 {print $2}'
> UserParameter=nginx_writing,curl -s127.0.0.1/nginx_status|awk 'NR==4 {print $4}'
> UserParameter=nginx_waiting,curl -s127.0.0.1/nginx_status|awk 'NR==4 {print $6}'
> END
# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                              
Starting Zabbix agent:                                    
#
服务端测试
# zabbix_get -s 172.16.1.8-p 10050 -k &quot;nginx_waiting&quot;
Reading: 0 Writing: 1 Waiting: 0
# zabbix_get -s 172.16.1.8-p 10050 -k &quot;nginx_accepts&quot;
58 58 58
#
网页进行自定义监控http://s1.运维网.com/images/20171226/1514287319898878.png
http://s1.运维网.com/images/20171226/1514287327333334.png
http://s1.运维网.com/images/20171226/1514287336155671.png
http://s1.运维网.com/images/20171226/1514287343615456.png
http://s1.运维网.com/images/20171226/1514287351516919.png
http://s1.运维网.com/images/20171226/1514287358609188.png
  

第8章 自动发现和自动注册
8.1 自动发现:服务端发现客户端
  服务端自动发现局域网中所有的客户端agent(主动模式)
优点:方便找到所有的客户端,不会遗漏
  缺点:一旦agent过多,server压力很大,每隔一段时间server会扫描一次局域网中的所有机器
http://s1.运维网.com/images/20171226/1514287376735783.png
http://s1.运维网.com/images/20171226/1514287386276329.png
http://s1.运维网.com/images/20171226/1514287392872636.png
http://s1.运维网.com/images/20171226/1514287398229529.png
http://s1.运维网.com/images/20171226/1514287407175662.png
http://s1.运维网.com/images/20171226/1514287414210240.png
http://s1.运维网.com/images/20171226/1514287421405642.png
http://s1.运维网.com/images/20171226/1514287429715100.png
8.2 自动注册:客户端主动到服务端登记信息
  所有的客户端agent主动去服务端server登记注册(小弟上门求收留)被动模式
  优点:对服务端的压力最低。
  缺点:配置过程稍微复杂
  应用场景:当自动发现时,server端压力过大时,用自动注册
修改配置文件
# sed -i 's#Hostname=Zabbix server#Hostname=web03#' /etc/zabbix/zabbix_agentd.conf
# sed -i 's#ServerActive=127.0.0.1#ServerActive=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf #sed -i '176a HostMetadataItem=system.uname' /etc/zabbix/zabbix_agentd.conf
重启
# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                              
Starting Zabbix agent:                                    
#http://s1.运维网.com/images/20171226/1514287468112647.png
http://s1.运维网.com/images/20171226/1514287475775382.png
http://s1.运维网.com/images/20171226/1514287482611883.png
http://s1.运维网.com/images/20171226/1514287489875649.png
http://s1.运维网.com/images/20171226/1514287496714138.png
http://s1.运维网.com/images/20171226/1514287504604686.png
http://s1.运维网.com/images/20171226/1514287512546944.png
http://s1.运维网.com/images/20171226/1514287518262372.png
http://s1.运维网.com/images/20171226/1514287524440994.png
  第9章 分布式监控
  默认只能监控同一个局域网的机器
  一台sever的监控主机数量是有限的
  功能:
能够减轻服务端的压力
zabbix server 只能在同一个局域网中监控
9.1 常规安装部署
9.1.1 在客户端进行下载安装
# wget http://192.168.12.200/zabbix/zabbix-proxy-mysql-3.0.9-1.el6.x86_64.rpm
echo &quot;192.168.12.200 mirrors.aliyun.com&quot; >> /etc/hosts
wget -O /etc/yum.repos.d/CentOS-Base.repo http://192.168.12.200/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://192.168.12.200/repo/epel-6.repo
yum clean allyum -ylocalinstall zabbix-proxy-mysql-3.0.9-1.el6.x86_64.rpm9.1.2 安装配置数据库
zabbix proxy需要数据库存储相关配置,但不存储监控数据
生产环境:在proxy
1
mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.06 sec)
mysql> grant all privileges on zabbix_proxy.* to zabbix@'172.16.1.%' identified by 'zabbix';
Query OK, 0 rows affected (0.15 sec)
mysql>9.1.3 导入sql文件
web客户端传文件到服务端
scp /usr/share/doc/zabbix-proxy-mysql-3.0.9/schema.sql.gz 10.0.0.61:/server/
m01导入文件
zcat /server/schema.sql.gz |mysql -uroot   zabbix_proxy9.1.4 配置文件修改
vim /etc/zabbix/zabbix_proxy.conf
Server=10.0.0.61
Hostname=web01
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix DBHost=172.16.1.619.1.5 启动并检查日志
# /etc/init.d/zabbix-proxy start
Starting Zabbix proxy:                                    
# tailf /var/log/zabbix/zabbix_proxy.log
39637:20171013:113558.590 cannot send heartbeat message to server at &quot;172.16.1.61&quot;: proxy &quot;web01&quot; not found
39651:20171013:113558.608 proxy #16 started
39652:20171013:113558.618 proxy #17 started
39654:20171013:113558.619 proxy #19 started
39650:20171013:113558.621 proxy #15 started
39653:20171013:113558.621 proxy #18 started
39655:20171013:113558.626 proxy #20 started
39658:20171013:113558.639 proxy #23 started
39657:20171013:113558.642 proxy #22 started
39656:20171013:113558.648 proxy #21 started 9.1.6 配置zabbix agent
# sed -i 's#172.16.1.61#172.16.1.8#g' /etc/zabbix/zabbix_agentd.conf
# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                              
Starting Zabbix agent:                                    
#9.2 开始网页操作部署
  将代理节点注册到zabbix server中
http://s1.运维网.com/images/20171226/1514287600450312.png
http://s1.运维网.com/images/20171226/1514287607260345.png
http://s1.运维网.com/images/20171226/1514287614541315.png
http://s1.运维网.com/images/20171226/1514287621655434.png
http://s1.运维网.com/images/20171226/1514287629502163.png
第10章 snmp监控(交换机监控)
  能用zabbix agent:系统能够安装zabbix软件的时候用,交换机打印机等智能设备不能使用zabbix程序。
  SNMP是专用来设备监控
  优点:软件小巧,所以设备都可以安装使用
  缺点:支持功能少
  生产环境建议:先安装使用agent,若不能安装则使用SNMP。
10.1 在Linux系统安装启动服务
# rpm -qa |grep snmp
net-snmp-5.5-60.el6.x86_64
net-snmp-utils-5.5-60.el6.x86_64
net-snmp-libs-5.5-60.el6.x86_64
#
没有就安装
    yum -y install net-snmp net-snmp-utils
配置snmp
# sed -i.ori '57a view systemview   included.1' /etc/snmp/snmpd.conf
# # /etc/init.d/snmpd start
Starting snmpd:                                          
#
使用
# snmpwalk -v 2c -c public 127.0.0.1 sysname
SNMPv2-MIB::sysName.0 = STRING: m01
# # snmpwalk -v 2c -c public 127.0.0.1 sysContact
SNMPv2-MIB::sysContact.0 = STRING: Root(configure /etc/snmp/snmp.local.conf)
# snmpwalk -v 2c -c public 127.0.0.1 SysService
SNMPv2-MIB::sysServices = No Such Instance currently exists at this OID
# snmpwalk -v 2c -c public 127.0.0.1 hrSWRunName
HOST-RESOURCES-MIB::hrSWRunName.1 = STRING: &quot;init&quot;
HOST-RESOURCES-MIB::hrSWRunName.2 = STRING: &quot;kthreadd&quot;
HOST-RESOURCES-MIB::hrSWRunName.3 = STRING: &quot;migration/0&quot;
HOST-RESOURCES-MIB::hrSWRunName.4 = STRING: &quot;ksoftirqd/0&quot;
HOST-RESOURCES-MIB::hrSWRunName.5 = STRING: &quot;stopper/0&quot; 说明: http://www.ttlsa.com/monitor/snmp-oid/10.2 在网页上配置使用
http://s1.运维网.com/images/20171226/1514287690607708.png
http://s1.运维网.com/images/20171226/1514287698234629.png
http://s1.运维网.com/images/20171226/1514287706862429.png
http://s1.运维网.com/images/20171226/1514287713769821.png



页: [1]
查看完整版本: zabbix3.0监控详解