1. 檢查是否有 check_snmp 檢查指令
一個是使用採用簡單認證,另外一個是支援加密傳輸
# locate check_snmp
/usr/lib64/nagios/plugins/check_snmp
2. 檢查一下,check_snmp 須要加入的參數
# /usr/lib64/nagios/plugins/check_snmp -h
-H, –hostname=ADDRESS
Host name, IP Address, or unix socket (must be an absolute path)
-p, –port=INTEGER
Port number (default: 161)
-n, –next
Use SNMP GETNEXT instead of SNMP GET
-P, –protocol=[1|2c|3]
SNMP protocol version
-L, –seclevel=[noAuthNoPriv|authNoPriv|authPriv]
SNMPv3 securityLevel
-a, –authproto=[MD5|SHA]
SNMPv3 auth proto
-x, –privproto=[DES|AES]
SNMPv3 priv proto (default DES)
-C, –community=STRING
Optional community string for SNMP communication (default is “public”)
-U, –secname=USERNAME
SNMPv3 username
-A, –authpassword=PASSWORD
SNMPv3 authentication password
-X, –privpasswd=PASSWORD
SNMPv3 privacy password
-o, –oid=OID(s)
Object identifier(s) or SNMP variables whose value you wish to query
[@more@]3. 測試一下
# /usr/lib64/nagios/plugins/check_snmp -H SNMP_Server’IP -o .1.3.6.1.2.1.1.3.0
SNMP OK – Timeticks: (41154894) 4 days, 18:19:08.94 |
4. 在 /etc/nagios/objects/commands.cfg 檔案加入
# ‘check_snmp’ command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -o $ARG1$
}
5. 在要偵測的 SNMP 主機加入
# vim /etc/nagios/servers/snmp.cfg
define service{
use generic-service ; Name of service template to use
host_name snmp.test.ilc.edu.tw
service_description SNMP
check_command check_snmp!.1.3.6.1.2.1.1.3.0
notifications_enabled 1
}
重新啟動 Nagios
# service nagios restart
Running configuration check…done.
Stopping nagios: .done.
Starting nagios: done.
如果沒有出現錯誤訊息,代表設定成功