分佈式監控系統Zabbix-3.0.3的安裝記錄php
環境說明
zabbix-server:192.168.1.30 #zabbix的服務端(若要監控本機,則須要配置本機的Zabbix agent,下面會提到)
zabbix-agent:192.168.1.7 #zabbix的客戶端(被監控端,須要配置Zabbix agent,下面會提到)html
1、zabbix-server端的操做記錄(192.168.1.30 )前端
zabbix服務器端要提早安裝好LNMP環境(mysql,nginx,php5的安裝目錄均是/usr/local)java
建立Zabbix運行的用戶:
[root@Zabbix-server ~]# groupadd zabbix
[root@Zabbix-server ~]# useradd -g zabbix zabbixpython
安裝libcurl和net-snmp:
[root@Zabbix-server ~]# yum install net-snmp-devel curl-develmysql
安裝Fping:
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# wget -c http://fping.org/dist/fping-3.4.tar.gz
[root@Zabbix-server src]# tar zxvf fping-3.4.tar.gz
[root@Zabbix-server src]# cd fping-3.4
[root@Zabbix-server fping-3.4]# ./configure
[root@Zabbix-server fping-3.4]# make && make install
[root@Zabbix-server fping-3.4]# chown root:zabbix /usr/local/sbin/fping
[root@Zabbix-server fping-3.4]# chmod 4710 /usr/local/sbin/fpingnginx
安裝Zabbix Server:
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# wget -c http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
[root@Zabbix-server src]# tar zxvf zabbix-3.0.3.tar.gz
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurlweb
注意:編譯時最好帶上--enable-java這個參數,方便後續監控tomcat程序所用。sql
==========zabbix編譯時可能出現的報錯及其解決辦法============= error: Invalid Net-SNMP directory - unable to find net-snmp-config # yum install net-snmp-devel configure: error: Jabber library not found #yum install iksemel-devel -y 便可, configure: error: LIBXML2 library not found #yum install libxml2-devel -y configure: error: unixODBC library not found #yum install unixODBC-devel -y configure: error: Invalid OPENIPMI directory - unable to findipmiif.h #yum install OpenIPMI-devel configure:error: Unable to find "javac" executable in pathyum install java-devel -y 缺乏java,可安裝java,好比java6,java7或java8 能夠參考https://www.cnblogs.com/kevingrace/p/5870814.html #yum -y install java-1.7.0-openjdk* configure: error: Curl library not found # yum install curl-devel -y configure: error: SSH2 library not found #yum install -y libssh2-devel
[root@Zabbix-server zabbix-3.0.3]# make && make install數據庫
Zabbix Server配置與啓動
建立Zabbix數據庫和MySQL用戶:
[root@Zabbix-server ~]# mysql -p
........
mysql> create schema zabbix character set utf8;
Query OK, 1 row affected (0.05 sec)
mysql> create user 'zabbix'@'%' identified by '123456';
Query OK, 0 rows affected (0.16 sec)
mysql> grant all on zabbix.* to 'zabbix'@'%';
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
導入Zabbix初始數據:
切換到zabbix的解壓目錄下,這裏是/usr/local/src目錄下
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]#cd database/mysql/
[root@Zabbix-server mysql]# pwd
/usr/local/src/zabbix-3.0.3/database/mysql
[root@Zabbix-server mysql]# ls
data.sql images.sql schema.sql
[root@Zabbix-server mysql]# mysql -uroot -p #登錄mysql,進行zabbix初始數據導入(記得要先"use zabbix"庫以後再導入)
mysql> set sql_log_bin=0;
mysql> source ./schema.sql;
mysql> source ./images.sql;
mysql> source ./data.sql;
mysql> set sql_log_bin=1;
編輯/usr/local/zabbix/etc/zabbix_server.conf:
[root@Zabbix-server ~]#vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/usr/local/zabbix/logs/zabbix_server.pid
DBHost=192.168.1.30
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
FpingLocation=/usr/local/sbin/fping
從安裝目錄拷貝zabbix_server腳本,並編輯:
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]# cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/
[root@Zabbix-server zabbix-3.0.3]# mkdir -p /usr/local/zabbix/logs
[root@Zabbix-server zabbix-3.0.3]# chown -R zabbix:zabbix /usr/local/zabbix
[root@Zabbix-server zabbix-3.0.3]# vim /etc/init.d/zabbix_server
[root@Zabbix-server zabbix-3.0.3]# cat /etc/init.d/zabbix_server
...
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"
CONF_FILE="/usr/local/zabbix/etc/zabbix_server.conf"
...
start() {
...
daemon $ZABBIX_BIN -c $CONF_FILE
...
}
調整防火牆規則(開放端口10051):
[root@Zabbix-server ~]# vim /etc/sysconfig/iptables
...
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
...
[root@Zabbix-server ~]# /etc/init.d/iptables restart
啓動Zabbix Server:
[root@Zabbix-server ~]# service zabbix_server start #也能夠直接/usr/local/zabbix/sbin/zabbix_server方式啓動
Starting Zabbix Server: [ OK ]
中止Zabbix Server:
[root@Zabbix-server ~]# service zabbix_server stop
Stopping Zabbix Server: [ OK ]
配置開機自動啓動:
[root@Zabbix-server ~]# chkconfig --add zabbix_server
[root@Zabbix-server ~]# chkconfig --level 35 zabbix_server on
Zabbix的Web前端
在安裝目錄將frontends拷貝到指定的web root:
[root@Zabbix-server ~]# mkdir -p /data/www/zabbix
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]#cp -a frontends/php/* /data/www/zabbix/
[root@Zabbix-server zabbix-3.0.3]# chown -R www:www /data/www/zabbix
Nginx配置:
[root@Zabbix-server ~]# cat /usr/local/nginx/conf/vhost/zabbix.conf
server { listen 80; server_name zabbix.zrwm.com; location / { root /data/www/zabbix; index index.php index.html index.htm ; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root /data/www/zabbix; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
php.ini配置:
[root@Zabbix-server ~]# cat /usr/local/php5/etc/php.ini
...
memory_limit = 128M
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
session.auto_start = 0 ; //必須爲0
mbstring.func_overload = 0
...
注:PHP須要至少開啓擴展:gd,bcmath,ctype,libXML,xmlreader,xmlwriter,session,sockets,mbstring,gettext,mysql
以下,查看是否包括了上面所提到的擴展模塊
[root@Zabbix-server ~]# /usr/local/php5/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib
[Zend Modules]
訪問Web界面http://zabbix.zrwm.com,進行相關web配置,配置完成後使用默認用戶admin(密碼:zabbix)登錄便可.
在上面zabbix檢索的時候可能出現的錯誤
1)PHP option "max_execution_time" 120 300 failed # vim /data/php/lib/php.ini max_execution_time = 300 //修改成300 而後重啓nginx(如果apache+php,就重啓apache) 2)PHP bcmath off failed 解決辦法:安裝php的bcmath擴展 # yum install *bcmath* --skip-broken # cd /data/software/php-5.6.30/ext/bcmath/ # /data/php/bin/phize # ./configure --with-php-config=/data/php/bin/php-config # make && make install # vim /data/php/lib/php.ini 添加下面內容 ..... extension=/data/php/lib/php/extensions/no-debug-zts-20131226/bcmath.so 而後重啓php(如果apache+php,就重啓apache) 3)about always-populate-raw-post-data must be set -1 的問題: PHP option "always_populate_raw_post_data" on off failed 解決辦法: # vim /data/vhosts/zabbix/include/classes/setup/CFrontendSetup.php 添加下面這一行 ....... public function checkPhpAlwaysPopulateRawPostData() { $current = ini_get('always_populate_raw_post_data'); $current = -1; //添加這一行內容 return [ 'name' => _s('PHP option "%1$s"', 'always_populate_raw_post_data'), 'current' => ($current != -1) ? _('on') : _('off'), 'required' => _('off'), 'result' => ($current != -1) ? self::CHECK_FATAL : self::CHECK_OK, 'error' => _s('PHP option "%1$s" must be set to "%2$s"', 'always_populate_raw_post_data', -1) ];
若是登陸zabbix後,出現下面報錯
解決方法 [root@Zabbix-server ~]# vim /usr/local/php5/etc/php.ini cgi.fix_pathinfo=1 [root@Zabbix-server ~]# /etc/init.d/php-fpm restart 問題根源 在zabbix php定位問題發現,zabbix是依據php文件名來設置權限,例如index.php、dashboard.php這些,若是cgi.fix_pathinfo設置爲0, 那麼php沒法獲取到url請求的文件名稱,例如訪問index.php,獲取不到index.php也定位到權限,因而出現這個錯誤。
===========php安裝的擴展沒有生效的緣由及解決辦法===========
在安裝zabbix時,lnmp環境部署後,發現有些依賴的php擴展沒有安裝,例如bcmath、gettext等。 在後續安裝這些擴展,配置好php.ini,並重啓php-fpm服務後,發現新安裝的php擴展並無生效(即"php -m"命令後沒有查找到)。 這是由於php-fpm啓動時,沒指定php.ini,因此一直都沒生效! [root@Zabbix-server etc]# /etc/init.d/php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done [root@Zabbix-server etc]# ps -ef|grep php-fpm root 19529 1 0 23:37 ? 00:00:00 php-fpm: master process (/data/php/etc/php-fpm.conf) www 19530 19529 0 23:37 ? 00:00:00 php-fpm: pool www www 19531 19529 0 23:37 ? 00:00:00 php-fpm: pool www root 19533 17173 0 23:37 pts/4 00:00:00 grep --color=auto php-fpm 解決辦法: 1)指定php.ini文件來啓動php-fpm服務 [root@Zabbix-server etc]# /etc/init.d/php-fpm stop Gracefully shutting down php-fpm . done [root@Zabbix-server etc]# ps -ef|grep php-fpm root 19541 17173 0 23:38 pts/4 00:00:00 grep --color=auto php-fpm [root@Zabbix-server etc]# /data/php/sbin/php-fpm -y /data/php/etc/php-fpm.conf -c /data/php/etc/php.ini [root@Zabbix-server etc]# ps -ef|grep php-fpm root 19543 1 0 23:38 ? 00:00:00 php-fpm: master process (/data/php/etc/php-fpm.conf) www 19544 19543 0 23:38 ? 00:00:00 php-fpm: pool www www 19545 19543 0 23:38 ? 00:00:00 php-fpm: pool www root 19547 17173 0 23:39 pts/4 00:00:00 grep --color=auto php-fpm 2)要是上面啓動後,安裝的php擴展仍是沒有生效!那就多是php.ini文件沒有放對路徑(這裏我是直接放在php的etc目錄下的,能夠嘗試放到php的lib目錄下) [root@Zabbix-server ~]# ll /data/php/etc/php.ini -rw-r--r-- 1 root root 73243 10月 13 23:32 /data/php/etc/php.ini [root@Zabbix-server ~]# cp /data/php/etc/php.ini /data/php/lib/ [root@Zabbix-server ~]# ll /data/php/lib/php.ini -rw-r--r-- 1 root root 73243 10月 13 23:35 /data/php/lib/php.ini 而後再接着重啓php-fpm服務便可! [root@Zabbix-server ~]# /etc/init.d/php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done [root@Zabbix-server ~]# ps -ef|grep php root 19564 1 0 23:43 ? 00:00:00 php-fpm: master process (/data/php/etc/php-fpm.conf) www 19565 19564 0 23:43 ? 00:00:00 php-fpm: pool www www 19566 19564 0 23:43 ? 00:00:00 php-fpm: pool www root 19568 17173 0 23:43 pts/4 00:00:00 grep --color=auto php [root@Zabbix-server ~]#
===============zabbix登陸密碼忘記了,重置密碼==============
若是zabbix界面的admin登陸密碼忘記了,能夠登陸mysql裏面進行修改 [root@Zabbix-server ~]# mysql -p123456 ........ mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | zabbix | +--------------------+ 5 rows in set (0.00 sec) mysql> use zabbix; mysql> desc users; +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ | userid | bigint(20) unsigned | NO | PRI | NULL | | | alias | varchar(100) | NO | UNI | | | | name | varchar(100) | NO | | | | | surname | varchar(100) | NO | | | | | passwd | char(32) | NO | | | | | url | varchar(255) | NO | | | | | autologin | int(11) | NO | | 0 | | | autologout | int(11) | NO | | 900 | | | lang | varchar(5) | NO | | en_GB | | | refresh | int(11) | NO | | 30 | | | type | int(11) | NO | | 1 | | | theme | varchar(128) | NO | | default | | | attempt_failed | int(11) | NO | | 0 | | | attempt_ip | varchar(39) | NO | | | | | attempt_clock | int(11) | NO | | 0 | | | rows_per_page | int(11) | NO | | 50 | | +----------------+---------------------+------+-----+---------+-------+ 16 rows in set (0.00 sec) mysql> select alias,passwd from users; +-------+----------------------------------+ | alias | passwd | +-------+----------------------------------+ | Admin | 5fce1b3e34b520afeffb37ce08c7cd66 | | guest | d41d8cd98f00b204e9800998ecf8427e | +-------+----------------------------------+ 2 rows in set (0.00 sec) mysql> 從新開個終端,生成一個MD5加密的密碼,這裏密碼設置的是zabbix@123 [root@Zabbix-server ~]# echo -n zabbix@123|openssl md5 (stdin)= 535d82a366525c82b94ba4388ed16fad mysql> update users set passwd="535d82a366525c82b94ba4388ed16fad" where alias="Admin"; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select alias,passwd from users; +-------+----------------------------------+ | alias | passwd | +-------+----------------------------------+ | Admin | 535d82a366525c82b94ba4388ed16fad | | guest | d41d8cd98f00b204e9800998ecf8427e | +-------+----------------------------------+ 2 rows in set (0.00 sec) mysql> 這樣,就將zabbix的admin用戶密碼重置爲"zabbix@123"了
2、zabbix客戶端的操做記錄(192.168.1.7)
安裝Zabbix,配置Zabbix agent:
[root@bastion-IDC ~]# cd /usr/local/src/
[root@bastion-IDC src]# wget -c wget -c http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz/download
[root@bastion-IDC src]# cd zabbix-3.0.3
[root@bastion-IDC zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --enable-agent
[root@bastion-IDC zabbix-3.0.3]# make && make install
[root@bastion-IDC zabbix-3.0.3]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
配置zabbix_agentd:
[root@bastion-IDC ~]# groupadd zabbix
[root@bastion-IDC ~]# useradd -g zabbix zabbix
[root@bastion-IDC ~]# mkdir -p /usr/local/zabbix/logs
[root@bastion-IDC ~]# chown zabbix:zabbix -R /usr/local/zabbix/
[root@bastion-IDC ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
[root@bastion-IDC ~]# cat /usr/local/zabbix/etc/zabbix_agentd.conf
...
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=192.168.1.30
ListenPort=10050
ServerActive=192.168.1.30
Hostname=192.168.1.7 [#在192.168.1.7本機的/etc/hosts裏作主機映射:「ip hostname」][也能夠設置公網ip]
Timeout=15
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
...
配置Zabbix Agent啓動腳本:
[root@bastion-IDC ~]# cat /etc/init.d/zabbix_agentd
...
prog="Zabbix Agent"
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"
CONF_FILE="/usr/local/zabbix/etc/zabbix_agentd.conf"
...
start() {
...
daemon $ZABBIX_BIN -c $CONF_FILE
...
}
...
開啓防火牆端口10050:
[root@bastion-IDC ~]# cat /etc/sysconfig/iptables
...
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
...
[root@bastion-IDC ~]# /etc/init.d/iptables restart
啓動zabbix_agentd:
[root@bastion-IDC ~]# /etc/init.d/zabbix_agentd start
Starting Zabbix Agent: [ OK ]
配置開機自動啓動:
[root@bastion-IDC ~]# chkconfig --add zabbix_agentd
[root@bastion-IDC ~]# chkconfig --level 35 zabbix_agentd on
測試下zabbix agent是否正常工做:
[root@bastion-IDC ~]# /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf -t system.uptime
system.uptime [u|68301]
==========================zabbix客戶機一鍵安裝和配置的腳本==============================
[root@yum ~]# vim zabbix_agent_install.sh #!/bin/bash host=`hostname` /usr/sbin/useradd zabbix cd /usr/local/ /usr/bin/wget http://192.168.10.55/software/zabbix_agent.tar.gz /bin/tar -zvxPf zabbix_agent.tar.gz /bin/rm -f zabbix_agent.tar.gz /bin/chown -R zabbix.zabbix zabbix/ sed -i "s/Hostname=127.0.0.1/Hostname=`hostname`/g" /usr/local/zabbix/etc/zabbix_agentd.conf /bin/cp zabbix/zabbix_agentd /etc/rc.d/init.d/ /bin/cp zabbix/zabbix_agentd /etc/init.d/ /bin/chmod 755 /etc/rc.d/init.d/zabbix_agentd /bin/chmod 755 /etc/init.d/zabbix_agentd chattr -ai /etc/sudoers chmod 640 /etc/sudoers echo "zabbix ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers chmod 440 /etc/sudoers chattr +ai /etc/sudoers
#/etc/init.d/zabbix_agentd start /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf echo "/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf" >> /etc/rc.local ========================================================================================= 賦予腳本執行權限,並執行腳本進行安裝和配置 [root@yum ~]# chmod 755 zabbix_agent_install.sh [root@yum ~]# sh -x zabbix_agent_install.sh 檢查zabbix_agent的安裝狀況 [root@yum ~]# ll -d /usr/local/zabbix drwxr-xr-x 9 zabbix zabbix 4096 12月 25 13:06 /usr/local/zabbix [root@yum ~]# lsof -i:10050 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME zabbix_ag 119763 zabbix 4u IPv4 677580 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 119764 zabbix 4u IPv4 677580 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 119765 zabbix 4u IPv4 677580 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 119766 zabbix 4u IPv4 677580 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 119767 zabbix 4u IPv4 677580 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 119768 zabbix 4u IPv4 677580 0t0 TCP *:zabbix-agent (LISTEN) [root@yum ~]# ps -ef|grep zabbix_agent zabbix 119763 1 0 2017 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf zabbix 119764 119763 0 2017 ? 00:17:05 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec] zabbix 119765 119763 0 2017 ? 00:01:47 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection] zabbix 119766 119763 0 2017 ? 00:01:46 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection] zabbix 119767 119763 0 2017 ? 00:01:47 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection] zabbix 119768 119763 0 2017 ? 00:00:13 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec] root 159646 159567 0 16:50 pts/0 00:00:00 grep zabbix_agent ========================================================================================= 上面腳本中的須要注意的: 0)zabbix server端的zabbix_agentd.conf文件裏Server和ServerActive都配置成zabbix server端ip地址,主動和被動模式都採用。 1)在zabbix的server端將編譯安裝並配置好的目錄(好比/usr/local/zabbix,裏面包括zabbix_agent的配置)進行打包,打包後的命令爲zabbix_agent.tar.gz (或者能夠將server端zabbix編譯安裝和配置的目錄只保留agent的部分進行打包),打包後存放地址爲:http://10.0.8.40:8001/zabbix_agent.tar.gz 2)將zabbix_agentd.conf文件中的Hostname部分配置成agent客戶機的主機名。因爲我在線上部署了內網DNS域名環境,全部機器的DNS域名地址都修改成內網 dns的地址,因此這裏將Hostname直接修改成內網DNS解析後的主機域名就能夠了。可是要千萬注意:zabbix的web界面的"配置"->"主機"的主機名必定也要 寫成一致的主機名(二者配置必定要一致,要麼都是ip,要麼都是主機名)
-----------------------------------------------------------------------------------------------------------------------------
登陸zabbix,先在「配置」-「主機」裏添加主機監控,監控os資源:內存,cpu,io,負載,帶寬等.
注意:下圖中的「主機名稱」要和zabbix_agentd.conf文件中設置的「Hostname」後面的名稱一致!
配置過一段時間後,觀察下監控圖效果出來了沒:
------------------------------------------------------------------------
在zabbix界面中,默認要查看多個主機的監控數據時須要不停的切換。其實能夠在一個頁面中批量查看多個主機的監控項的數據,這就須要使用Screen方法(Screen 的方法是將每一個item的graph放到一個屏幕上,即在聚合圖形裏選擇要放在一個screen裏的圖形,事先建立一個拓撲圖。注意選擇磁盤空間監控項的圖形時,圖形樣式調整「層積「顯示),可是看起來不夠明晰;最好是將各機器的同一item放到同一個graph裏。好比一個Nginx的組裏有10臺機器,將這10臺機器的內存使用率放到一個graph裏,方便在測試時查看。
在zabbix的前端要建立此類的graph只能經過手工一個一個的加,不能建立此類的templates。在網上有批量建立Screen的針對API的python腳本。
-------------------------------------------------------------------------------------------------------------------------
zabbix監控獲取數據的途徑有簡單檢查,zabbix agent,snmp。能夠經過zabbix agent獲取客戶機的cpu、內存、磁盤io等監控數據;可是對於交互機(打印機,路由器等網絡設備)的監控就要用到snmp協議,snmp經過特定的oid值來獲取對應的數據。交換機須要開啓snmp協議,經過snmpwalk 能夠抓取到數據就能夠了(snmpwalk -v 2c -c public *.*.*.*)
------------------------------------------------------------------------------------------------------------------------
使用zabbix的ICMP Ping模版實現對客戶端網絡狀態的監控
如上正確安裝及配置fping,而後在服務端進行zabbix用戶測試fping命令
[root@Zabbix-server ~]# /usr/local/sbin/fping www.baidu.com
www.baidu.com is alive //說明命令返回成功。
接着在zabbix監控界面裏添加主機設置,並選擇添加模版template icmp ping。而後點開這個模塊,能夠選擇想要的監控項的圖形,效果以下:
-----------------------------------------Zabbix監控項CPU Load數值與服務器上uptime的實際值不符合--------------------------------------
現象說明:
zabbix監控項cpu load的數值跟被監控機本地uptime顯示的負載值對不上,前者數值小於後者。
產生緣由:
如今服務器的cpu基本都是多核的,但zabbix監控項cpu load參數裏默認顯示的是一個核心的參數,
而不是總和,因此二者數值對不上。
解決辦法:
"配置"->"模板"->"Template OS Linux"->"監控項"->"Processor load (1 min average per core)"
點開,將system.cpu.load[percpu,avg1]改成system.cpu.load[all,avg1],即將percpu改成all。
其他5 min和15 min的load監控項的改法同樣!保存等幾分鐘便可顯示。
-----------------------------------添加網絡監控項的觸發器(報警設置)--------------------------------
注意:
網絡監控的默認單位是bps,監控報警通常看的是Mbps,須要轉爲爲bps。好比超過8M報警,那觸發器的值即爲8*1024*1024=8388608