本格堅守四不一沒有政治主張:不知道、不清楚、不瞭解、不明白、沒有我的事!
[ start | index | login or register ]

2004-05-19 #1

Created by Ada. Last edited by Ada, 3 years and 297 days ago. Viewed 1,200 times. #3
[diff] [history] [edit] [rdf]
labels
Parent:Linux
attachments

SNMP 服務設定

這篇是個人在 Gentoo Linux 1.4 上設定 snmp 服務的記錄。

安裝 snmp 服務套件

www snmp # emerge -pv net-snmp

These are the packages that I would merge, in order:

Calculating dependencies ...done! [ebuild N ] net-analyzer/net-snmp-5.0.9-r1 -ipv6 +ssl +tcpd 0 kB

Total size of downloads: 0 kB

www snmp # emerge -v net-snmp

透過公用程式 snmpconf 完成 snmpd.conf 設定檔設定作業

www snmp # snmpconf

I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program)

1: snmpd.conf 2: snmp.conf 3: snmptrapd.conf

Other options: quit

Select File: 1

逐一設定 snmpd.conf 各內容:

The configuration information which can be put into snmpd.conf is divided
into sections.  Select a configuration section for snmpd.conf
that you wish to create:

1: Access Control Setup 2: Trap Destinations 3: Monitor Various Aspects of the Running Host 4: Agent Operating Mode 5: System Information Setup 6: Extending the Agent

Other options: finished

Select section: 5

System Information Setup 內容:

Section: System Information Setup
Description:
  This section defines some of the information reported in
  the "system" mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system. 2: The contact information for the administrator 3: The proper value for the sysServices object.

Other options: finished, list

Select section:

* The [typically physical] location of the system:

請填入系統所在的地理位置作為識別,一般應該會以設備名稱 + 部門、樓層等為識別字串。

Configuring: syslocation
Description:
  The [typically physical] location of the system.
    Note that setting this value here means that when trying to
    perform an snmp SET operation to the sysLocation.0 variable will make
    the agent return the "notWritable" error code.  IE, including
    this token in the snmpd.conf file will disable write access to
    the variable.
    arguments:  location_string

The location of the system: room

* The contact information for the administrator

請填入聯絡人資訊,可以輸入電話或郵件地址等。

Configuring: syscontact
Description:
  The contact information for the administrator
    Note that setting this value here means that when trying to
    perform an snmp SET operation to the sysContact.0 variable will make
    the agent return the "notWritable" error code.  IE, including
    this token in the snmpd.conf file will disable write access to
    the variable.
    arguments:  contact_string

The contact information: Ada Hsu

* The proper value for the sysServices object.

使用 0 (否) 或 1 (是) 回答相關問題,由系統算出 sysServices 的值。

Configuring: sysservices
Description:
  The proper value for the sysServices object.
    arguments:  sysservices_number

does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 0 does this host offer datalink/subnetwork services (eg, like a bridge): 0 does this host offer internet services (eg, supports IP): 1 does this host offer end-to-end services (eg, supports TCP): 1 does this host offer application services (eg, supports SMTP): 1

Finished Output: sysservices 0*1 + 0*2 + 1*4 + 1*8 + 1*64

輸入 finished 後結束 System Information Setup 設定回主選單

Select section: finished

The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create:

1: Access Control Setup 2: Trap Destinations 3: Monitor Various Aspects of the Running Host 4: Agent Operating Mode 5: System Information Setup 6: Extending the Agent

Other options: finished

Select section: 1

進行存取控制設定 Access Control Setup

Section: Access Control Setup
Description:
  This section defines who is allowed to talk to your running
  snmp agent.

Select from:

1: a SNMPv3 read-write user 2: a SNMPv3 read-only user 3: a SNMPv1/SNMPv2c read-only access community name 4: a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Select section:

* a SNMPv1/SNMPv2c read-only access community name

這是指定用來讀取 SNMP 訊息用的群組帳號名稱,大部份的 SNMP 代理者多以 public 為其預設的名稱,但建議要另行設定較好。設定完畢後請輸入 finished 回到主選單中。

Configuring: rocommunity
Description:
  a SNMPv1/SNMPv2c read-only access community name
    arguments:  community [default|hostname|network/bits] [oid]

The community name to add read-only access for: snmpmgr The hostname or network address to accept this community name from [RETURN for all]: The OID that this community should be restricted to [RETURN for no-restriction]:

Finished Output: rocommunity snmpmgr

啟動 snmpd 服務

當完成上述設定後即可在主選單中輸入 finished 結束 snmpd.conf 設定作業,最後輸入 quit 離開 snmpconf 設定工具。

I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf 2: snmp.conf 3: snmptrapd.conf

Other options: quit

Select File: quit

The following files were created:

snmpd.conf

