SNMP 匯入新 MIB on LINUX server

這次我們要測試的機器仍然是 RHEL ES4U6 的環境,已經裝好相關的 net-snmp (net-snmp-5.1.2-11.EL4.11) 程式,下面列出測試要匯入的為 RADIUS 相關的幾個 MIB 檔:
RADIUS-AUTH-SERVER-MIB.txt
RADIUS-AUTH-CLIENT-MIB.txt
RADIUS-ACC-SERVER-MIB.txt
RADIUS-ACC-CLIENT-MIB.txt
RADIUS-DYNAUTH-SERVER-MIB.txt
RADIUS-DYNAUTH-CLIENT-MIB.txt
先用 snmptranslate 來確認一下 snmpd 是否可以認得我們要匯入的 OBJECT-TYPE 與 OID:
[root@KHXAAAS2 mibs]# snmptranslate -On -IR radiusAuthServMIBCompliance
Unknown object identifier: radiusAuthServMIBCompliance
[root@KHXAAAS2 mibs]# snmptranslate -Td .1.3.6.1.2.1.67.1.1.2.1.1
SNMPv2-SMI::mib-2.67.1.1.2.1.1
mib-2 OBJECT-TYPE
-- FROM SNMPv2-SMI, RFC1213-MIB
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) 67 1 1 2 1 1 }
看起來目前是翻譯不出我們所要查 RADIUS 相關的 OBJECT-TYPE 與 OID,好了,接下來就是這次的工作囉:

首先,我們將 RADIUS 這幾個 MIB 檔複製到 /usr/share/snmp/mibs 底下:
[root@KHXAAAS2 ~] mkdir -p $HOME/.snmp
[root@KHXAAAS2 ~] cp -p /tmp/RADIUS* /usr/share/snmp/mibs/
接著就是告訴 snmpd 去 load 這些 MIB:

有兩種方式,暫時測試可用第一種方法,只對目前的 session 有效:
[root@KHXAAAS2 ~] export MIBS=+MY-MIB
或者是第二種方法:
[root@KHXAAAS2 ~] echo "mibs +RADIUS-AUTH-SERVER-MIB" >> $HOME/.snmp/snmp.conf
[root@KHXAAAS2 ~] echo "mibs +RADIUS-AUTH-CLIENT-MIB" >> $HOME/.snmp/snmp.conf
[root@KHXAAAS2 ~] echo "mibs +RADIUS-ACC-SERVER-MIB" >> $HOME/.snmp/snmp.conf
[root@KHXAAAS2 ~] echo "mibs +RADIUS-ACC-CLIENT-MIB" >> $HOME/.snmp/snmp.conf
[root@KHXAAAS2 ~] echo "mibs +RADIUS-DYNAUTH-SERVER-MIB" >> $HOME/.snmp/snmp.conf
[root@KHXAAAS2 ~] echo "mibs +RADIUS-DYNAUTH-CLIENT-MIB" >> $HOME/.snmp/snmp.conf
or
[root@KHXAAAS2 ~] echo "mibs +ALL" >> $HOME/.snmp/snmp.conf
也是可以,用 ALL 會把所有可用的 MIB 都 LOAD 進來,當然包括剛剛的幾個測試 MIB 檔,不過速度上會比較慢喔。(注意喔,如果是用
echo "mibs +RADIUS-DYNAUTH-CLIENT-MIB" 的方式,要記得把後面的 .txt 去掉喔~)

