一、Zabbix介紹
zabbix 簡介
Zabbix 是一個高度集成的網絡監控解決方案,可以提供企業級的開源分布式監控解決方案,由一個國外的團隊持續維護更新,軟件可以自由下載使用,運作團隊靠提供收費的技術支持贏利
zabbix是一個基於Web界面的,提供分布式系統監控以及網絡監視功能的企業級的開源解決方案。
zabbix能監視各種網絡參數,保證服務器系統的安全運營,並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各種問題
zabbix主要由2部分構成zabbix server和zabbix agent,可選組建zabbix proxy
zabbix server可以通過SNMP,zabbix agent,fping端口監視等方法對遠程服務器或網絡狀態完成監視,數據收集等功能。同時支持Linux以及Unix平台,Windows平台只能安裝客戶端
Zabbix 功能
①具備常見的商業監控軟件所具備的功能(主機的性能監控、網絡設備性能監控、數據庫、性能監控、FTP 等通用協議監控、多種告警方式、詳細的報表圖表繪制)
②支持自動發現網絡設備和服務器(可以通過配置自動發現服務器規則來實現)
③支持自動發現(low discovery)key 實現動態監控項的批量監控(需寫腳本)
④支持分布式,能集中展示、管理分布式的監控點
⑤擴展性強,server 提供通用接口(api 功能),可以自己開發完善各類監控(根據相關接口編寫程序實現)編寫插件容易,可以自定義監控項,報警級別的設置。
⑥數據收集
- 可用和性能檢測
- 支持snmp(包括trapping and polling),IPMI,JMX,SSH,TELNET
- 自定義的檢測
- 自定義收集數據的頻率
- 服務器/代理和客戶端模式
- 靈活的觸發器
- 可以定義非常靈活的問題閾值,稱為觸發器,從后端數據庫的參考值
- 高可定制的報警
- 發送通知,可定制的報警升級,收件人,媒體類型
- 通知可以使用宏變量有用的變量
- 自動操作包括遠程命令
- 實時的繪圖功能
- 監控項實時的將數據繪制在圖形上面
WEB 監控能力
ZABBIX 可以模擬鼠標點擊了一個網站,並檢查返回值和響應時間
Api 功能
應用api功能,可以方便的和其他系統結合,包括手機客戶端的使用。
更多功能請查看
http://www.zabbix.com/documentation.php
Zabbix版本
Zabbix 3.0 Manual
Zabbix 2.4 Manual
Zabbix 2.2 Manual
Zabbix 2.0 Manual
下載地址:http://www.zabbix.com/documentation.php
Zabbix優缺點
優點
1、開源,無軟件成本投入
2、Server 對設備性能要求低
3、支持設備多,自帶多種監控模板
4、支持分布式集中管理,有自動發現功能,可以實現自動化監控
5、開放式接口,擴展性強,插件編寫容易
6、當監控的item 比較多服務器隊列比較大時可以采用被動狀態,被監控客戶端主動從
7、server 端去下載需要監控的item 然后取數據上傳到server 端。這種方式對服務器的負載比較小。
8、Api 的支持,方便與其他系統結合
缺點
需在被監控主機上安裝agent,所有數據都存在數據庫里,產生的數據據很大,瓶頸主要在數據庫。
Zabbix監控原理
Zabbix 通過C/S 模式采集數據,通過B/S模式在web 端展示和配置。
被監控端:主機通過安裝agent 方式采集數據,網絡設備通過SNMP 方式采集數據
Server 端:通過收集SNMP 和agent 發送的數據,寫入數據庫(MySQL,ORACLE 等),再通過php+apache 在web 前端展示。
Zabbix 運行條件
Server:Zabbix Server 需運行在LAMP(Linux+Apache+Mysql+PHP)環境下(或者LNMP),對硬件要求低
Agent:目前已有的agent 基本支持市面常見的OS,包含Linux、HPUX、Solaris、Sun、 windows
SNMP:支持各類常見的網絡設備
SNMP(Simple Network Management Protocol,簡單網絡管理協議
Zabbix監控過程邏輯圖
二、監控
1、監按對象
2、監控范圍
- 硬件監控
- 操作系統監控
- 應用服務監控
- 業務監控
三、Zabbix服務端安裝
1、環境
1 [root@zabbix-server ~]# cat /etc/redhat-release
2 CentOS release 6.7 (Final) 3
4 [root@zabbix-server ~]# uname -r
5 2.6.32-573.el6.x86_64 6
7 [root@zabbix-server ~]# uname -m
8 x86_64
2、server端安裝
1 rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm 2 yum install httpd zabbix zabbix-server zabbix-web zabbix-server-mysql zabbix-web-mysql mysql-server -y
3、PHP安裝
1 rpm -ivh http://mirror.webtatic.com/yum/el6/latest.rpm 2 yum install php55w php55w-mysql php55w-common php55w-gd php55w-mbstring php55w-mcrypt php55w-devel php55w-xml php55w-bcmath -y 3 yum remove zabbix-server-pgsql -y 4 cp -R /usr/share/zabbix/ /var/www/html/
5 #備注:zabbix3.0必須要php5.4以上,因此需要安裝特殊源,才能夠安裝php5.5
4、MySQL配置
1 [root@zabbix-server ~]#/etc/init.d/mysqld start
2
3 Initializing MySQL database: Installing MySQL system tables... 4 161007 10:31:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead. 5 OK 6 Filling help tables... 7 161007 10:31:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead. 8 OK 9
10 To start mysqld at boot time you have to copy 11 support-files/mysql.server to the right place for your system 12
13 PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! 14 To do so, start the server, then issue the following commands: 15
16 /usr/bin/mysqladmin -u root password 'new-password'
17 /usr/bin/mysqladmin -u root -h m01 password 'new-password'
18
19 Alternatively you can run: 20 /usr/bin/mysql_secure_installation 21
22 which will also give you the option of removing the test 23 databases and anonymous user created by default. This is
24 strongly recommended for production servers. 25
26 See the manual for more instructions. 27
28 You can start the MySQL daemon with: 29 cd /usr ; /usr/bin/mysqld_safe &
30
31 You can test the MySQL daemon with mysql-test-run.pl 32 cd /usr/mysql-test ; perl mysql-test-run.pl 33
34 Please report any problems with the /usr/bin/mysqlbug script! 35
36 [ OK ] 37 Starting mysqld: [ OK ]
5、創建用戶並授權
1 [root@zabbix-server ~]# mysql
2 Welcome to the MySQL monitor. Commands end with ; or \g. 3 Your MySQL connection id is 2
4 Server version: 5.1.73-log Source distribution 5
6 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 7
8 Oracle is a registered trademark of Oracle Corporation and/or its 9 affiliates. Other names may be trademarks of their respective 10 owners. 11
12 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 13
14 mysql> create database zabbix character set utf8 collate utf8_bin; 15 Query OK, 1 row affected (0.00 sec) 16
17 mysql> grant all on zabbix.* to zabbix@'localhost' identified by '111111'; 18 Query OK, 0 rows affected (0.00 sec) 19
20 mysql> flush privileges; 21 Query OK, 0 rows affected (0.01 sec) 22
23 mysql> exit 24 Bye
6、導入zabbix數據庫文件
1 [root@zabbix-server]# cd /usr/share/doc/zabbix-server-mysql-3.0.5/
2
3 #導入數據庫文件
4 [root@zabbix-server zabbix-server-mysql-3.0.5]# zcat create.sql.gz |mysql -uzabbix -p111111 zabbix
7、修改相關配置文件
修改php配置文件
1 [root@zabbix-server]#vim /etc/php.ini
2 post_max_size = 16M 3 max_execution_time = 300
4 max_input_time = 300
5 date.timezone = Asia/shanghai
修改zabbix_server配置文件
1 [root@zabbix-server ~]# vi /etc/zabbix/zabbix_server.conf
2 修改數據庫地址、數據庫名、 用戶、密碼 3
4 分別對應 5 DBHost=localhost 6 DBName=zabbix 7 DBUser=zabbix 8 DBPassword=111111
9 DBSocket=/var/lib/mysql/mysql.sock
文件授權
1 [root@zabbix-server ~]# chmod -R 755 /etc/zabbix/web
2 [root@zabbix-server ~]# chown -R apache.apache /etc/zabbix/web
啟動apache && zabbix
1 /etc/init.d/httpd start 2 /etc/init.d/zabbix-server start
8、登錄安裝
http://192.168.30.132/zabbix
輸入用戶名(注意大小寫)和密碼
登錄進去后的界面如下:
服務端完裝完畢。
四、agent端安裝
1、環境准備
1 [root@web01 ~]# cat /etc/redhat-release
2 CentOS release 6.7 (Final) 3 [root@web01 ~]# uname -r
4 2.6.32-573.el6.x86_645 [root@web01 ~]# uname -m
6 x86_64
2、安裝zabbix的yum源,國內阿里的yum源已經提供了zabbix3.0
aliyum源配置
1 rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
3、zabbix_agent安裝配置
1 [root@web01 ~]# rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
2 [root@web01 ~]# yum install zabbix-agent -y
3 [root@web01 ~]# vim /etc/zabbix/zabbix_agentd.conf
4 Server=192.168.30.132 #用於被動模式,數據獲取
5 ServerActive=192.168.30.132 #用於主動模式,數據提交
6 [root@web01 ~]# /etc/init.d/zabbix-agent start #啟動zabbix agent
備注:這里的主動模式還有被動模式的出發點是agent端,所以agent主動向server端發送數據就成為主動模式,而等待server端主動獲取數據則稱為被動模式。
4、配置開機自啟動
1 [root@web01 ~]# chkconfig zabbix-agent on
#詳細文檔參考:
https://www.cnblogs.com/clsn/p/7885990.html