簡介php
前提: 服務器安裝了mysqlhtml
服務器: 192.168.44.71 zabbix01mysql
wget http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
rpm -ivh zabbix-release-3.0-1.el7.noarch.rpm
執行完上面兩步後,會生成一個yum源文件:web
[root@zabbix01 ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
yum install zabbix-server-mysql zabbix-get
[root@zabbix01 ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.0.25
/usr/share/doc/zabbix-server-mysql-3.0.25/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.0.25/COPYING
/usr/share/doc/zabbix-server-mysql-3.0.25/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.0.25/NEWS
/usr/share/doc/zabbix-server-mysql-3.0.25/README
/usr/share/doc/zabbix-server-mysql-3.0.25/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
找到上面紅色的目錄中的sql文件sql
cd /usr/share/doc/zabbix-server-mysql-3.0.25/
gunzip create.sql.gz
建立zabbix數據庫並初始化數據庫
mysql -uroot -p
create database zabbix charset 'utf8';
grant all on zabbix.* to zabbix@'localhost' identified by '123456';
flush privileges;
執行sql文件vim
mysql -uroot -p -Dzabbix < /usr/share/doc/zabbix-server-mysql-3.0.25/create.sql
編輯配置文件安全
vim /etc/zabbix/zabbix_server.conf
ListenPort=10051 #監控端口
SourceIP=192.168.44.71 #服務器ip
LogType=file
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix #mysql中數據庫名稱
DBUser=zabbix #mysql數據庫用戶
DBPassword=123456 #mysql數據庫密碼
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306 #mysql端口
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
配置完成後,啓動zabbix server服務器
systemctl start zabbix-server.service
依賴環境網絡
yum install httpd php php-mysql php-mbstring php-gd php-bcmath php-ldap php-xml
安裝zabbix web
yum install zabbix-web zabbix-web-mysql
修改配置文件 注意紅色部分(80端口也可修改成其餘端口)
vim /etc/httpd/conf.d/zabbix.conf
<VirtualHost 192.168.44.71:80> servername zabbix01 documentroot /usr/share/zabbix Alias /zabbix /usr/share/zabbix <Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted <IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value max_input_vars 10000 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai </IfModule> </Directory> <Directory "/usr/share/zabbix/conf"> Require all denied </Directory> <Directory "/usr/share/zabbix/app"> Require all denied </Directory> <Directory "/usr/share/zabbix/include"> Require all denied </Directory> <Directory "/usr/share/zabbix/local"> Require all denied </Directory> </VirtualHost>
啓動httpd服務
systemctl start httpd.service
訪問192.168.44.71/zabbix 進行一步步配置便可,默認的管理員用戶密碼爲 Admin:zabbix
登陸完成後:
更改成中文界面:
從新登陸便可。
yum install -y zabbix-agent zabbix-sender
修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.44.71 #服務端ip
ServerActive=192.168.44.71 #服務端ip
Hostname=zabbix01_agent #agent名稱
Include=/etc/zabbix/zabbix_agentd.d/
啓動zabbix agent
systemctl start zabbix-agent.service
可在服務器中測試一下cpu使用率(以前安裝了zabbix_get)
[root@zabbix01 ~]# zabbix_get -s 192.168.44.71 -k system.cpu.switches
3572908
最終的監控項
可在監測中>最新數據>監控項>圖形中看具體圖形化結果
這種帶參數的監控項
選擇了之後,修改參數值便可
以監控根目錄下磁盤使用率爲例
同不帶參數的監控項查看方式同樣可查看圖形界面。
一些其餘配置可查看官方文檔 https://www.zabbix.com/documentation/3.0
以監控根目錄磁盤使用率的監控項爲例, 監測到磁盤使用率大於等於20% 則觸發
點擊建立觸發器後
建立完成,因爲是給RootPartitionUsed建立的觸發器,因此可在最新數據>RootPartitionUsed監控項的圖形中查看。
本文參考借鑑 http://www.zsythink.net/archives/500