监控 cacti zabbix(2)
监控(1):(cactizabbix)前提:cacti配置完成
cacti 监控其他主机(采集数据:crontab定时调用(poller.php)snmp采集存储数据:rrdtool -->rra下的rrd数据库(大小时固定,循环记录数据,不会增大,以后不断做数据更新)绘制图表:http(80) -->php -->mysql(前提:初始化数据)-->web(php动态的去mysql数据库里面去取信息但真正采集来的数据在rrd里面 mysql里面保存的是所有节点的信息(除了采集来的信息其他的都保存在mysql里面)))真实绘制图像的时候,调用rrdtool命令 cacti的缺陷:没有报警对硬件没有监控(eg:温度传感器等但可以安装插件)
被监控主机安装: net-snmp net-snmp-utils
vim/etc/snmp/snmpd.conf
测试:
snmpwalk -v 1 -c public localhost.1.3.6.1.4.1.2021.10.1.3
snmpwalk -v 1 -c public 172.25.42.250.1.3.6.1.4.1.2021.10.1.3
https://s2.运维网.com/wyfs02/M02/8F/AE/wKiom1jo5e7zL_aWAAGYRWAwt18452.png-wh_500x0-wm_3-wmp_4-s_2956444509.png
https://s3.运维网.com/wyfs02/M01/8F/AE/wKiom1jo5e-zyKWMAAFIz5R__hM359.png-wh_500x0-wm_3-wmp_4-s_2554816883.png
将被监控主机加入 cacti
https://s4.运维网.com/wyfs02/M01/8F/AC/wKioL1jo5fmiA2zoAAFrsweyb7s443.png-wh_500x0-wm_3-wmp_4-s_3527129795.png
按秒监控:crontab+sleep
eg:* * * * * sleep 10;commit
eg:* * * * * sleep 20;commit
eg:* * * * * sleep 30;commit
eg:* * * * * sleep 40;commit
eg:* * * * * sleep 50;commit
cacti加强版:tarzxf cacti-spine-0.8.8h.tar.gz
cd cacti-spine-0.8.8h
yum install mysql-devel net-snmp-devel gcc -y
./configure
make && make install
cd /usr/local/spine/etc
cp spine.conf.dist /etc/spine.conf
https://s5.运维网.com/wyfs02/M02/8F/AC/wKioL1jo5gSjwHybAAGQwPKYack045.png-wh_500x0-wm_3-wmp_4-s_479991553.png
Vim /etc/spine.conf
https://s4.运维网.com/wyfs02/M02/8F/AE/wKiom1jo5g6CGR6XAAE92fI8Dv8940.png-wh_500x0-wm_3-wmp_4-s_2241954757.png
su - cacti
/usr/local/spine/bin/spine
https://s3.运维网.com/wyfs02/M02/8F/AC/wKioL1jo5iGge0DhAAFZOBzqNpA242.png-wh_500x0-wm_3-wmp_4-s_1248996013.png
https://s5.运维网.com/wyfs02/M00/8F/AE/wKiom1jo5iLx8LitAAFRJinivIM805.png-wh_500x0-wm_3-wmp_4-s_2978329814.png
zabbix:
两台虚拟机:
dd5(server):yum installzabbix-server-2.4.5-1.el6.x86_64.rpm zabbix-server-mysql-2.4.5-1.el6.x86_64.rpmzabbix-web-2.4.5-1.el6.noarch.rpm zabbix-web-mysql-2.4.5-1.el6.noarch.rpmzabbix-2.4.5-1.el6.x86_64.rpm fping-2.4b2-16.el6.x86_64.rpmphp-bcmath-5.3.3-26.el6.x86_64.rpm iksemel-1.4-2.el6.x86_64.rpm ../php-mbstring-5.3.3-26.el6.x86_64.rpm
dd4:yum install zabbix-agent-2.4.5-1.el6.x86_64.rpm -yzabbix-2.4.5-1.el6.x86_64.rpm
dd5:(server)
配置 mysql 数据库
mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by'westos';
mysql> quit;
https://s1.运维网.com/wyfs02/M00/8F/AC/wKioL1jo5kfBgnKyAAEDgUhEl6E599.png-wh_500x0-wm_3-wmp_4-s_3221963039.png
mysql -uzabbix -pwestos zabbix < schema.sql
mysql -uzabbix -pwestos zabbix < images.sql
mysql -uzabbix -pwestos zabbix < data.sql
配置 zabbix server
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName= zabbix
DBPassword=westos
https://s3.运维网.com/wyfs02/M00/8F/AC/wKioL1jo5lWCGfnaAACmntvhOLM946.png-wh_500x0-wm_3-wmp_4-s_3325736465.png
https://s2.运维网.com/wyfs02/M01/8F/AE/wKiom1jo5lbgxGJJAACuFn0WTHE178.png-wh_500x0-wm_3-wmp_4-s_2726897803.png
监控本机:
rpm -ivhzabbix-agent-2.4.5-1.el6.x86_64.rpm
vim /etc/zabbix/zabbix_agent.conf
https://s3.运维网.com/wyfs02/M01/8F/AC/wKioL1jo5mLTlTS-AADeYiLmAnY255.png-wh_500x0-wm_3-wmp_4-s_3396697532.png
/etc/init.d/zabbix-agent start
查看:
Dd4:
rpm -ivh zabbix-agent-2.4.5-1.el6.x86_64.rpm
vim /etc/zabbix/zabbix_angent.conf
https://s4.运维网.com/wyfs02/M01/8F/AE/wKiom1jo5nChmZ_SAADkJQesbRg817.png-wh_500x0-wm_3-wmp_4-s_359309074.png
https://s5.运维网.com/wyfs02/M01/8F/AC/wKioL1jo5nHwhhtDAADpOsnGg1k912.png-wh_500x0-wm_3-wmp_4-s_3620098071.png
/etc/init.d/zabbix-serverstart
https://s2.运维网.com/wyfs02/M02/8F/AE/wKiom1jo5oTTHPgjAAGazY6nDkw883.png-wh_500x0-wm_3-wmp_4-s_1199046150.png
https://s2.运维网.com/wyfs02/M02/8F/AC/wKioL1jo5oXx1jQ0AAE7Uogb2zk883.png-wh_500x0-wm_3-wmp_4-s_234542007.png
https://s5.运维网.com/wyfs02/M00/8F/AE/wKiom1jo5oWBTZNZAAECiOk_nQg487.png-wh_500x0-wm_3-wmp_4-s_1229201046.png
两种模式:(都可自动发现主机)
自动检测: (适合批量处理)
自动加载:(可用性更高)
监控server 上的 mysql 服务
在/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf文件中指定了 zabbix agent 如何获取 mysql
服务的各种信息,并在/var/lib/zabbix 目录中新建“.my.cnf”文件,用以指定 zabbix agent 如何登陆数据库,默认使用的是 zabbix 用户,可以在 zabbix_server.conf 文件中找到密码。
https://s3.运维网.com/wyfs02/M02/8F/AC/wKioL1jo5pXxp4o2AABvkEopgpg368.png-wh_500x0-wm_3-wmp_4-s_269795166.png
# mkdir/var/lib/zabbix
# vim /var/lib/zabbix/.my.cnf
host = localhost
user = zabbix
password = westos
socket = /var/lib/mysql/mysql.sock
host = localhost
user = zabbix
password = westos
socket = /var/lib/mysql/mysql.sock
页:
[1]