These files should be moved to /usr/share/snmp/ if you want them used by everyone on the system. In the future, if you add the -i option to the command line I'll copy them there automatically for you.

Or, if you want them for your personal use only, copy them to /root/.snmp . In the future, if you add the -p option to the command line I'll copy them there automatically for you.

上述的說明似乎有點不正確,snmpd.conf 在 Gentoo 中應該要放入 /etc/snmp/ 下,否則 snmpd 是無法正確啟動的。當將 snmpd.conf 複製到 /etc/snmp/ 下後即可啟動 snmpd 服務。

www root # cp snmpd.conf /etc/snmp/
www root # /etc/init.d/snmpd start
 * Starting net-snmpd…                                                  [ ok ]
www root # ps -ef | grep snmp
root     18048     1  0 15:12 ?        00:00:00 /usr/sbin/snmpd -P /var/run/snmpd.pid -a -s -l /dev/null
root     18053 10326  0 15:13 pts/15   00:00:00 grep snmp

使用 snmpwalk 對本機進行訪談,snmpwalk 中要指定在 Access Control Setup 中所設定的帳號名稱,如範例。若 snmpd.conf 設定正確應可看到畫面輸出一長串好幾十頁的訊息。

www root # snmpwalk localhost -c snmpmgr -v 1

若想查看先前在 System Information Setup 所做的設定,可以使用以下方式達成。有關 1.3.6.1.2.1.1 所代表的意義表示為該 SNMP 代理者所記錄的系統資訊,詳細請參閱 SNMP 中有關 OID 的說明。

www root # snmpwalk localhost -c snmpmgr -v 1 1.3.6.1.2.1.1

你可能會發現主機名稱不是完整的領域名稱(FQDN),這可以透過修改 /etc/snmp/snmpd.conf 重新設定,只要加上 sysname 參數即可。但是請注意: 當使用 snmpconf 重新設定 snmpd.conf 內容時,sysname 的設定可能會遺失。

sysname "www.t-times.net"

重啟 snmpd 後重新查詢即可確定設定是否正確。

www root # snmpwalk localhost -c snmpmgr -v 1 1.3.6.1.2.1.1.sysName.0
SNMPv2-MIB::sysName.0 = STRING: "www.t-times.net"

snmp 中提供不少系統的各項資訊,如 1.3.6.1.2.1.2 中記載了系統各種網路界面的資訊,同樣可以使用 snmpwalk 進行查詢。

完成以上動作後,snmpd 即完成設定,最後記得將 snmpd 設定為開機後自動啟動。

www root # rc-update add snmpd default
Please login to post a comment.


【求助】

  1. 如何指定格式化的文字
  2. 如果字太小
【SnipSnap 強化方案】
>>SnipIt 誕生
>>功能討論
>>功能確認

< January 2009 >
SunMonTueWedThuFriSat
123
45678910
11121314151617
18192021222324
25262728293031

【RSS 訂閱】




【雜想分類區】
美食小吃
生活雜想
職場遭遇戰
休閒娛樂
台北居、大不易
錯誤正在橫行中
廣告異聞錄
神秘事件簿
電影
健康管理
資訊電腦
科高地球
手機應用
新聞馬後炮
動漫世界
管理眾人之事
專案管理
歌曲歌詞
嘸爽啦!
部落格記錄
惡搞裝笨耍白爛
歧視非IE用戶之網頁
關於我
CSS
RSS

【與 Ada 聯絡】

【Windows 多媒體播放工具】
介紹:多功能免費媒體播放工具 MyMPC 2006 安裝介紹
下載(1):>>MyMPC 20060117 簡、繁、英三合一安裝版
下載(2):>>MyMPC 20060117 簡、繁、英三合一安裝版

【Firefox 擴充套件自動安裝服務】
>>建議擴充套件介紹
>>擴充套件分類介紹
※更新日期:2007-04-12

【有趣的 Blog】
>>什麼都破,什麼都爛,什麼都不奇怪
>>酪梨壽司的日記
>>去吧!錯誤特攻隊!
>>隨裕而安
>>荒謬大觀
>>網路黑貓
>>瑞克梅添涼 DALIREAL
>>鳥毅的blog
>>潛艦 - >>反垃圾信
>>窮留學生懶人食譜
>>約耳談軟體

【工具網站】
>>dns checker
>>美國街道電子地圖

【網路貼紙】
XHTML 1.0 validated CSS validated
RSS 2.0 validated Powered by SnipSnap
Powered by Gentoo Linux
網站使用 UTF-8 編碼 網站所在地-台灣
Onion Club 洋蔥酷樂部 Powered By PostgreSQL
我是台灣人

【網路同盟】
怠墮管理者同盟

【PCDVD 七八區 RSS】




【PCDVD 疑雜區 RSS】




【網路串連】









【參訪團】

snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt