zabbix是一個基於WEB界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。php
zabbix能監視各類網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各類問題。mysql
zabbix由2部分構成,zabbix server與可選組件zabbix agent。web
zabbix server能夠經過SNMP,zabbix agent,ping,端口監視等方法提供對遠程服務器/網絡狀態的監視,數據收集等功能,它能夠運行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平臺上。sql
zabbix agent須要安裝在被監視的目標服務器上,它主要完成對硬件信息或與操做系統有關的內存,CPU等信息的收集。數據庫
zabbix server能夠單獨監視遠程服務器的服務狀態;同時也能夠與zabbix agent配合,能夠輪詢zabbix agent主動接收監視數據(agent方式),同時還可被動接收zabbix agent發送的數據(trapping方式)。 另外zabbix server還支持SNMP (v1,v2),能夠與SNMP軟件(例如:net-snmp)等配合使用。apache
zabbix的主要特色:vim
Zabbix主要功能:windows
zabbix配置文件有兩種:瀏覽器
服務器端配置文件zabbix_server.conf經常使用配置參數:sass
參數 | 做用 |
---|---|
LogFile | 設置服務端日誌文件存放路徑 |
ListenIP | 設置服務端監聽IP |
ListenPort | 設置服務端監聽的端口號 |
PidFile | 設置服務端進程號文件存放路徑 |
DBHost | 指定zabbix的數據庫服務器IP |
DBName | 指定zabbix使用的數據庫庫名 |
DBUser | 指定zabbix數據庫登陸用戶 |
DBPassword | 指定zabbix數據庫登陸密碼 |
DBPort | 指定zabbix數據庫端口號 |
User | 設置zabbix以什麼用戶的身份運行 |
AlertScriptsPath | 設置告警腳本存放路徑 |
ExternalScripts | 外部腳本存放路徑 |
客戶端配置文件zabbix_agentd.conf經常使用配置參數:
參數 | 做用 |
---|---|
Server | 指定zabbix服務器的IP或域名 |
ServerActive | 指定zabbix服務器的IP或域名 |
Hostname | 指定本機的主機名,此項必須與web界面配置項一致 |
UnsafeUserParameters | 是否啓用自定義監控項,可選值爲{1 |
UserParameter | 指定自定義監控腳本參數 |
LogFile | 設置客戶端日誌文件存放路徑 |
環境說明:
環境 | IP | 要安裝的應用 |
---|---|---|
服務器 | 192.168.56.20 | lamp架構 zabbix server zabbix agent |
客戶端 | 192.168.56.23 | zabbix agent |
由於zabbix是用php語言開發的,因此必須先部署lamp架構,使其可以支持運行php網頁
//安裝依賴包
[root@20liuzhenchao ~]# yum -y install net-snmp-devel libevent-devel 安裝過程略.... //下載zabbix [root@20liuzhenchao ~]# cd /usr/src [root@20liuzhenchao src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz 下載過程略.... //解壓 [root@20liuzhenchao src]# tar xf zabbix-4.0.3.tar.gz //建立zabbix用戶和組 [root@20liuzhenchao src]# groupadd -r zabbix [root@20liuzhenchao src]# useradd -r -M -s /sbin/nologin -g zabbix zabbix //配置zabbix數據庫 [root@20liuzhenchao ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.22 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!'; Query OK, 0 rows affected, 2 warnings (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye [root@20liuzhenchao ~]# cd /usr/src/zabbix-4.0.3/database/mysql/ [root@20liuzhenchao mysql]# ls data.sql images.sql Makefile.am Makefile.in schema.sql [root@20liuzhenchao mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@20liuzhenchao mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@20liuzhenchao mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure. //編譯安裝zabbix [root@20liuzhenchao mysql]# cd /usr/src/zabbix-4.0.3 [root@20liuzhenchao zabbix-4.0.3]# ./configure --enable-server \ --enable-agent \ --with-mysql \ --with-net-snmp \ --with-libcurl \ --with-libxml2 [root@20liuzhenchao zabbix-4.0.3]# make install
[root@20liuzhenchao zabbix-4.0.3]# ls /usr/local/etc/ zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d //修改服務端配置文件 //設置數據庫信息 [root@20liuzhenchao zabbix-4.0.3]# vim /usr/local/etc/zabbix_server.conf .... DBPassword=zabbix123! //設置zabbix數據庫鏈接密碼 //啓動zabbix_server和zabbix_agentd [root@20liuzhenchao zabbix-4.0.3]# zabbix_server [root@20liuzhenchao zabbix-4.0.3]# zabbix_agentd [root@20liuzhenchao zabbix-4.0.3]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:10050 *:* LISTEN 0 128 *:10051 *:* LISTEN 0 128 127.0.0.1:9000 *:* LISTEN 0 10 127.0.0.1:53 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:953 *:* LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::80 :::* LISTEN 0 10 ::1:53 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 ::1:953 :::*
//修改/etc/php.ini的配置並重啓php-fpm
[root@20liuzhenchao ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini [root@20liuzhenchao ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini [root@20liuzhenchao ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini [root@20liuzhenchao ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini [root@20liuzhenchao ~]# service php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done [root@20liuzhenchao ~]# cd /usr/src/zabbix-4.0.3 [root@20liuzhenchao zabbix-4.0.3]# ls aclocal.m4 bin ChangeLog conf config.log config.sub configure.ac database frontends INSTALL m4 Makefile.am man missing README src AUTHORS build compile config.guess config.status configure COPYING depcomp include install-sh Makefile Makefile.in misc NEWS sass [root@20liuzhenchao zabbix-4.0.3]# mkdir /usr/local/apache/htdocs/zabbix [root@20liuzhenchao zabbix-4.0.3]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/ [root@20liuzhenchao zabbix-4.0.3]# chown -R apache.apache /usr/local/apache/htdocs //配置apache虛擬主機 [root@20liuzhenchao ~]# vim /etc/httpd24/httpd.conf //在配置文件的末尾加以下內容 <VirtualHost *:80> DocumentRoot "/usr/local/apache/htdocs/zabbix" ServerName zabbix.liuzhenchao.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1 <Directory "/usr/local/apache/htdocs/zabbix"> Options none AllowOverride none Require all granted </Directory> </VirtualHost> //設置zabbix/conf目錄的權限,讓zabbix有權限生成配置文件zabbix.conf.php [root@20liuzhenchao ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf [root@20liuzhenchao ~]# ll -d /usr/local/apache/htdocs/zabbix/conf drwxrwsrwx 2 apache apache 81 12月 20 19:24 /usr/local/apache/htdocs/zabbix/conf //重啓apache [root@20liuzhenchao ~]# apachectl -t Syntax OK [root@20liuzhenchao ~]# apachectl stop [root@20liuzhenchao ~]# apachectl start [root@20liuzhenchao ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:10050 *:* LISTEN 0 128 *:10051 *:* LISTEN 0 128 127.0.0.1:9000 *:* LISTEN 0 10 127.0.0.1:53 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:953 *:* LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::80 :::* LISTEN 0 10 ::1:53 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 ::1:953 :::*
修改本地C:\Windows\System32\drivers\etc\hosts文件,添加域名與IP的映射 在瀏覽器上訪問域名,本文設置的域名爲zabbix.liuzhenchao.com
在瀏覽器上訪問域名進行安裝:
恢復zabbix/conf目錄的權限爲755:
[root@20liuzhenchao ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf [root@20liuzhenchao ~]# ll /usr/local/apache/htdocs/zabbix/conf -d drwxr-sr-x 2 apache apache 81 12月 20 19:24 /usr/local/apache/htdocs/zabbix/conf
zabbix默認登陸用戶名和密碼:
用戶名 | 密碼 |
---|---|
Admin | zabbix |
//獲取zabbix安裝包
[root@20liuzhenchao ~]# scp zabbix-4.0.3.tar.gz root@192.168.56.23:/root
root@192.168.56.23's password:
zabbix-4.0.3.tar.gz 100% 17MB 37.8MB/s 00:00
[root@33liuzhenchao ~]# ls |grep zabbix
zabbix-4.0.3.tar.gz
//解壓
[root@33liuzhenchao ~]# tar xf zabbix-4.0.3.tar.gz -C /usr/src
//編譯並安裝
[root@33liuzhenchao ~]# cd /usr/src/zabbix-4.0.3/
[root@33liuzhenchao zabbix-4.0.3]# ./configure --enable-agent
.....
.....
Enable Java gateway: no
LDAP support: no
IPv6 support: no
*********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * *********************************************************** [root@33liuzhenchao zabbix-4.0.3]# make install .... .... make[2]: 對「install-data-am」無需作任何事。 make[2]: 離開目錄「/usr/src/zabbix-4.0.3/misc」 make[1]: 離開目錄「/usr/src/zabbix-4.0.3/misc」 make[1]: 進入目錄「/usr/src/zabbix-4.0.3」 make[2]: 進入目錄「/usr/src/zabbix-4.0.3」 make[2]: 對「install-exec-am」無需作任何事。 make[2]: 對「install-data-am」無需作任何事。 make[2]: 離開目錄「/usr/src/zabbix-4.0.3」 make[1]: 離開目錄「/usr/src/zabbix-4.0.3」 //編輯zabbix_agentd.conf [root@33liuzhenchao zabbix-4.0.3]# cd /usr/local/etc/ [root@33liuzhenchao etc]# ls zabbix_agentd.conf zabbix_agentd.conf.d //將Server和ServerActive改爲192.168.56.20 hostname取個名,好比:client23 [root@33liuzhenchao etc]# vim zabbix_agentd.conf Server=192.168.56.20 ServerActive=192.168.56.20 Hostname=client23 //建立zabbix用戶 [root@33liuzhenchao ~]# groupadd -r zabbix [root@33liuzhenchao ~]# useradd -r -M -s /sbin/nologin -g zabbix zabbix //啓動客戶端 [root@33liuzhenchao ~]# zabbix_agentd [root@33liuzhenchao ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:10050 *:* LISTEN 0 128 127.0.0.1:9000 *:* LISTEN 0 128 *:22 *:* :::*
一、分別點擊Configuration、Hosts、Create host,以下圖:
二、添加監控主機信息
三、點擊Visible name 建立模板,點擊Templates並選擇Template OS Linux,點擊下面的Add和Update
四、分別點擊Monitoring、Dashboard、Edit dashboard能夠刪除不須要的框架
一、在windows系統上打開運行界面,而後輸入c:\windows\fonts,而後點擊肯定,打開windows的字體目錄。在右上角的搜索框輸入simkai.ttf,而後會出現楷體的搜索結果
二、將這個simkai字體拷貝出來,而後使用xftp工具將它上傳到zabbix服務器上,以下面圖中所示,上傳完成後,將它移動到zabbix的字體目錄。
[root@20liuzhenchao ~]# mv simkai.ttf /usr/local/apache/htdocs/zabbix/fonts/ [root@20liuzhenchao ~]# ls /usr/local/apache/htdocs/zabbix/fonts/ DejaVuSans.ttf simkai.ttf
三、修改字體配置文件
[root@20liuzhenchao ~]# cd /usr/local/apache/htdocs/zabbix/include [root@20liuzhenchao include]# vim defines.inc.php define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
四、查看效果