好了,先看一下 MIBDIR 的目錄下有些什麼囉:
[root@KHXAAAS2 mibs]# pwd
/usr/share/snmp/mibs
[root@KHXAAAS2 mibs]# ls -alrt
total 1740
-rw-r--r-- 1 root root 38034 Jul 19 2007 SNMPv2-TC.txt
-rw-r--r-- 1 root root 8924 Jul 19 2007 SNMPv2-SMI.txt
-rw-r--r-- 1 root root 29305 Jul 19 2007 SNMPv2-MIB.txt
-rw-r--r-- 1 root root 8263 Jul 19 2007 SNMPv2-CONF.txt
-rw-r--r-- 1 root root 9106 Jul 19 2007 SNMP-PROXY-MIB.txt
-rw-r--r-- 1 root root 1174 Jul 19 2007 RFC-1215.txt
-rw-r--r-- 1 root root 79667 Jul 19 2007 RFC1213-MIB.txt
-rw-r--r-- 1 root root 3067 Jul 19 2007 RFC1155-SMI.txt
-rw-r--r-- 1 root root 71691 Jul 19 2007 IF-MIB.txt
-rw-r--r-- 1 root root 5066 Jul 19 2007 IF-INVERTED-STACK-MIB.txt
-rw-r--r-- 1 root root 84492 Jul 19 2007 EtherLike-MIB.txt
-rw-r--r-- 1 root root 4076 Jul 19 2007 UDP-MIB.txt
-rw-r--r-- 1 root root 10765 Jul 19 2007 TCP-MIB.txt
-rw-r--r-- 1 root root 2205 Jul 19 2007 SNMP-USM-AES-MIB.txt
-rw-r--r-- 1 root root 147822 Jul 19 2007 RMON-MIB.txt
-rw-r--r-- 1 root root 24723 Jul 19 2007 NOTIFICATION-LOG-MIB.txt
-rw-r--r-- 1 root root 4400 Jul 19 2007 IPV6-UDP-MIB.txt
-rw-r--r-- 1 root root 2367 Jul 19 2007 IPV6-TC.txt
-rw-r--r-- 1 root root 7257 Jul 19 2007 IPV6-TCP-MIB.txt
-rw-r--r-- 1 root root 48703 Jul 19 2007 IPV6-MIB.txt
-rw-r--r-- 1 root root 15936 Jul 19 2007 IPV6-ICMP-MIB.txt
-rw-r--r-- 1 root root 23499 Jul 19 2007 IP-MIB.txt
-rw-r--r-- 1 root root 26781 Jul 19 2007 IP-FORWARD-MIB.txt
-rw-r--r-- 1 root root 12517 Jul 19 2007 INET-ADDRESS-MIB.txt
-rw-r--r-- 1 root root 4660 Jul 19 2007 HCNUM-TC.txt
-rw-r--r-- 1 root root 64311 Jul 19 2007 DISMAN-SCRIPT-MIB.txt
-rw-r--r-- 1 root root 24613 Jul 19 2007 DISMAN-SCHEDULE-MIB.txt
-rw-r--r-- 1 root root 17455 Jul 19 2007 AGENTX-MIB.txt
-rw-r--r-- 1 root root 35242 Jul 19 2007 UCD-SNMP-MIB.txt
-rw-r--r-- 1 root root 8118 Jul 19 2007 UCD-IPFWACC-MIB.txt
-rw-r--r-- 1 root root 2163 Jul 19 2007 UCD-DEMO-MIB.txt
-rw-r--r-- 1 root root 22769 Jul 19 2007 SNMP-TARGET-MIB.txt
-rw-r--r-- 1 root root 4628 Jul 19 2007 SMUX-MIB.txt
-rw-r--r-- 1 root root 4318 Jul 19 2007 NET-SNMP-TC.txt
-rw-r--r-- 1 root root 2036 Jul 19 2007 NET-SNMP-MIB.txt
-rw-r--r-- 1 root root 6741 Jul 19 2007 NET-SNMP-EXAMPLES-MIB.txt
-rw-r--r-- 1 root root 15650 Jul 19 2007 NET-SNMP-AGENT-MIB.txt
-rw-r--r-- 1 root root 4299 Jul 19 2007 IANA-LANGUAGE-MIB.txt
-rw-r--r-- 1 root root 20126 Jul 19 2007 IANAifType-MIB.txt
-rw-r--r-- 1 root root 4743 Jul 19 2007 IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt
-rw-r--r-- 1 root root 10583 Jul 19 2007 HOST-RESOURCES-TYPES.txt
-rw-r--r-- 1 root root 52544 Jul 19 2007 HOST-RESOURCES-MIB.txt
-rw-r--r-- 1 root root 3010 Jul 19 2007 UCD-DLMOD-MIB.txt
-rw-r--r-- 1 root root 3198 Jul 19 2007 UCD-DISKIO-MIB.txt
-rw-r--r-- 1 root root 34162 Jul 19 2007 SNMP-VIEW-BASED-ACM-MIB.txt
-rw-r--r-- 1 root root 5775 Jul 19 2007 SNMPv2-TM.txt
-rw-r--r-- 1 root root 39201 Jul 19 2007 SNMP-USER-BASED-SM-MIB.txt
-rw-r--r-- 1 root root 20014 Jul 19 2007 SNMP-NOTIFICATION-MIB.txt
-rw-r--r-- 1 root root 5496 Jul 19 2007 SNMP-MPD-MIB.txt
-rw-r--r-- 1 root root 22342 Jul 19 2007 SNMP-FRAMEWORK-MIB.txt
-rw-r--r-- 1 root root 15490 Jul 19 2007 SNMP-COMMUNITY-MIB.txt
-rw-r--r-- 1 root root 5931 Jul 19 2007 LM-SENSORS-MIB.txt
-rw-r--r-- 1 root root 68177 Jul 19 2007 DISMAN-EVENT-MIB.txt
drwxr-xr-x 4 root root 4096 Jun 12 04:28 ..
-rw-rw---- 1 root root 28446 Aug 29 00:32 RADIUS-AUTH-SERVER-MIB.txt
-rw-rw---- 1 root root 26373 Aug 29 00:32 RADIUS-AUTH-CLIENT-MIB.txt
-rw-rw---- 1 root root 26281 Aug 29 00:32 RADIUS-ACC-SERVER-MIB.txt
-rw-rw---- 1 root root 23747 Aug 29 00:32 RADIUS-ACC-CLIENT-MIB.txt
-rw-rw---- 1 root root 29247 Aug 29 00:32 RADIUS-DYNAUTH-SERVER-MIB.txt
-rw-rw---- 1 root root 31892 Aug 29 00:32 RADIUS-DYNAUTH-CLIENT-MIB.txt
drwxr-xr-x 2 root root 4096 Oct 2 10:16 .
-rw-r--r-- 1 root root 2058 Oct 2 10:16 .index
不用重起 snmpd 的服務,我們直接再查詢一次試試看:

[root@KHXAAAS2 mibs]# snmptranslate -On -IR radiusAuthServMIBCompliance
.1.3.6.1.2.1.67.1.1.2.1.1
[root@KHXAAAS2 mibs]# snmptranslate -Td .1.3.6.1.2.1.67.1.1.2.1.1
RADIUS-AUTH-SERVER-MIB::radiusAuthServMIBCompliance
radiusAuthServMIBCompliance MODULE-COMPLIANCE
-- FROM RADIUS-AUTH-SERVER-MIB
DESCRIPTION "The compliance statement for authentication
servers implementing the RADIUS Authentication
Server MIB. Implementation of this module is for
IPv4-only entities, or for backwards compatibility
use with entities that support both IPv4 and
IPv6."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) radiusMIB(67) radiusAuthentication(1) radiusAuthServMIB(1) radiusAuthServMIBConformance(2) radiusAuthServMIBCompliances(1) 1 }
果然就可以查詢的到 RADIUS 的 OBJECT-TYPE 與 OID 囉...

參考資料:Net-SNMP FAQ How do I add a MIB
0 Responses