简介
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
安装配置
zabbix分为两部分
zabbix server
通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能
zabbix agent
需要安装在被监视的目标服务器上,
主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集
(1)安装Zabbix server
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+xenial_all.deb dpkg -i zabbix-release_5.0-1+xenial_all.deb apt update
(2)数据库
apt-get install zabbix-server-mysql
登陆mysql
mysql -uroot -p
创建数据库
create database zabbix character set utf8 collate utf8_bin;
注:
字符集utf8_bin
授权
grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
导入初始数据
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p
(3) Zabbix Server配置
修改 Zabbix Server配置文件 /etc/zabbix/zabbix_server.conf
配置数据库部分
DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456
启动
sudo systemctl restart zabbix-server
查看
baby@ubuntu:/etc/zabbix$ sudo systemctl status zabbix-server ● zabbix-server.service - Zabbix Server Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-12-14 10:33:38 CST; 7s ago Process: 27804 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 27809 (zabbix_server) Tasks: 38 Memory: 24.9M CPU: 143ms CGroup: /system.slice/zabbix-server.service ├─27809 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf ├─27811 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.035316 sec, idle 60 sec ├─27812 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes ├─27813 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.012570 sec, idle 21 se ├─27814 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000507 sec, idle 5 sec ├─27815 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000560 sec, idle 60 sec ├─27816 /usr/sbin/zabbix_server: history syncer #1 [processed 1 values, 1 triggers in 0.002847 sec, idle 1 ├─27817 /usr/sbin/zabbix_server: history syncer #2 [processed 0 values, 0 triggers in 0.000029 sec, idle 1 ├─27818 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000025 sec, idle 1 ├─27819 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000029 sec, idle 1 ├─27820 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.001306 sec, idle 3 sec ├─27824 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000040 sec, idle 5 sec ├─27825 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000026 sec, idle 1 sec ├─27826 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000368 sec, idle 5 sec lines 1-23
(4)安装Zabbix agent
apt install zabbix-agent
启动
sudo systemctl restart zabbix-agent
(5)Zabbix Web服务
启动apache
systemctl restart apache2
安装web服务
apt-get install zabbix-frontend-php
复制zabbix到apache2
cp -r /usr/share/zabbix /var/www/html/zabbix
经过尝试,这样安装的太老,和当前版本不匹配
sudo dpkg --list
删除
sudo dpkg -P zabbix-frontend-php
下载source包,将ui复制到/var/www/html/下
http://XXX.XXX.XXX.XXX/ui
检查配置项,修改
post_max_size = 30M max_execution_time = 300 max_input_time = 300 date.timezone =Asia/Shanghai
安装完成后跳到登陆页面
登陆账号Admin,zabbix
配置文件
zabbix_server:
LogFile=/tmp/zabbix_server.log LogFileSize=0 PidFile=/tmp/zabbix_server.pid DBHost=10.10.3.188 DBName=zabbix DBUser=zabbix DBPassword=123456 StartDBSyncers=24 Timeout=30 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts #CacheSize=1024M CacheUpdateFrequency=120 LogSlowQueries=3000 AllowRoot=1 StartPingers=100 #DebugLevel=4 JavaGateway=127.0.0.1 JavaGatewayPort=10052 StartJavaPollers=5 StartPollers=100 StartPollersUnreachable=50 StartTrappers=30 StartDiscoverers=6 CacheSize=2G CacheUpdateFrequency=300 StartDBSyncers=20 HistoryCacheSize=512M TrendCacheSize=256M ValueCacheSize=1G
zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log PidFile=/run/zabbix/zabbix_agentd.pid StartAgents=0 ServerActive=10.10.3.144 Hostname=cloud-dfs-6-6 RefreshActiveChecks=120 Include=/etc/zabbix/zabbix_agentd.conf.d/*.conf AllowRoot=1 Timeout=30
自动注册
Auto.registration:{HOST.HOST}
Action:zabbix客户端注册 Host.name:{HOST.HOST} Host.IP:{HOST.IP} Agent.port:{HOST.PORT}
Media types
golang-zabbix-robot-64 -webhook=https://oapi.dingtalk.com/robot/send?access_token=e03aa26f3773412affa441cd00f8839e696769cd8aebff935cc36f996a39e8ab -msg={ALERT.MESSAGE} -url=http://10.10.3.144/zabbix -log=/var/log/dingding.log
短信
故障{TRIGGER.STATUS},服务器:{HOSTNAME1}发生: {TRIGGER.NAME}故障 告警主机:{HOSTNAME1} 告警时间:{EVENT.DATE} {EVENT.TIME} 告警等级:{TRIGGER.SEVERITY} 告警信息: {TRIGGER.NAME} 告警项目:{TRIGGER.KEY1} 问题详情:{ITEM.NAME}:{ITEM.VALUE} 当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1} 事件ID:{EVENT.ID}
故障{TRIGGER.STATUS},服务器:{HOSTNAME1}发生: {TRIGGER.NAME}恢复 告警主机:{HOSTNAME1} 告警时间:{EVENT.DATE} {EVENT.TIME} 告警等级:{TRIGGER.SEVERITY} 告警信息: {TRIGGER.NAME} 告警项目:{TRIGGER.KEY1} 问题详情:{ITEM.NAME}:{ITEM.VALUE} 当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1} 事件ID:{EVENT.ID}
http://www.virplus.com/thread-1421.htm
转载请注明:2021-9-9 于 VirPlus 发表