zabbix報錯

zabbix報錯  原文:https://www.cnblogs.com/dbslinux/p/9465803.htmlphp

https://www.cnblogs.com/losbyday/category/876878.html做者總結的很全棒html

1.在啓動zabbix-agent 時系統日誌輸出前端

PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after starnode

zabbix-agent.service never wrote its PID file. Failingmysql

重啓zabbix-agent服務依舊不能正常啓動,查看/var/log/zabbix/zabbix-agentd.log 發現系統提示zabbix共享內存報錯linux

zabbix_agentd [5922]: cannot open log: cannot create semaphore set: [28] No space left on deviceios

後經過修改 vim /etc/sysctl.confnginx

kernel.sem =500  64000   64      256git

sysctl -p /etc/sysctl.conf  github

後便可以正常啓動了。(報錯緣由:kernel.sem參數設置太小 ,原先系統默認設置的爲 250 32000 32 128)

參數含義

上面的4個數據分別對應:SEMMSL、SEMMNS、SEMOPM、SEMMNI這四個核心參數,具體含義和配置以下。

SEMMSL :用於控制每一個信號集的最大信號數量。

SEMMNS:用於控制整個 Linux 系統中信號(而不是信號集)的最大數。

SEMOPM: 內核參數用於控制每一個 semop 系統調用能夠執行的信號操做的數量。SE一、Zabbix報警 icmp pinger processes more than 75% busy

1

2

[root@localhost zabbix]#  vi /etc/zabbix/zabbix_server.conf

將這個值設置成StartPingers=5,而後重啓zabbix-server服務。

 

二、zabbix unreachable poller processes more than 75 busy 
unreachable poller processes 一直在處於busy的狀態,那這個具體表明什麼意思呢,查看官方文檔zabbix internal process、unreachable poller - poller for unreachable devices 用於輪詢不可到達到的設備。

可能狀況:
1.經過Zabbix agent採集數據的設備處於moniting的狀態可是此時機器死機或其餘緣由致使zabbix agent死掉server獲取不到數據,此時unreachable poller就會升高。
2.經過Zabbix agent採集數據的設備處於moniting的狀態可是server向agent獲取數據時時間過長,常常超過server設置的timeout時間,此時unreachable poller就會升高。

3.支撐Zabbix的MySQL卡住了,Zabbix服務器的IO卡住了都有可能,Zabbix進程分配到內存不足都有可能。

一個簡單的方法是增長Zabbix Server啓動時初始化的進程數量,這樣直接增長了輪詢的負載量,從比例上來說忙的狀況就少了

1

2

[root@localhost zabbix]#  vi /etc/zabbix/zabbix_server.conf

將這個值設置成StartPollers=500,而後重啓zabbix-server服務。也能夠定時重啓zabbix服務。

 

三、Zabbix alerter processes more than 75% busy 
收到幾百條zabbix告警信息:
Zabbix alerter processes more than 75% busy

可能緣由:
zabbix的數據庫問題
zabbix服務器的IO負載
zabbix進程分配到內存不足
網絡延時或者不通

 

處理方法:

1

2

3

4

5

6

[root@localhost zabbix] vim /etc/zabbix/zabbix_server.conf 

將其默認值5修改成20:

StartPollers=500

修改的位置

# StartDiscoverers=1

StartDiscoverers=100

 

四、zabbix-server服務掛了,啓動後又自動停機了,而且日誌中不少下面這個錯誤

報警提示

Zabbix value cache working in low memory mode
Less than 25% free in the configuration cache

1

2

3

4

5

6

7

8

[root@localhost zabbix] cat /var/log/zabbix/zabbix_server.log

6278:20180320:190117.775 using configuration file: /etc/zabbix/zabbix_server.conf

6278:20180320:190117.807 current database version (mandatory/optional): 03020000/03020001

6278:20180320:190117.807 required mandatory version: 03020000

6278:20180320:190118.378 __mem_malloc: skipped 0 asked 136 skip_min 4294967295 skip_max 0

6278:20180320:190118.378 [file:dbconfig.c,line:653] zbx_mem_malloc(): out of memory (requested 136 bytes)

6278:20180320:190118.378 [file:dbconfig.c,line:653] zbx_mem_malloc(): please increase CacheSize configuration parameter

6354:20180320:190128.632 Starting Zabbix Server. Zabbix 3.2.10 (revision 74337).

 

1

2

3

4

5

6

7

8

9

10

11

12

13

[root@localhost zabbix] vi /etc/zabbix/zabbix_server.conf

### Option: CacheSize

#       Size of configuration cache, in bytes.

#       Shared memory size for storing host, item and trigger data.

#

# Mandatory: no

# Range: 128K-8G

# Default:

# CacheSize=8M

CacheSize=2048M

 

[root@localhost zabbix]# systemctl restart zabbix-server

備註:今天批量添加了700臺主機,形成內存溢出。

 

五、zabbix-server日誌報錯,提示connection to database 'zabbix' failed: [1040] Too many connections錯誤,mariadb正常。想到應該是mysql最大鏈接數問題。

修改mysql最大鏈接數的連接:http://blog.51cto.com/net881004/2089198

 

六、報警提示More than 100 items having missing data for more than 10 minutesZabbix poller processes more than 75% busy錯誤。

修改配置文件增大線程數和緩存

1

2

3

4

5

6

7

8

9

10

11

12

[root@localhost zabbix]#  vim /usr/local/zabbix/etc/zabbix_server.conf

StartPollers=500

StartPollersUnreachable=50

StartTrappers=30

StartDiscoverers=6

CacheSize=1G

CacheUpdateFrequency=300

StartDBSyncers=20

HistoryCacheSize=512M

TrendCacheSize=256M

HistoryTextCacheSize=80M

ValueCacheSize=1G

 

七、server日誌不少first network error, wait for 15 seconds報錯

server配置文件Timeout時間改大點,我改爲了30s。

 

八、zabbix告警「Zabbix poller processes more than 75% busy」(網友)
告警緣由:
1.某個進程卡住了,
2.殭屍進程出錯,太多,致使慢了
3.網絡延遲(可忽略)
4.zabbix消耗的內存多了

告警危害:
普通告警,暫無危害(可是最好處理)

處理方法:
一:簡單,粗暴(重啓zabbix-server可結合定時任務使用)
service zabbix-server restart
crontab -e 調出Cron編輯器中增長一個計劃:
@daily service zabbix-server restart > /dev/null 2>&1

二:編輯Zabbix Server的配置文件/etc/zabbix/zabbix_server.conf,找到配置StartPollers的段落:
### Option: StartPollers
#       Number of pre-forked instances of pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPollers=5
取消StartPollers=一行的註釋或者直接在後面增長:
StartPollers=10
將StartPollers改爲多少取決於服務器的性能和監控的數量,將StartPollers設置成12以後就再沒有遇到過警報。若是內存足夠的話能夠設置更高。

 

九、早上收到不少報警郵件,官網訪問不了,不少服務器端口不通。可是用手機訪問官網卻能夠訪問,郵件裏面不少Zabbix alerter processes more than 75% busy、Zabbix http poller processes more than 75% busy、和端口不通的報警信息。

因爲以前優化過zabbix配置,因此以爲應該不是zabbix配置的問題。多是那時候zabbix所在網絡不通或者延時形成的(確認後是機房那邊網絡斷開了2個小時,恢復後這些報警信息才發送出來了)。看來要針對zabbix服務器自己在異地作個監控,有時間弄個nagios看看。

MMNI :內核參數用於控制整個 Linux 系統中信號集的最大數量。

10.②報錯:No route to host處理

今天在客戶端配置Zabbix_agentd後,經過自動註冊到 Zabbix_Server 頁面中,點擊主機列表卻發現ZBX顯示紅色,沒法被監控到,查看報錯爲:

No route to host

在客戶端telnet服務端的10051端口發現沒有問題,服務端telnet 客戶端10050端口報錯:
telnet 1.1.1.1 10050
Trying 1.1.1.1...
telnet: connect to address 120.27.241.253: No route to host
原來是被客戶端的防火牆檔掉了,關閉客戶端防火牆或者配置相應規則便可

11.④zookeeper不出圖

查看日誌/var/log/zabbix/zabbix_agentd.log,大量的報錯

1404:20161225:183259.913 active check configuration update from [1.1.1.1:10051] started to fail (ZBX_TCP_READ() timed out)

原來是zabbix_sender須要主動向服務器發送數據,而zabbix-server端的10051端口被防火牆擋住了,從新放行端口問題解決

12.zabbix安裝完成後啓動提示錯誤

[root@bogon zabbix-2.2.2]# /usr/local/zabbix-2.2.2/sbin/zabbix_server 
/usr/local/zabbix-2.2.2/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

 

這是由於找不到 libmysqlclient.so.16 文件所致,能夠查找mysql的安裝目錄,找到此文件而後作一個軟連接便可:

ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib

或者打開  /etc/ld.so.confrs 文件

   vim  /etc/ld.so.confrs

        在其中添加:

            /usr/local/mysql/lib

13.Received empty response from Zabbix Agent at [127.0.0.1]. Assuming that agent dropped connection because of access permissions.

意思是說沒有權限訪問agent端口10050,解決方法以下:

將server的agent連接IP 127.0.0.1修改成本機IP

重啓服務

14.# systemctl restart zabbix-server

======================================

Zabbix discoverer processes more than 75% busy

 

增長Zabbix Server啓動時初始化的進程數量,這樣直接增長了輪詢的負載量,從比例上來說忙的狀況就少了

[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf

修改成

StartDiscoverers=5

重啓

[root@zabbix-server ~]# systemctl restart zabbix-server

======================================

15.zabbix-agent沒法啓動錯誤

# tail -20 /var/log/zabbix/zabbix_agentd.log

.........................

zabbix_agentd [1232]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory

zabbix_agentd [3847]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory

zabbix_agentd [1724]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [13] Permission denied

解決

[root@elkstack ~]# mkdir -p /var/run/zabbix/

[root@elkstack ~]# chown zabbix.zabbix /var/run/zabbix/

[root@elkstack ~]# systemctl restart zabbix-agent.service

16.Web頁面報錯總結

 

 問題一Zabbix alerter processes more than 75% busy

問題緣由:

zabbix服務器郵件進程繁忙致使的,通常是由於設置動做的間隔過短。特殊狀況下會產生大量告警,如服務器發幾萬封郵件過程當中,郵件進程發掛了

解決方案:

01.刪除數據庫解決(風險較大,不建議)

02.修改郵件腳本,將郵件的動做改成打印時間,等待郵件徹底釋放再改回來,以下

 1 [root@m01 ~]# cat /usr/lib/zabbix/alertscripts/sms 2 3 #!/bin/bash 4 5 echo `date` >>/tmp/sms.txt 

3.2 問題二Zabbix discoverer processes more than 75% busy

問題緣由:

01.配置了discovery自動發現任務,配置的每一個discovery任務在必定時間內佔用1個進程,而zabbix_server.conf中默認配置只有1個discovery(被註釋,默認生效)

02.爲了快速驗證自動發現效果,將discovery任務的"Delay"由默認3600s設置成60s

解決方案:

01.修改配置文件中的StartDiscoverers進程數量,取消其以前的#號並將數值修改成5,最後重啓服務

(注:根據系統硬件配置,能夠設置成更高的數值,但其範圍爲0~250)

1 [root@m01 ~]# grep 'StartDiscoverers' /etc/zabbix/zabbix_server.conf2 3 ### Option: StartDiscoverers4 5 StartDiscoverers=56 7 [root@m01 ~]# systemctl restart zabbix-server.service

02.編寫定時任務腳本重啓zabbix_server來下降負載

1 [root@m01 ~]# crontab -e2 3 @daily service zabbix-server restart > /dev/null 2>&14 5 #計劃會天天自動重啓Zabbix服務以結束殭屍進程並清理內存等

3.3 問題三Zabbix poller processes more than 75% busy

問題緣由:

01.經過Zabbix agent採集數據的設備死機或其餘緣由致使zabbix agent死掉server獲取不到數據

02. server向agent獲取數據時時間過長,超過了server設置的timeout時間

解決方案:

01.增長Zabbix Server啓動時初始化的進程數量

 1 ### Option: StartPollers 2 3 StartPollers=10 #改爲多少取決於服務器的性能和監控的數量,若是內存足夠的話能夠設置更高 

02.修改模板自動發現規則中的保留失去的資源期間爲0

3.4 問題四Zabbix housekeeper processes more than 75% busy

問題緣由:

爲了防止數據庫持續增大,zabbix有自動刪除歷史數據的機制即housekeeper,而mysql刪除數據時性能會下降,就會報錯

解決方案:

調整HousekeepingFrequency參數

 1 HousekeepingFrequency=12 #間隔時間 2 3 MaxHousekeeperDelete=1000000 #最大刪除量 

3.5 問題五Zabbix server內存溢出,沒法啓動

問題緣由:

zabbix使用一段時間後,再次加入一批交換機監控,zabbix-server將沒法啓動,查看日誌顯示以下(提示內存溢出,需調整zabbix服務器配置zabbix_server.conf)

1 2816:20170725:174352.675 [file:dbconfig.c,line:652] zbx_mem_realloc(): out of memory (requested 162664 bytes)2 3 2816:20170725:174352.675 [file:dbconfig.c,line:652] zbx_mem_realloc(): please increase CacheSize configuration parameter

解決方案:

 1 vim zabbix_server.conf 2 3 CacheSize=1024M #默認爲8M 

3.6 PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 11 bytes)

問題緣由:

zabbix某些頁面沒法打開,查看php日誌發現,當訪問這個頁面時報錯內存不足

解決方案:

不清楚是否內存泄露,最簡單的方法是調大php進程的可用內存

 1 [root@zabbix-master ~]# grep 'memory_limit' /etc/httpd/conf.d/zabbix.conf 2 3 php_value memory_limit 512M #默認128M 

17.、cannot connect to [[172.16.2.225]:10050]: [113] No route to host

這種通常是網絡鏈接問題

排查:在server上telnet 172.16.2.225 10050,是一樣的報錯,查看是否關閉iptables和selinux

18.zabbix server is not running: the information displayed may not be current.

排查:編輯zabbix.conf.php文件,把$ZBX_SERVER的原來的值localhost改成本機的IP地址。

vim /etc/zabbix/web/zabbix.conf.php
$ZBX_SERVER = '172.16.2.116'; 

19.一、打開zabbix web界面點擊profile出現如下報錯信息:

scandir() has been disabled for security reasons [profile.php:198 → CView->

解決:

php環境中把scandir寫在了disable_functions中。在php.ini文件把disable_functions中的scandir去掉便可。

(重啓php-fpm和nginx)

二、添加windows監控時候報錯:

Get value error: ZBX_TCP_READ() failed: [104] Connection reset by peer

解決:windows下agentd.conf文件IP地址不對

三、zabbix打開既然沒有任何數據顯示

我用360安全瀏覽器使用打開沒有任何數據顯示,然而用IE打開zabbix數據就能正常的顯示呈現。

四、搞微信報警按照前輩們操做http://www.ttlsa.com/linux/zabbix-wechat-onalert-20/,在最後一步添加actions的時候老是不成功既然出現

ERROR: Page received incorrect data

不知緣由

五、配置zabbix-server監控IPMI

編譯加--with-openipmi參數報錯。

configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h

     解決:需提早安裝

  1. yum install net-snmp-devel OpenIPMI OpenIPMI-devel rpm-build

20.0x01  zabbix_server dead but subsys locked錯

今天把Zabbix版本從3.2升級到了3.4。但在啓動Zabbix_Server時出現了"zabbix_server dead but subsys locked"的錯誤狀態。

一、問題緣由

在查看了zabbix_server日誌,發現日誌裏有下面的告警

zbx_mem_malloc(): out of memory (requested 256 bytes) zbx_mem_malloc(): please increase CacheSize configuration parameter 

錯誤緣由寫的很明白,內存溢出,請調整CacheSize大小。

二、問題解決

編輯zabbix_server.conf配置文件,定位到CacheSize關鍵字位置,而後調高CacheSize大小,大小根據本身環境調整

# Size of configuration cache, in bytes. # Shared memory size for storing host, item and trigger data. # Mandatory: no # Range: 128K-8G # Default: CacheSize=32M 

最後重啓zabbix_server服務便可。

0x02  Zabbix value cache working in low memory mode錯誤

問題解決:

編輯zabbix_server.conf配置文件,定位到ValueCacheSize關鍵字位置,而後調高ValueCacheSize大小,大小根據本身環境調整

# Option: ValueCacheSize # Size of history value cache, in bytes. # Shared memory size for caching item history data requests. # Setting to 0 disables value cache. # # Mandatory: no # Range: 0,128K-64G # Default: ValueCacheSize=2048M

21.2、錯誤解決:
1.安裝zabbix時發生的錯誤:
①錯誤:編譯zabbix時老是提示gcc not find之類
 解決:安裝development tools,命令:
   yum -y groupinstall "Delvelopment Tools"
②錯誤:編譯zabbix時提示mysqlclient not find之類
   解決:安裝mysql-devel,命令:
   yum -y install  mysql-devel
③錯誤:輸入127.0.0.1/zabbix/setup.php提示403forbidden
   解決:關閉Selinux,使用setenforce 0命令,或者vim /etc/selinux/config,將SELINUX=enforcing改成SELINUX=disabled,再    重啓linux便可。

2.使用過程當中發生的錯誤:
①錯誤:zabbix運行狀態顯示no,未運行
   解決:首先檢查是否zabbix服務未啓動,使用/etc/init.d/zabbix_server start啓動zabbix服務;
             若是仍是錯誤,vim/var/www/html/zabbix/conf/zabbix.conf.php,將配置文件中的$ZBX_SERVER字段爲服務器的IP地        址,默認是127.0.0.1,而後重啓zabbix_server服務;
②錯誤:zabbix出現zabbix agent unreachable警告。
   解決:vim /usr/local/etc/zabbix_agentd.conf,(看我的狀況選擇路徑)查看Hostname與組態--主機--主機名稱是否相同,若是不一樣更    改主機名稱,將Server改成ip。

③錯誤:zabbix出現Lack of free swap space警告
 解決:1.檢查 Swap 空間,
       命令:free -m

                若是返回的信息概要是空的,則表示 Swap 文件不存在。

    2.檢查文件系統,
     命令df-hal
      檢查返回的信息,還剩餘足夠的硬盤空間便可。
    3.建立並容許 Swap 文件,
     命令dd if=/dev/zero of=/swapfile bs=1024 count=2048000

     參數解讀:
       if=文件名:輸入文件名,缺省爲標準輸入。即指定源文件。< if=input file >
     of=文件名:輸出文件名,缺省爲標準輸出。即指定目的文件。< of=output file >
     bs=bytes:同時設置讀入/輸出的塊大小爲bytes個字節
     count=blocks:僅拷貝blocks個塊,塊大小等於bs指定的字節數。
    4.格式化並激活 Swap 文件,
     命令:格式化Swap:   mkswap  /swapfile

        激活Swap:    swapon /swapfile

        查看Swap:    swapon -s
        修改 fstab 配置: vim /etc/fstab ,在最後加上/swapfile   swap    swap    defaults    0   0
        受權:      chown root:root  /swapfile
                 chmod 0600   /swapfile
④錯誤:zabbix自定義key顯示未啓用,log中顯示bad interpreter錯誤
 解決:在windows用創建的sh文件在linux中運行時,由於window在每行後加入隱藏字符^M,因此當linux編譯時 因爲沒法編譯^M而導  致bad interpreter錯誤,使用 vi -b <file name> 找出^M 而後刪除便可。

22.Zabbix 是一個基於WEB界面的企業級開源分佈式監控軟件,很多人在部署和配置zabbix時會重複遇到各類坑,臨時解決後又忘記作記錄,這是很是很差的習慣,技術一流彙總一下常見錯誤的解決方法供你們參考。

問題一:

使用源代碼安裝以後, 在zabbix的網頁上不能使用MySQL數據庫

解決方法:zabbix須要php支持mysqli; 使用源碼安裝php時須要加上–with-mysqli=mysqlnd參數以後在網頁能夠顯示。

問題二:在./configure時,提示configure: error: Invalid Net-SNMP directory – unable to find net-snmp-config

解決方法:執行 yum install -y net-snmp-devel libxml2-devel libcurl-devel

問題三:在zabbix網頁上填寫MySQL信息後下一步提示The frontend does not match Zabbix database.報錯

解決方法:確認mysql帳號信息無誤後,再檢查初始化zabbix庫是否成功,若還報錯則從新初始化zabbix數據庫。

問題四:網頁安裝zabbix提示要下載配置文件:Unable to create the configuration file.

 

解決方法:設置 web服務器用戶在zabbix網頁的conf/目錄具備寫權限,配置文件會自動保存。

問題五:zabbix安裝完成後,在管理後臺>admin我的資料頁面沒法選擇中文語言

解決方法:修改zabbix網站目錄下的zabbix/include/locales.inc.php文件中的中文支持(默認存在中文語言支持的)

找到 ‘zh_CN’ => [‘name’ => _(‘Chinese (zh_CN)’),     ‘display’ => false],  將false改成true

問題六:後臺修改語言爲中文後,圖形的漢字顯示爲方格亂碼

解決方法:[root@eazence ~]# cd /etc/nginx/html/zabbix/fonts/  #這個是存放zabbix網頁的字體路徑

[root@eazence fonts]# ls

DejaVuSans.ttf

[root@eazence fonts]# wget -c http://www.138096.com/simkai.ttf

[root@eazence fonts]# cp -p DejaVuSans.ttf DejaVuSans.ttf.bak

[root@eazence fonts]# mv -f simkai.ttf DejaVuSans.ttf     #完成這一步後刷新網頁便可

23.(1)在Zabbix的Dashboard中Status of Zabbix的:

Zabbix server is running's value is "No"

解決思路,考慮是Zabbix Server的配置文件中鏈接數據庫的帳戶對zabbix數據庫的權限不夠,修改帳戶的對數據庫的權限;

 

(2)ITEM收取不到數據,並報一下錯誤:

Received value [0.05] is not suitable for value type [Numeric (unsigned)] 

解決思路,修改Zabbix Server配置文件中CacheSize的默認值,儘可能提高;

或者是ITEM的配置中Type of information配置的有誤,修改成合適的格式

24.導入percona模版報錯

 Import failed

    Invalid XML tag "/zabbix_export/date": "YYYY-MM-DDThh:mm:ssZ" is expected.解決辦法

將zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml導入zabbix2.4中再導出。以後將新的導出xml導入到3.0中問題解決。

從zabbix3.0導出的percona模板:Percona-MySQL-Server-Template

25.Zabbix Server忽然掛了,查看log報錯以下:

using configuration file: /etc/zabbix/zabbix_server.conf...[file:dbconfig.c,line:545] zbx_mem_malloc(): out of memory (requested 16 bytes)[file:dbconfig.c,line:545] zbx_mem_malloc(): please increase CacheSize configuration parameter

報錯裏已經很明確的提示了修復辦法:please increase CacheSize configuration parameter

因此,咱們就去zabbix_server.conf中找到CacheSize字段

### Option: CacheSize#   Size of configuration cache, in bytes.#   Shared memory size for storing host, item and trigger data.## Mandatory: no# Range: 128K-8G# Default:# CacheSize=8M

根據服務器配置狀況,修改CacheSize

### Option: CacheSize#   Size of configuration cache, in bytes.#   Shared memory size for storing host, item and trigger data.## Mandatory: no# Range: 128K-8G# Default:CacheSize=2048M

重啓Zabbix Server便可

26.Zabbix日誌錯誤總結

zabbix_agentd.log  

錯誤一 

 no active checks on server [*.*.*.*:10051]: host [*] not found

出現該錯誤的緣由是通常是zabbix_agentd.conf裏面的Hostname和前端zabbix web(Monitoring->Configuration->Hosts 頁面的Name)裏面的配置不同所形成的

解決:在zabbix web頁面Monitoring->Configuration->Hosts 頁面更改Host name和zabbix_agentd.conf裏面的Hostname同樣。

錯誤二activecheck configuration update from [127.0.0.1:10051] started to fail (cannotconnect to [[127.0.0.1]:10051]: [111] Connection refused)

解決:上面標註的地方有報錯,咱們能夠編輯etc/zabbix/zabbix_agentd.conf 註釋掉#ServerActive=127.0.0.1而且重啓zabbix agent便可。

zabbix_server.log        

一、failed to accept an incoming connection: connection from "*。*。*。*" rejected, allowed hosts: "127.0.0.1"    這個是 zabbix_agentd.conf 文件配置錯誤的提示,好好檢查一下

# vim /usr/local/zabbix/etc/zabbix_agentd.conf

修改 :

Server=你的服務器地址ServerActive=你的服務器地址

Hostname=你的客戶端名稱

27.zabbix_agentd.log  

錯誤一 

 no active checks on server [*.*.*.*:10051]: host [*] not found

出現該錯誤的緣由是通常是zabbix_agentd.conf裏面的Hostname和前端zabbix web(Monitoring->Configuration->Hosts 頁面的Name)裏面的配置不同所形成的

解決

在zabbix web頁面Monitoring->Configuration->Hosts 頁面更改Host name和zabbix_agentd.conf裏面的Hostname同樣。

 

 

錯誤二activecheck configuration update from [127.0.0.1:10051] started to fail (cannotconnect to [[127.0.0.1]:10051]: [111] Connection refused)解決:

上面標註的地方有報錯,咱們能夠編輯etc/zabbix/zabbix_agentd.conf 註釋掉#ServerActive=127.0.0.1而且重啓zabbix agent便可

28.failed to accept an incoming connection: connection from "*。*。*。*" rejected, allowed hosts: "127.0.0.1"  

這個是 zabbix_agentd.conf 文件配置錯誤的提示,好好檢查一下

# vim /usr/local/zabbix/etc/zabbix_agentd.conf

修改 :

Server=你的服務器地址 ServerActive=你的服務器地址 Hostname=你的客戶端名稱

 尤爲是Hostname

zabbix_agentd.conf裏面的Hostname必須和web管理界面主機名稱同樣

配置----主機---要監控的主機---主機名稱

 

29.登陸Zabbix以前,卻確認Nginx服務打開,php-fpm打開,service zabbix_server start server_agentd start

意外斷電Zabbix登陸出現以下錯誤

Database error

  • Error connecting to database: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

沒法鏈接到數據庫,請確認數據庫是否開啓

 

當我要開啓數據庫服務的時候,數據庫又出錯,由於我沒有開啓熱備份。。。。

[root@dep5 ~]# service mysqld statusMySQL is not running, but lock file (/var/lock/subsys/mysql[失敗]ts[root@dep5 ~]# service mysqld startStarting MySQL...The server quit without updating PID file [失敗]mysql.pid).

 

#查看日誌 #[root@dep5 ~]# vim /data/mysqldb/log/mysql-error.log 2016-09-03 16:26:43 10550 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace zabbix/groups uses space ID: 3 at filepath: ./zabbix/groups.ibd. Cannot open tablespace mysql/slave_relay_log_info which uses space ID: 3 at filepath: ./mysql/slave_relay_log_info.ibd2016-09-03 16:26:43 7f4097e0a720  InnoDB: Operating system error number 2 in a file operation.InnoDB: The error means the system cannot find the path specified.InnoDB: If you are installing InnoDB, remember that you must createInnoDB: directories yourself, InnoDB does not create them.InnoDB: Error: could not open single-table tablespace file ./mysql/slave_relay_log_info.ibdInnoDB: We do not continue the crash recovery, because the table may becomeInnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.InnoDB: To fix the problem and start mysqld:InnoDB: 1) If there is a permission problem in the file and mysqld cannotInnoDB: open the file, you should modify the permissions.InnoDB: 2) If the table is not needed, or you can restore it from a backup,InnoDB: then you can remove the .ibd file, and InnoDB will do a normalInnoDB: crash recovery and ignore that table.InnoDB: 3) If the file system or the disk is broken, and you cannot removeInnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnfInnoDB: and force InnoDB to continue crash recovery here.160903 16:26:43 mysqld_safe mysqld from pid file /tmp/mysql.pid ended

 

mysql 日誌中給出了猜想和各自的解決方案

1)權限問題,修改權限就OK

2)就是說你不須要這些表的話,清空表,刪除.ibd文件,就會恢復(這樣的話你的zabbix也會沒有,我想一下第三種方法)

3)如富哦這是文件系統或者磁損壞,你不能移除,你能夠在你的my.cnf裏面將設置innodb_force_recovery > 0,強制InnoDB引擎來.....

解決:

 

[root@dep5 ~]# vim /etc/my.cnf#innodbinnodb_file_per_table = 1innodb_data_file_path = ibdata1:2048M:autoextendinnodb_log_file_size = 128minnodb_log_files_in_group = 3innodb_buffer_pool_size = 60Minnodb_buffer_pool_instances = -1innodb_max_dirty_pages_pct = 70#innodb_thread_concurrency = 8innodb_flush_method = O_DIRECTinnodb_log_buffer_size = 16minnodb_flush_log_at_trx_commit = 2innodb_force_recovery = 1  #添加這個就Ok了


#[root@dep5 ~]# vim /etc/my.cnf 
#[root@dep5 ~]# service mysqld start
#Starting MySQL.......   

 

我看了一下啓動成功以後的數據庫日誌有以下片斷,猜想Zabbix沒法正常打開=  =

 

2016-09-03 16:41:33 18646 [Warning] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened.2016-09-03 16:41:33 18646 [Warning] InnoDB: Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.2016-09-03 16:41:33 18646 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.2016-09-03 16:41:33 18646 [Warning] Info table is not ready to be used. Table 'mysql.slave_relay_log_info' cannot be opened.2016-09-03 16:41:34 18646 [Note] Event Scheduler: Loaded 0 events2016-09-03 16:41:34 18646 [Note] /usr/local/mysql/bin/mysqld: ready for connections.Version: '5.6.31-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution2016-09-03 16:41:34 18646 [Note] Event Scheduler: scheduler thread started with id 12016-09-03 16:41:39 7feb5261e700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.2016-09-03 16:41:39 7feb5261e700 InnoDB: Error: Fetch of persistent statistics requested for table "zabbix"."users" but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.2016-09-03 16:41:39 7feb5261e700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

 

這個就是Zabbix打開出現的界面,,

 

後面想着註釋在my.cnf添加的哪一行,,

雖然mysql從新啓動是OK了,可是mysql日誌被刷新了一次...

2016-09-03 16:48:11 7f37cdfb7700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.2016-09-03 16:48:11 7f37cdfb7700 InnoDB: Error: Fetch of persistent statistics requested for table "zabbix"."media_type" but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.

我就想着修復表。。。

[root@dep5 ~]# mysqlcheck -r zabbixzabbix.acknowledgesnote     : The storage engine for the table doesn't support repairzabbix.actionsnote     : The storage engine for the table doesn't support repairzabbix.alerts

悲劇了,我猜zabbix數據庫的引擎應該爲myisam,看不到引擎啊。。

使用MySQL5.6或者更高版本,自從MySQL被Oracle收購了,它的性能確實有很多的提高。請必定選擇innodb,別選擇myisam,由於zabbix在innodb的性能比在myisam快1.5倍,並且myisam不安全,zabbix監控數據量很大,一旦表壞了,那就是一個悲劇。

悲劇啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

注意:

畢竟我也是新手,而後能想到的最笨的辦法就是全部重來(沒作配置備份,引擎沒有修改,好尷尬)

最後的處理辦法,閃庫,從新建庫建表,而且從新導入zabbix表把。。想搭建zabbix服務器那樣,前面作了什麼所有清理掉,而後從新來

31.

1.在啓動zabbix-agent 時系統日誌輸出

PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after star

zabbix-agent.service never wrote its PID file. Failing

 

同時經過輸入 systemctl status zabbix-agent.service 看其中提到了selinux,後經過輸入getenforce 發現selinux是打開的,便關閉了selinux

重啓zabbix-agent服務依舊不能正常啓動,查看/var/log/zabbix/zabbix-agentd.log 發現系統提示zabbix共享內存報錯

zabbix_agentd [5922]: cannot open log: cannot create semaphore set: [28] No space left on device

如圖:

 

後經過修改 vim /etc/sysctl.conf

kernel.sem =500  64000   64      256

sysctl -p /etc/sysctl.conf  後便可以正常啓動了。(報錯緣由:kernel.sem參數設置太小 ,原先系統默認設置的爲 250 32000 32 128)

參數含義

上面的4個數據分別對應:SEMMSL、SEMMNS、SEMOPM、SEMMNI這四個核心參數,具體含義和配置以下。

1.SEMMSL :用於控制每一個信號集的最大信號數量。

2.SEMMNS:用於控制整個 Linux 系統中信號(而不是信號集)的最大數。

3.SEMOPM: 內核參數用於控制每一個 semop 系統調用能夠執行的信號操做的數量。

4.SEMMNI :內核參數用於控制整個 Linux 系統中信號集的最大數量。

32.1.zabbix儀表板錯誤

問題:
zabbix server is not running: the information displayed may not be current
解決方案:

