zabbix報錯
https://www.cnblogs.com/losbyday/category/876878.html作者總結的很全棒
1.在啟動zabbix-agent 時系統日志輸出
PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after star
zabbix-agent.service never wrote its PID file. Failing
重啟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這四個核心參數,具體含義和配置如下。
SEMMSL :用於控制每個信號集的最大信號數量。
SEMMNS:用於控制整個 Linux 系統中信號(而不是信號集)的最大數。
SEMOPM: 內核參數用於控制每個 semop 系統調用可以執行的信號操作的數量。SE1、Zabbix報警 icmp pinger processes more than 75% busy
1 2 |
[root@localhost zabbix]# vi /etc/zabbix/zabbix_server.conf 將這個值設置成StartPingers=5,然后重啟zabbix-server服務。 |
2、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服務。 |
3、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 |
4、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台主機,造成內存溢出。 |
5、zabbix-server日志報錯,提示connection to database 'zabbix' failed: [1040] Too many connections錯誤,mariadb正常。想到應該是mysql最大連接數問題。
修改mysql最大連接數的鏈接:http://blog.51cto.com/net881004/2089198
6、報警提示More than 100 items having missing data for more than 10 minutes和Zabbix 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 |
7、server日志很多first network error, wait for 15 seconds報錯
server配置文件Timeout時間改大點,我改成了30s。
8、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之后就再沒有遇到過警報。如果內存足夠的話可以設置更高。
9、早上收到很多報警郵件,官網訪問不了,很多服務器端口不通。但是用手機訪問官網卻可以訪問,郵件里面很多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.1、打開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)
2、添加windows監控時候報錯:
Get value error: ZBX_TCP_READ() failed: [104] Connection reset by peer
解決:windows下agentd.conf文件IP地址不對
3、zabbix打開既然沒有任何數據顯示
我用360安全瀏覽器使用打開沒有任何數據顯示,然而用IE打開zabbix數據就能正常的顯示呈現。
4、搞微信報警按照前輩們操作http://www.ttlsa.com/linux/zabbix-wechat-onalert-20/,在最后一步添加actions的時候總是不成功既然出現
ERROR: Page received incorrect data
不知原因
5、配置zabbix-server監控IPMI
編譯加--with-openipmi參數報錯。
configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
解決:需提前安裝
- 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"的錯誤狀態。
1、問題原因
在查看了zabbix_server日志,發現日志里有下面的告警
zbx_mem_malloc(): out of memory (requested 256 bytes) zbx_mem_malloc(): please increase CacheSize configuration parameter
錯誤原因寫的很明白,內存溢出,請調整CacheSize大小。
2、問題解決
編輯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.二、錯誤解決:
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
1、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登錄出現如下錯誤
- 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
解決方案:
1、啟用中文
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兩個服務一下,應該可以選了。。
2、但是我發現翻譯的不好,有大神做了更好的翻譯(未測)
進入 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
3、亂碼問題
看圖時候,如果有中文,會亂碼 調整圖像里的中文亂碼 下載雅黑 代碼: 全選 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
4、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的進程被阻塞導致)