Zabbix 3.0部署安裝 配置OS自動發現 自動新增 並郵件告警
阿新 • • 發佈:2018-11-19
簡單說明:
依據《CentOS7實驗機模板搭建部署》克隆實驗機192.168.77.210,部署Zabbix 3.0 LTS
配置郵件告警功能,配置自動發現功能,配置action對發現的主機自動監控並郵件告警
部署安裝Zabbix 3.0 LTS:
# 主機名和hosts解析部署 HOSTNAME=zabbix hostnamectl set-hostname "$HOSTNAME" echo "$HOSTNAME">/etc/hostname echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts echo "$(ip a|grep "inet "|grep -v 127|awk -F'[ /]' '{print $6}') $HOSTNAME">>/etc/hosts # 安裝MySQL yum -y install mariadb-server mariadb systemctl restart mariadb systemctl enable mariadb # 使用官方yum源安裝Zabbix # https://www.zabbix.com/download?zabbix=3.0&os_distribution=centos&os_version=7&db=MySQL cd /tmp axel https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm rpm -ivh /tmp/zabbix-release-3.0-1.el7.noarch.rpm yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent # 建庫,匯入zabbix庫 mysql create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to
[email protected] identified by 'zabbix'; flush privileges; quit; zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix # 修改配置檔案,啟動 sed -i 's/# DBPassword=.*/&\nDBPassword=zabbix/g' /etc/zabbix/zabbix_server.conf sed -i 's|# \(php_value date.timezone\) Europe/Riga|\1 Asia/Shanghai|g' /etc/httpd/conf.d/zabbix.conf systemctl restart zabbix-server zabbix-agent httpd systemctl enable zabbix-server zabbix-agent httpd # 網頁配置 http://192.168.77.210/zabbix # 預設使用者名稱和密碼 Admin/zabbix
配置郵件告警功能:
配置自動發現功能並測試:
1° 依據《CentOS6實驗機模板搭建部署》克隆測試機 192.168.77.250 並部署:
# 主機名和hosts解析部署 hostname zabbixtest echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts echo "$(ifconfig eth0|grep inet|awk -F'[ :]' '{print $13}') $(hostname)">>/etc/hosts echo "192.168.77.210 zabbix_server">>/etc/hosts sed -i "s/^HOSTNAME.*$/HOSTNAME=$(hostname)/g" /etc/sysconfig/network ping -c 3 $(hostname) # 使用官方yum源安裝配置Zabbix agent cd /tmp wget https://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm rpm -ivh /tmp/zabbix-release-3.0-1.el6.noarch.rpm yum -y install zabbix-agent cd /etc/zabbix/ sed -i 's/^Server=127.0.0.1/Server=zabbix_server/g' zabbix_agentd.conf sed -i 's/^ServerActive=127.0.0.1/ServerActive=zabbix_server:10051/g' zabbix_agentd.conf sed -i "s/^\(Hostname=\).*/\1$(hostname)/g" zabbix_agentd.conf chkconfig zabbix-agent on /etc/init.d/zabbix-agent start
2° 網頁新增自動發現功能
Configuration——>Discovery——>Create discovery rule
Monitoring>Discovery——>Status of discovery
配置Action自動新增OS並郵件告警:
Configuration——>Actions——>Event source: Discovery——>Create action
此處可以看出,可以依據下線狀態的主機進行操作,比如刪除掉下線主機
[TOC]