幾種狀況都有可能引發這個錯誤:1)多是zabbix-server未安裝zabbix-agent;或者安裝了卻沒有檢測到agent的端口2)

 

2.日誌報錯

問題:
172730.555 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for
解決方案:

#修改配置文件shell->vim/etc/zabbix/zabbix-server.confDBPassword=zabbix#重啓服務shell->/etc/init.d/zabbix-server restart#再次查看日誌shell->tail -f /var/log/zabbix/zabbix-server.log

 

3. 提示沒有中文環境

問題:
You are not able to choose some of the languages, because locales for them are not installed on the

解決方案:

一、啓用中文

    vi /usr/share/zabbix/include/locales.inc.php    把zh_CN後面參數寫true 而後去web界面選擇語言。    若是,去選擇語言的時候,你發現仍是不能選擇.     提示:    You are not able to choose some of the languages, because locales for them are not installed on the web server.    是由於你係統裏沒中文環境    那麼:設置中文環境    第一步,安裝中文包:    apt-get install language-pack-zh-hant language-pack-zh-hans     第二步,配置相關環境變量:    vi /etc/environment    在文件中增長語言和編碼的設置:    LANG="zh_CN.UTF-8"    LANGUAGE="zh_CN:zh:en_US:en"    第三步,從新設置本地配置:    dpkg-reconfigure locales    如今重啓apache&zabbix_server兩個服務一下,應該能夠選了。。

二、可是我發現翻譯的很差,有大神作了更好的翻譯(未測)

點擊參考

    進入    cd /usr/share/zabbix/locale/zh_CN/LC_MESSAGES目錄    代碼: 全選    wget https://github.com/echohn/zabbix-zh_CN/ ... master.zip    unzip master.zip    rm frontend.mo    cp zabbix-zh_CN-master/frontend.mo frontend.mo     如今重啓apache&zabbix_server兩個服務    service zabbix-server restart    service apache2 restart

三、亂碼問題

看圖時候,若是有中文,會亂碼    調整圖像裏的中文亂碼    下載雅黑    代碼: 全選    wget http://dx.sc.chinaz.com/Files/DownLoad/font2/dd.rar    解壓縮文件    rar x dd.rar    cp dd/msyh.ttf msyh.ttf    而後修改 vi /usr/share/zabbix/include/defines.inc.php    找到    define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name    修改爲:    define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name    cp msyh.ttf /usr/share/zabbix/fonts  #少了這一步則圖形下面沒有字體    重啓apache服務便可

