05.27 zabbix服务系统监控
来源:互联网 发布:恋爱的双马尾 知乎 编辑:程序博客网 时间:2024/05/17 21:40
第一章 网站可用性
所谓网站可用性(availability)也即网站正常运行时间的百分比,业界用N个9来量化可用性,最常说的就是类似4个9(也就是99.99%)的可用性。
第二章 服务器的硬件监控
- 【温度】
- 【风扇转速】
- 【电压电流】
- 【远程管理卡】
- 【ipmitools】命令监控
yum -y install OpenIPMI ipmitool[root@KVM ~]# ipmitool sdr type TemperatureTemp | 01h | ns | 3.1 | DisabledTemp | 02h | ns | 3.2 | DisabledTemp | 05h | ns | 10.1 | DisabledTemp | 06h | ns | 10.2 | DisabledAmbient Temp | 0Eh | ok | 7.1 | 22 degrees CPlanar Temp | 0Fh | ns | 7.1 | DisabledIOH THERMTRIP | 5Dh | ns | 7.1 | DisabledCPU Temp Interf | 76h | ns | 7.1 | DisabledTemp | 0Ah | ns | 8.1 | DisabledTemp | 0Bh | ns | 8.1 | DisabledTemp | 0Ch | ns | 8.1 | Disabled
第三章 系统监控
1. CPU监控
【lscpu】查看cpu信息[root@ansible01-61 ~]# lscpu Architecture: x86_64CPU op-mode(s): 32-bit, 64-bitByte Order: Little EndianCPU(s): 1On-line CPU(s) list: 0Thread(s) per core: 1Core(s) per socket: 1Socket(s): 1NUMA node(s): 1Vendor ID: GenuineIntel【uptime】查看系统负载[root@m01 ~]# uptime09:23:50 up 33 min, 1 user, load average: 0.00, 0.01, 0.03【top】查看系统运行情况top - 19:21:07 up 36 min, 1 user, load average: 0.00, 0.01, 0.05Tasks: 92 total, 1 running, 91 sleeping, 0 stopped, 0 zombie%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stKiB Mem : 999936 total, 588488 free, 98748 used, 312700 buff/cacheKiB Swap: 1048572 total, 1048572 free, 0 used. 731792 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 125396 3960 2408 S 0.0 0.4 0:01.41 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.10 ksoftirqd/0 4 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0 6 root 20 0 0 0 0 S 0.0 0.0 0:00.13 kworker/u256:0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 0:00.30 rcu_sched 10 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0 12 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper 13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs 14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns 15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback 【htop】top升级版[root@ansible01-61 ~]# htop CPU[|| 1.2%] Tasks: 28, 35 thr; 1 running Mem[||||||||||||||||||||||||||||||||||||||||| 127M/976M] Load average: 0.00 0.01 0.05 Swp[ 0K/1024M] Uptime: 00:47:36 PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command 1415 root 20 0 540M 16436 5784 S 0.0 1.6 0:00.00 /usr/bin/python -Es /usr/sbin/tuned -l -P 1418 root 20 0 540M 16436 5784 S 0.0 1.6 0:00.00 /usr/bin/python -Es /usr/sbin/tuned -l -P 1420 root 20 0 540M 16436 5784 S 0.0 1.6 0:00.34 /usr/bin/python -Es /usr/sbin/tuned -l -P 1425 root 20 0 540M 16436 5784 S 0.0 1.6 0:00.00 /usr/bin/python -Es /usr/sbin/tuned -l -P 1215 root 20 0 540M 16436 5784 S 0.0 1.6 0:00.51 /usr/bin/python -Es /usr/sbin/tuned -l -P
2. 内存监控
【free -h】[root@ansible01-61 ~]# free -h total used free shared buff/cache availableMem: 976M 96M 574M 6.7M 305M 714MSwap: 1.0G 0B 1.0G
3. 磁盘监控
【df -h】[root@ansible01-61 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 48G 1.8G 47G 4% /devtmpfs 479M 0 479M 0% /devtmpfs 489M 0 489M 0% /dev/shmtmpfs 489M 6.7M 482M 2% /runtmpfs 489M 0 489M 0% /sys/fs/cgroup/dev/sda1 1014M 133M 882M 14% /boottmpfs 98M 0 98M 0% /run/user/0【dd】测试写速度[root@m01 ~]# dd if=/dev/zero of=test.data bs=100M count=22+0 records in2+0 records out209715200 bytes (210 MB) copied, 0.99772 s, 210 MB/s【hdparm -t /dev/sda】测试读速度[root@ansible01-61 ~]# hdparm -t /dev/sda1/dev/sda1: Timing buffered disk reads: 1024 MB in 1.44 seconds = 710.31 MB/sec【iotop】[root@ansible01-61 ~]# iotop Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/sActual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % systemd --switched-root --system --deserialize 21 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd] 3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0] 4 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/0:0] 6 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u256:0]
5. 网络监控
【iftop】实时显示网卡流量[root@m01 ~]# iftop -i eth0【nethogs】[root@m01 ~]# yum -y install iftop nethogs
6. TCP监控
【ss/netstat】[root@ansible01-61 ~]# ss -antState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:111 *:* LISTEN 0 128 *:22 *:* 【lsof】
7. 进程监控
[root@ansible01-61 ~]# ps -efUID PID PPID C STIME TTY TIME CMDroot 1 0 0 18:44 ? 00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 21root 2 0 0 18:44 ? 00:00:00 [kthreadd]root 3 2 0 18:44 ? 00:00:00 [ksoftirqd/0]root 4 2 0 18:44 ? 00:00:00 [kworker/0:0]
8. 服务监控
第四章 一切皆可监控
第五章 zabbix监控工具服务端安装
1. 安装zabbix源和依赖包
axel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-get-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-java-gateway-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-proxy-mysql-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-proxy-pgsql-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-sender-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-server-mysql-3.2.1-1.el7.x86_64.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-web-3.2.1-1.el7.noarch.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-web-japanese-3.2.1-1.el7.noarch.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-web-mysql-3.2.1-1.el7.noarch.rpmaxel http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-web-pgsql-3.2.1-1.el7.noarch.rpmyum install zabbix-agent-3.2.1-1.el7.x86_64.rpm zabbix-get-3.2.1-1.el7.x86_64.rpm zabbix-java-gateway-3.2.1-1.el7.x86_64.rpm zabbix-proxy-mysql-3.2.1-1.el7.x86_64.rpm zabbix-sender-3.2.1-1.el7.x86_64.rpm zabbix-server-mysql-3.2.1-1.el7.x86_64.rpm zabbix-web-3.2.1-1.el7.noarch.rpm zabbix-web-japanese-3.2.1-1.el7.noarch.rpm zabbix-web-mysql-3.2.1-1.el7.noarch.rpm yum install -y httpd mariadb
编译安装(可忽略)
编译安装zabbix
同时安装server和agent,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –with-ssh2如果仅安装server,并支持将数据放入MySQL数据中,可使用类似如下配置命令;
./configure –enable-server –with-mysql –with-net-snmp –with-libcurl如果仅安装proxy,并支持将数据放入MySQL数据中,可使用类似如下配置命令;
./configure –prefix=/usr –enable-proxy –with-net-snmp –with-mysql –with-ssh2如果仅安装agent,可使用类似如下配置命令;
./configure –enable-agent而后编译安装zabbix即可;
#make && make install
2. 配置MySQL
/etc/init.d/mysqld startmysql -uroot -e"create database zabbix character set utf8 collate utf8_bin;"mysql -e "grant all on zabbix.* to 'zbxuser'@'localhost' identified by 'zbxpass';"mysql -e "flush privileges;"
3. 导入数据到MySQL
zcat create.sql.gz |mysql -uzbxuser -pzbxpass zabbix
4. 配置PHP修改PHP最大配置
sed -i 's#max_execution_time = 30#max_execution_time = 300#;s#max_input_time = 60#max_input_time = 300#;s#post_max_size = 8M#post_max_size = 16M#;910a date.timezone = Asia/Shanghai' /etc/php.ini
5. 配置zabbix配置文件数据库用户密码
sed -i '/DBUser=/cDBUser=zbxuser' /etc/zabbix/zabbix_server.confsed -i '115a DBPassword=zbxpass' /etc/zabbix/zabbix_server.conf
6. 配置zabbix网页配置
cp -R /usr/share/zabbix/ /var/www/html/chmod -R 755 /etc/zabbix/webchown -R apache.apache /etc/zabbix/web echo "ServerName 127.0.0.1:80">>/etc/httpd/conf/httpd.conf
7. 服务启动顺序
/etc/init.d/mysqld startsystemctl start httpd.servicesystemctl start zabbix-server.service
8. 查看网页
10.0.0.61/zabbix #这里你的服务器IP地址
第六章 zabbix客户端安装
1. 下载zabbix-agent包
rsync -avP root@172.16.1.61:/root/zabbix-agent-3.2.6-1.el7.x86_64.rpm /root/yum localinstall zabbix-agent-3.2.6-1.el7.x86_64.rpm
2. 修改服务端IP地址
sed -i 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.confsed -i '/serverActive/cServerActive=172.16.1.61' /etc/zabbix/zabbix_agentd.conf
3. 启动agent
systemctl start zabbix-agent.service systemctl status zabbix-agent.service
第七章 解决网页显示中文乱码问题
yum install -y wqy-microhei-fonts\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
第八章 自定义监控修改配置文件
1. 客户端执行
sed -i '294a UserParameter=login_user,who|wc -l' /etc/zabbix/zabbix_agentd.confsystemctl restart zabbix-agent
2. 服务端执行
zabbix_get -s 172.16.1.7 -p 10050 -k "login_user"
3. 示例自定义监控
[root@web01 zabbix_agentd.d]# pwd/etc/zabbix/zabbix_agentd.d[root@web01 zabbix_agentd.d]# cat userparameter_nginx.conf UserParameter=nginx_active,curl -s 127.0.0.1/nginx_status|awk '/Active/ {print $NF}'UserParameter=nginx_accepts,curl -s 127.0.0.1/nginx_status|awk 'NR==3 {print $1}'UserParameter=nginx_handled,curl -s 127.0.0.1/nginx_status|awk 'NR==3 {print $2}'UserParameter=nginx_requests,curl -s 127.0.0.1/nginx_status|awk 'NR==3 {print $3}'UserParameter=nginx_reading,curl -s 127.0.0.1/nginx_status|awk 'NR==4 {print $2}'UserParameter=nginx_writing,curl -s 127.0.0.1/nginx_status|awk 'NR==4 {print $4}'UserParameter=nginx_waiting,curl -s 127.0.0.1/nginx_status|awk 'NR==4 {print $6}'[root@web01 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart######status######### server { listen 127.0.0.1:80; stub_status on; access_log off; }
第九章 web页面配置
- 05.27 zabbix服务系统监控
- zabbix配置监控某一系统服务
- zabbix监控服务安装
- 安装zabbix监控服务
- zabbix 分布式监控系统
- Zabbix 系统监控软件
- 集群监控系统【zabbix】
- zabbix监控系统
- Zabbix监控windows系统
- zabbix监控系统入坑必看
- Zabbix监控系统
- 服务篇十四---zabbix监控服务
- 部署Zabbix集中监控系统
- zabbix监控系统学习总结
- Zabbix监控系统深度实践
- 《Zabbix监控系统深度实践》
- zabbix监控系统fping配置
- zabbix监控系统客户端安装
- dubbox配置
- Codeforces Round #424 (Div. 2) D. Office Keys(dp)
- 使用Logstash multiline 收集PHP、tomcat等应用服务多行堆栈日志
- svn的使用注意事项
- 在Windows Azure/IIS7环境下部署svg/woff/woff2字体,添加MIME类型
- 05.27 zabbix服务系统监控
- nyoj973天下第一spfa环路判断
- Ubuntu连接校园网
- 揭秘游戏行业遭遇大规模DDoS攻击后的影响和真相丨阿里云河南
- FreeMarker配置
- eclipse运行报java.lang.OutOfMemoryError: PermGen space解决方法
- 驱动管理模块项目流程总结报告
- nginx+keepalived安装配置
- 低功耗电池摄像机 远程唤醒 PIR唤醒 告别布线布网的时代