Nagios 伺服器 IP 變更後,更新客戶端配置仍無法監控。發現 NRPE 進程無法啟動,5666 端口被佔用。
# netstat -anp | grep 5666
tcp 0 0 :::5666 :::* LISTEN 2036/xinetd
發現 xinetd (PID 2036) 佔用了 NRPE 預設端口 5666。
# kill -9 2036
# netstat -anp | grep 5666
# (無輸出,表示端口已釋放)
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
# ps -ef | grep nrpe
nagios 2128 1 0 10:34 ? 00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
/etc/xinetd.d/nrpe 管理 NRPE,若配置啟用會綁定 5666 端口-d 獨立模式啟動時,會嘗試綁定同一端口,導致衝突nrpe.cfg 中 allowed_hosts 未同步更新,或 xinetd 配置殘留# /etc/xinetd.d/nrpe
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 192.168.1.100 # Nagios 伺服器 IP
}
service xinetd restart
# 禁用 xinetd 中的 nrpe
sed -i 's/disable\s*=\s*no/disable = yes/' /etc/xinetd.d/nrpe
service xinetd reload
# 使用 systemd 管理獨立 NRPE
# /etc/systemd/system/nrpe.service
[Unit]
Description=Nagios NRPE
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable nrpe
systemctl start nrpe
allowed_hosts 与 only_from端口衝突是服務遷移常見問題,系統化排查與標準化部署模式能有效避免重複踩坑。
Linux 程式背景執行完整指南:nohup、&、setsid、disown、screen 多種方式與作業控制
Linux 硬體配置查看命令大全:系統、資源、磁碟、網路與進程
盤點 Linux 之外的 7 款開源作業系統:從嵌入式到雲端
Linux 記憶體管理核心原理:從核心空間 (頁、區、Slab、vmalloc) 到使用者空間 (VMA、mm_struct、fork 複製) 完整圖解
coLinux 安裝與配置完整指南 (Windows 下運行 Linux)
Linux 網路連線故障診斷實戰:從 ifconfig 到路由表的分層排查法