[zabbix3.0使用](http://www.tuicool.com/articles/e2EnMvi)裏面設置字體的地方43行跟93行設爲同樣便可

4.重要的mibs庫,必須更新,不然snmp監控交換機時,mib會報錯。(未測)

    apt-get install snmp-mibs-downloade    ##一些提示 tips    從新啓動zabbix-server服務進程    # service zabbix-server restart    從新啓動zabbix-agent進程    # service zabbix-server restart    重啓apache進程    #service apache2 restart     重要目錄:    log: /var/log/zabbix/zabbix_server/log和agent.log 排查錯誤必須    conf:/etc/zabbix/*.conf    安裝目錄:/usr/share/zabbix 重要的include,font .etc    根web目錄在var/www/html    ###原文:http://www.cnblogs.com/zangdalei/p/5712951.html

 

四、apt-get update更新時報錯

問題:
Failed to fetch
http://ubuntu.kurento.org/dists/trusty/kms6/binary-i386/Packages 403 Forbidden [IP: 112.124.140.210 80]

解決方案:

apt-get update時出現沒有權限(403)的問題,112.124.140.210 是apt代理地址,修改(或者刪除,註釋最好)apt.conf文件,取消掉這個代理就能夠了,固然不用代理的話,您的ubuntu必須可以訪問外網。

 

5.zabbix微信報警時出現

shell腳本中忘記開頭!#/bin/bash 致使手動執行腳本微信能夠發生消息,可是zabbix觸發後action完成可是微信收不到消息!

33.zabbix3.2升級3.4報錯Database error

zabbix3.2版本升級到zabbix3.4版本後打開頁面報錯,報錯內容以下

Database error
The frontend does not match Zabbix database. Current database version (mandatory/optional): 3020000/3020000. Required mandatory version: 3040000. Contact your system administrator.

 

解決辦法:進入數據庫

1

2

3

4

mysql> show databases;

mysql> use zabbix;

mysql> update dbversion set mandatory=3040000;

mysql> flush privileges;

從新打開web便可解決

34.zabbix報錯: cannot connect to [[192.168.119.110]:10050]: [111] Connection refused

 

錯誤分析:Connection refused 拒絕鏈接!

(1)客戶端與服務端網絡不通;

(2)客戶端服務內用防火牆阻隔;

(3)網段內用物理防火牆阻隔。

解決方法:

(1)查看日誌:查看、分析錯誤緣由

root@a-desktop:~# tail /var/log/zabbix-agent/zabbix_agentd.log

  5927:20160913:101039.428 agent #2 started [listener #2]

  5923:20160913:102113.808 Got signal [signal:15(SIGTERM),sender_pid:5999,sender_uid:0,reason:0]. Exiting ...

  5923:20160913:102113.810 Zabbix Agent stopped. Zabbix 2.2.2 (revision 42525).

  6004:20160913:102113.824 Starting Zabbix Agent [Cloud_platform002]. Zabbix 2.2.2 (revision 42525).

  6004:20160913:102113.824 using configuration file: /etc/zabbix/zabbix_agentd.conf

  6005:20160913:102113.824 agent #0 started [collector]

  6006:20160913:102113.825 agent #1 started [listener #1]

  6007:20160913:102113.825 agent #2 started [listener #2]

  6008:20160913:102113.825 agent #3 started [listener #3]

  6009:20160913:102113.825 agent #4 started [active checks #1]

(2)若是是網絡不通,能夠作域名解析或者經過zabbix-agent實現數據收集

 zabbix-agent分佈式監控能夠參考個人另外一篇分享《zabbix分佈式監控(阿里雲zabbix-server,.. 》

(3)若是服務器防火牆

添加規則:iptables -I INPUT -p tcp -m multiport --destination-port 80,10050:10051 -j ACCEPT

(4)物理防火牆

一樣的也是在牆上開個10050的TCP端口

35.sudo bug致使的zabbix斷圖問題

線上使用zabbix的host update來監測監控值是否完整(關於host update的實現請參考:

http://caiguangguang.blog.51cto.com/1652935/1345789)

一直髮現有機器過一段時間update值就會莫名其妙變低,以前一直沒有找到rc,只是簡單經過重啓agent來進行修復,最近同事細心地發現多是和sudo的bug有關係。

回過頭再來驗證下整個的排查過程。

1.經過zabbix 數據庫獲取丟失數據的item,拿出缺失的(20分鐘沒有更新的)值的item列表

1

2

3

select b.key_,b.lastvalue,from_unixtime(b.lastclock) from hosts a,

 items b where a.hostid=b.hostid and a.host='xxxxxx' and 

 b.lastclock < (unix_timestamp() - 1200) limit 10;

好比這裏看agent.ping:

觀察監控圖,發如今18點20分以後數據丟失

 

2.分析zabbix agent端的日誌

發如今18點24粉左右出現下面的日誌,沒有看到正常的獲取值和發送值的狀況,只有大量的update_cpustats狀態,同時發現有一行kill  command 失敗的日誌:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

27589:20141021:182442.143 In zbx_popen() command:'sudo hadoop_stats.sh nodemanager StopContainerAvgTime'

27589:20141021:182442.143 End of zbx_popen():5

48430:20141021:182442.143 zbx_popen(): executing script

27585:20141021:182442.284 In update_cpustats()

27585:20141021:182442.285 End of update_cpustats()

27585:20141021:182443.285 In update_cpustats()

27585:20141021:182443.286 End of update_cpustats()

27585:20141021:182444.286 In update_cpustats()

27585:20141021:182444.287 End of update_cpustats()

27585:20141021:182445.287 In update_cpustats()

27585:20141021:182445.287 End of update_cpustats()

27585:20141021:182446.288 In update_cpustats()

27585:20141021:182446.288 End of update_cpustats()

..........

27585:20141021:182508.305 In update_cpustats()

27585:20141021:182508.305 End of update_cpustats()

27585:20141021:182509.306 In update_cpustats()

27585:20141021:182509.306 End of update_cpustats()

27585:20141021:182510.306 In update_cpustats()

27585:20141021:182510.307 End of update_cpustats()

27585:20141021:182511.307 In update_cpustats()

27585:20141021:182511.308 End of update_cpustats()

27589:20141021:182512.154 failed to kill [sudo hadoop_stats.sh nodemanager StopContainerAvgTime]: [1] Operation not permitted

27589:20141021:182512.155 In zbx_waitpid()

27585:20141021:182512.308 In update_cpustats()

27585:20141021:182512.309 End of update_cpustats()

27585:20141021:182513.309 In update_cpustats()

27585:20141021:182513.309 End of update_cpustats()

對比正常的日誌:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

27589:20141021:180054.376 In zbx_popen() command:'sudo hadoop_stats.sh nodemanager StopContainerAvgTime'

27589:20141021:180054.377 End of zbx_popen():5

18798:20141021:180054.377 zbx_popen(): executing script

27589:20141021:180054.384 In zbx_waitpid()

27589:20141021:180054.384 zbx_waitpid() exited, status:1

27589:20141021:180054.384 End of zbx_waitpid():18798

27589:20141021:180054.384 Run remote command [sudo  hadoop_stats.sh nodemanager StopContainerAvgTime] Result [2] [-1]...

27589:20141021:180054.384 For key [hadoop_stats[nodemanager,StopContainerAvgTime]] received value [-1]

27589:20141021:180054.384 In process_value() key:'gd6g203s80-hadoop-datanode.idc.vipshop.com:hadoop_stats[nodemanager,StopContainerAvgTime]' value:'-1'

27589:20141021:180054.384 In send_buffer() host:'10.200.100.28' port:10051 values:37/50

27589:20141021:180054.384 Will not send now. Now 1413885654 lastsent 1413885654 < 1

27589:20141021:180054.385 End of send_buffer():SUCCEED

27589:20141021:180054.385 buffer: new element 37

27589:20141021:180054.385 End of process_value():SUCCEED

能夠看到正常狀況下腳本會有返回值,而出問題的時候,腳本是沒有返回值的,而且因爲是使用sudo 運行腳本,致使以普通用戶啓動的zabbix在超時時沒有辦法殺掉這個command(Operation not permitted 錯誤)

3.假設這裏啓動zabbix agent的普通用戶爲apps用戶,咱們看下這個腳本目前的狀態

1

2

3

4

ps -ef|grep hadoop_stats.sh

root     34494 31429  0 12:54 pts/0    00:00:00 grep 48430

root     48430 27589  0 Oct21 ?        00:00:00 sudo hadoop_stats.sh nodemanager StopContainerAvgTime

root     48431 48430  0 Oct21 ?        00:00:00 [hadoop_stats.sh] <defunct>

能夠看到,這裏產生了一個殭屍進程(關於殭屍進程能夠參考:http://en.wikipedia.org/wiki/Zombie_process)

殭屍進程是因爲子進程運行完畢以後,發送SIGCHLD到父進程,而父進程沒有正常處理這個信號致使。

1

2

3

4

5

6

7

You have killed the process, but a dead process doesn't disappear from the process table 

until its parent process performs a task called "reaping" (essentially calling wait(3)

 for that process to read its exit status). Dead processes that haven't been reaped are

  called "zombie processes."

The parent process id you see for 31756 is process id 1, which always belongs to init. 

That process should reap its zombie processes periodically, but if it can't, they will

 remain zombies in the process table until you reboot.

正常的進程狀況下,咱們使用strace attach到父進程,而後殺掉子進程後能夠看到以下信息:

1

2

3

4

5

6

7

8

Process 3036 attached - interrupt to quit

select(6, [5], [], NULL, NULL

)          = ? ERESTARTNOHAND (To be restarted)

--- SIGCHLD (Child exited) @ 0 (0) ---

rt_sigreturn(0x11)                      = -1 EINTR (Interrupted system call)

wait4(3037, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGTERM}], WNOHANG|WSTOPPED, NULL) = 3037

exit_group(143)                         = ?

Process 3036 detached

產生殭屍進程以後,能夠經過殺掉父進程把殭屍進程變成孤兒進程(父進程爲init進程)

可是這裏由於是用sudo啓動的腳本,致使啓動用戶都是root,apps用戶就沒有權限殺掉啓動的命令,進而致使子進程一直是殭屍進程的狀態存在

4.來看一下zabbix agent端啓動的相關進程狀況

1

2

3

4

5

6

7

8

9

ps -ef|grep zabbix

apps     27583     1  0 Sep09 ?        00:00:00 /apps/svr/zabbix/sbin/zabbix_agentd -c /apps/conf/zabbix_agentd.conf

apps     27585 27583  0 Sep09 ?        00:33:25 /apps/svr/zabbix/sbin/zabbix_agentd -c /apps/conf/zabbix_agentd.conf

apps     27586 27583  0 Sep09 ?        00:00:14 /apps/svr/zabbix/sbin/zabbix_agentd -c /apps/conf/zabbix_agentd.conf

apps     27587 27583  0 Sep09 ?        00:00:14 /apps/svr/zabbix/sbin/zabbix_agentd -c /apps/conf/zabbix_agentd.conf

apps     27588 27583  0 Sep09 ?        00:00:14 /apps/svr/zabbix/sbin/zabbix_agentd -c /apps/conf/zabbix_agentd.conf

apps     27589 27583  0 Sep09 ?        02:28:12 /apps/svr/zabbix/sbin/zabbix_agentd -c /apps/conf/zabbix_agentd.conf

root     34207 31429  0 12:54 pts/0    00:00:00 grep zabbix

root     48430 27589  0 Oct21 ?        00:00:00 sudo /apps/sh/zabbix_scripts/hadoop/hadoop_stats.sh nodemanager StopContainerAvgTime

經過strace咱們發現27589的進程一直在等待48430的進程

1

2

3

4

strace  -p 27589

Process 27589 attached - interrupt to quit

wait4(48430, ^C <unfinished ...>

Process 27589 detached

而48430的進程即爲殭屍進程的父進程,經過strace attach上去,能夠看到在等待#5的fd

1

2

3

4

strace  -p 48430

Process 48430 attached - interrupt to quit

select(6, [5], [], NULL, NULL^C <unfinished ...>

Process 48430 detached

經過lsof能夠看到#5的fd實際上是一個socket

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

lsof  -p 48430

COMMAND   PID USER   FD   TYPE             DEVICE  SIZE/OFF       NODE NAME

sudo    48430 root  cwd    DIR                8,2      4096          2 /

sudo    48430 root  rtd    DIR                8,2      4096          2 /

sudo    48430 root  txt    REG                8,2    212904    1578739 /usr/bin/sudo

sudo    48430 root  mem    REG                8,2     65928    1441822 /lib64/libnss_files-2.12.so

sudo    48430 root  mem    REG                8,2  99158704    1573509 /usr/lib/locale/locale-archive

sudo    48430 root  mem    REG                8,2     91096    1441832 /lib64/libz.so.1.2.3

sudo    48430 root  mem    REG                8,2    141576    1442145 /lib64/libpthread-2.12.so

sudo    48430 root  mem    REG                8,2    386040    1442172 /lib64/libfreebl3.so

sudo    48430 root  mem    REG                8,2    108728    1575924 /usr/lib64/libsasl2.so.2.0.23

sudo    48430 root  mem    REG                8,2    243064    1441896 /lib64/libnspr4.so

sudo    48430 root  mem    REG                8,2     21256    1442186 /lib64/libplc4.so

sudo    48430 root  mem    REG                8,2     17096    1442187 /lib64/libplds4.so

sudo    48430 root  mem    REG                8,2    128368    1577789 /usr/lib64/libnssutil3.so

sudo    48430 root  mem    REG                8,2   1290648    1582418 /usr/lib64/libnss3.so

sudo    48430 root  mem    REG                8,2    188072    1575925 /usr/lib64/libsmime3.so

sudo    48430 root  mem    REG                8,2    220200    1587191 /usr/lib64/libssl3.so

sudo    48430 root  mem    REG                8,2    113952    1442182 /lib64/libresolv-2.12.so

sudo    48430 root  mem    REG                8,2     43392    1442173 /lib64/libcrypt-2.12.so

sudo    48430 root  mem    REG                8,2     63304    1442180 /lib64/liblber-2.4.so.2.5.6

sudo    48430 root  mem    REG                8,2   1979000    1442169 /lib64/libc-2.12.so

sudo    48430 root  mem    REG                8,2    308912    1442181 /lib64/libldap-2.4.so.2.5.6

sudo    48430 root  mem    REG                8,2     22536    1442171 /lib64/libdl-2.12.so

sudo    48430 root  mem    REG                8,2     58480    1442174 /lib64/libpam.so.0.82.2

sudo    48430 root  mem    REG                8,2     17520    1441884 /lib64/libutil-2.12.so

sudo    48430 root  mem    REG                8,2    124624    1441798 /lib64/libselinux.so.1

sudo    48430 root  mem    REG                8,2     99112    1442170 /lib64/libaudit.so.1.0.0

sudo    48430 root  mem    REG                8,2    156872    1442168 /lib64/ld-2.12.so

sudo    48430 root    0r   CHR                1,3       0t0       3916 /dev/null

sudo    48430 root    1w  FIFO                0,8       0t0 1429910151 pipe

sudo    48430 root    2w   REG                8,3 376639626     524292 /apps/logs/zabbix/zabbix_agentd.log

sudo    48430 root    3u  sock                0,6       0t0 1429910161 can't identify protocol

sudo    48430 root    4r   REG                8,2       764    2240617 /etc/group

sudo    48430 root    5u  unix 0xffff880179ee4680       0t0 1429910162 socket

這裏經過查看/proc/pid/fd下的文件描述符的狀態,發現這個fd實際上是已經關閉的。

 

這裏就有多是子進程已經運行完成,而父進程沒有正確處理子進程的返回信息致使父進程一直認爲子進程還在運行,最終產生了殭屍進程。

這實際上是sudo的一個bug,相關的bug id :

http://www.gratisoft.us/bugzilla/show_bug.cgi?id=447

關於bug的描述:

1

2

3

4

5

6

7

8

9

If the parent process gets re-scheduled after the 「if」 was executed, and at this very 

time the child process finishes and SIGCHLD is sent to the parent process, sudo gets 

in trouble. The SIGCHLD handler accounts in the variable 「recvsig[]」 that the signal

 was received, and then the parent process calls select(). This select will never be 

 interrupted, as the author had it in mind. In 99% of the cases, the parent process 

 will enter in the select() blocking state before the child process ended. 

 The child would then send SIGCHLD, which will be accounted in the handler procedure, 

 and will also interrupt select() which will return -1 in 「nready」, and 「errno」

  will be set to EINTR.

問題出在sudo的代碼sudo/file/tip/src/exec.c,小於 1.7.5或1.8.0 以前的版本都有問題,當子進程剛好在select()這個系統調用前退出的時候,句柄已經被退出,因此sudo會卡在select這裏

patch:

http://www.sudo.ws/repos/sudo/rev/99adc5ea7f0a

1

Avoid a potential race condition if SIGCHLD is received immediately before we call select().

網上有人遇到了一樣地問題:

http://blog.famzah.net/2010/11/01/sudo-hangs-and-leaves-the-executed-program-as-zombie/

回過頭總結,這個問題實際上是多個潛在問題同時形成:

1.zabbix agent的自定義監控配置中使用了sudo,致使殭屍進程的父進程不能正常關閉(若是須要sudo,寫在腳本里面便可)

2.sudo的bug致使產生了僵死進程(升級sudo便可)

3.zabbix agent端的實現也有問題,某一個進程成爲僵死進程後會影響其餘的監控項獲取(zabbix agent的進程被阻塞致使)

相關文章
相關標籤/搜索