第四步 添加一個 Linux 主機 host-one我們將添加一個新的將被監控的 Linux 主機,IP 位址為 192.168.1.121,主機名稱為 host-one 的 Ubuntu 16.04。
串連到 host-one 主機:
ssh host1@192.168.1.121
從 Ubuntu 軟體庫中安裝 snmp 和snmpd 軟體包:
sudo apt-get install snmp snmpd
然後,用vim編輯snmpd.conf設定檔:
vim /etc/snmp/snmpd.conf
注釋掉第 15 行並取消注釋第 17 行:
#agentAddress udp:127.0.0.1:161agentAddress udp:161,udp6:[::1]:161
注釋掉第 51 和 53 行,然後加一行新的配置,如下:
#rocommunity mypass default -V systemonly#rocommunity6 mypass default -V systemonlyrocommunity mypass
儲存並退出。
現在用systemctl命令來啟動snmpd服務:
systemctl start snmpd
在 shinken 伺服器上通過在hosts檔案夾下建立新的檔案來定義一個新的主機:
cd /etc/shinken/hosts/vim host-one.cfg
粘貼如下配置資訊:
define host{ use generic-host,linux-snmp,ssh contact_groups admins host_name host-one address 192.168.1.121 _SNMPCOMMUNITY mypass # SNMP Pass Config on snmpd.conf }儲存並退出。
在 shinken 伺服器上編輯 SNMP 設定檔。
vim /etc/shinken/resource.d/snmp.cfg
將public改為mypass -必須和你在用戶端snmpd設定檔中使用的密碼相同:
$SNMPCOMMUNITYREAD$=mypass
儲存並退出。
現在將服務端和用戶端都重啟:
reboot
現在 Linux 主機已經被成功地添加到 shinken 伺服器中了。
第五步 訪問 Shinken Webui2在連接埠 7677 訪問 Shinken webui2 (將 URL 中的 IP 替換成你自己的 IP 位址):
http://192.168.1.120:7767
用管理使用者和密碼登入(你在 admin.cfg 檔案中設定的)
Webui2 中的 Shinken 面板:
我們的兩個伺服器正在被 Shinken 監控:
列出所有被 linux-snmp 監控的服務:
所有主機和服務的狀態資訊:
第6步 Shinken 的常見問題NTP 伺服器相關的問題當你得到如下的 NTP 錯誤提示
TimeSync - CRITICAL ( NTP CRITICAL: No response from the NTP server)TimeSync - CRITICAL ( NTP CRITICAL: Offset unknown )
為瞭解決這個問題,在所有 Linux 主機上安裝 ntp。
sudo apt-get install ntp ntpdate
編輯 ntp 設定檔:
vim /etc/ntp.conf
注釋掉所有 pools 並替換為:
#pool 0.ubuntu.pool.ntp.org iburst#pool 1.ubuntu.pool.ntp.org iburst#pool 2.ubuntu.pool.ntp.org iburst#pool 3.ubuntu.pool.ntp.org iburstpool 0.id.pool.ntp.orgpool 1.asia.pool.ntp.orgpool 0.asia.pool.ntp.org
然後,在新的一行添加如下限制規則:
# Local users may interrogate the ntp server more closely.restrict 127.0.0.1restrict 192.168.1.120 #shinken server IP addressrestrict ::1NOTE: 192.168.1.120 is the Shinken server IP address.
儲存並退出。
啟動 ntp 並且檢查 Shinken 面板。
ntpd
check_netint.pl Not Found 問題從 github 倉庫下載原始碼到 shinken 的庫目錄下:
cd /var/lib/shinken/libexec/wget https://raw.githubusercontent.com/Sysnove/shinken-plugins/master/check_netint.plchmod +x check_netint.plchown shinken:shinken check_netint.pl
網路佔用的問題這是錯誤資訊:
ERROR : Unknown interface eth/d+
檢查你的網路介面並且編輯linux-snmp模版。
在我的 Ununtu 伺服器,網卡是 “enp0s8”,而不是 eth0,所以我遇到了這個錯誤。
vim編輯linux-snmp模版:
vim /etc/shinken/packs/linux-snmp/templates.cfg
在第 24 行添加網路介面資訊:
NET_IFACES eth/d+|em/d+|enp0s8
儲存並退出。
原文來自:https://linux.cn/article-7821-1.html
本文地址:http://www.linuxprobe.com/server-monitoring-system.html