Home > 未分類 > SNMPWALKを使ってみる

SNMPWALKを使ってみる

  • このエントリをはてなブックマークに追加このエントリをdel.icio.usに追加このエントリをLivedoor Clipに追加このエントリをYahoo!ブックマークに追加このエントリをFC2ブックマークに追加このエントリをNifty Clipに追加このエントリをPOOKMARK. Airlinesに追加このエントリをBuzzurl(バザール)に追加このエントリをChoixに追加このエントリをnewsingに追加

  • 2007-08-22 (水) 23:21
  • 未分類
  • | | | |

snmpwalkっていうコマンドを使ってオリジナルのCactiテンプレートを作成してみる事にしました。今更ですがsnmp良く分かっていません。
まあ、やった事無い事は分からなくて当たり前ですから、分からなければ調べれば良いわけです。

■SNMPエージェントから情報を取得

net-snmpdパッケージには簡易SNMPマネージャとしてsnmpget snmpwalkなどのコマンドが用意されています。前者はMIBのエントリを一つずつ取得するためのコマンドで、snmpwalkは指定したツリー全体を取得するためのコマンドです。これらを使用し、リモートのシステムからSNMPで情報を取得することができます。
スタックアスタリスクより転載

なるほど、使い方としてはsnmpwalkで全体を見てsnmpgetでピンポイントで押さえ込め。ということでしょうか。抽象的ですけども。

Cactiの回でやったnet-snmpをインストールするとWindowsマシンでもこの2つのコマンドが使えるようになります。というわけでとりあえずはコマンドの使い方から覚えてみたいと思います。
※今回の検証環境は前回Cactiをインストールしたマシン上で行っています。

■分からないコマンドがあればとりあえず/?で

知らないコマンドや謎のコマンドと直面したら、とりあえずコマンドプロンプトを開いて

snmpwalk /?

と打ってみます。何やらゴソゴソと文字列が出てきましたね。これにはこのコマンドの使い方が書いてあるわけです。初めは読み方が分からないかもしれないけども、なんとなく使っているうちに覚えると思います。

■snmpwalkコマンド一覧

パッと見難しそうですけど、実は一行一行じっくり読んでみると案外理解出来るものです。英語と言ってもカタカナがローマ字になったようなものですから。


USAGE: snmpwalk [OPTIONS] AGENT [OID]
Version: 5.4.1
Web: http://www.net-snmp.org/
Email: net-snmp-coders@lists.sourceforge.net
OPTIONS:
-h, --help display this help message
'このヘルプメッセージを表示します
-H display configuration file directives understood
'コンフィグファイルディレクトリを表示します
-v 1|2c|3 specifies SNMP version to use
'使用するSNMPバージョンを書きます
-V, --version display package version number
'バージョン情報を表示します
SNMP Version 1 or 2c specific
-c COMMUNITY set the community string
'コミュニティ名を設定します
SNMP Version 3 specific
-a PROTOCOL set authentication protocol (MD5|SHA)
-A PASSPHRASE set authentication protocol pass phrase
-e ENGINE-ID set security engine ID (e.g. 800000020109840301)
-E ENGINE-ID set context engine ID (e.g. 800000020109840301)
-l LEVEL set security level (noAuthNoPriv|authNoPriv|authPriv)
-n CONTEXT set context name (e.g. bridge1)
-u USER-NAME set security name (e.g. bert)
-x PROTOCOL set privacy protocol (DES)
-X PASSPHRASE set privacy protocol pass phrase
-Z BOOTS,TIME set destination engine boots/time

General communication options
-r RETRIES set the number of retries
-t TIMEOUT set the request timeout (in seconds)
Debugging
-d dump input/output packets in hexadecimal
-D TOKEN[,...] turn on debugging output for the specified TOKENs
(ALL gives extremely verbose debugging output)
General options
-m MIB[:...] load given list of MIBs (ALL loads everything)
-M DIR[:...] look in given list of directories for MIBs
-P MIBOPTS Toggle various defaults controlling MIB parsing:
u: allow the use of underlines in MIB symbols
c: disallow the use of "--" to terminate comments
d: save the DESCRIPTIONs of the MIB objects
e: disable errors when MIB symbols conflict
w: enable warnings when MIB symbols conflict
W: enable detailed warnings when MIB symbols conflict

R: replace MIB symbols from latest module
-O OUTOPTS Toggle various defaults controlling output display:
0: print leading 0 for single-digit hex characters
a: print all strings in ascii format
b: do not break OID indexes down
e: print enums numerically
E: escape quotes in string indices
f: print full OIDs on output
n: print OIDs numerically
q: quick print for easier parsing
Q: quick print with equal-signs
s: print only last symbolic element of OID
S: print MIB module-id plus last element
t: print timeticks unparsed as numeric integers
T: print human-readable text along with hex strings
u: print OIDs using UCD-style prefix suppression
U: don't print units
v: print values only (not OID = value)
x: print all strings in hex format
X: extended index format
-I INOPTS Toggle various defaults controlling input parsing:
b: do best/regex matching to find a MIB node
h: don't apply DISPLAY-HINTs
r: do not check values for range/type legality
R: do random access to OID labels
u: top-level OIDs must have '.' prefix (UCD-style)
s SUFFIX: Append all textual OIDs with SUFFIX before
parsing
S PREFIX: Prepend all textual OIDs with PREFIX before
parsing
-L LOGOPTS Toggle various defaults controlling logging:
e: log to standard error
o: log to standard output
n: don't log at all
f file: log to the specified file
s facility: log to syslog (via the specified facility
)

(variants)
[EON] pri: log to standard error, output or /dev/nul
l for level 'pri' and above
[EON] p1-p2: log to standard error, output or /dev/nul
l for levels 'p1' to 'p2'
[FS] pri token: log to file/syslog for level 'pri'
and above
[FS] p1-p2 token: log to file/syslog for levels 'p1'
to 'p2'
-C APPOPTS Set various application specific behaviours:
p: print the number of variables found
i: include given OID in the search range
I: don't include the given OID, even if no results ar
e returned
c: do not check returned OIDs are increasing
t: Display wall-clock time to complete the request

とりあえず全部日本語説明書こうとしたんですが面倒に・・・すいません。

使用例がとりあえず

snmpwalk [OPTIONS] AGENT [OID]

こう書いてありましたのでCactiで覚えたSNMP知識をちょっと活用してみましょう。とりあえず自分自身のSNMPで取得出来る値を取るには以下のようにコマンドプロンプトに入力します。

snmpwalk -v 1 -c コミュニティ名 PC名

僕の環境の場合には以下のようになります

snmpwalk -v 1 -c pnpk.net localhost

このコマンドを実行すると激しく画面がスクロールしていろんな値が出て来ると思います、がこれじゃ早すぎて見えませんよね。こんな場合にはコマンドの実行結果をテキストファイルに出す事が出来る

> 保存先

を使ってみましょう。このコマンドに使うのであれば

snmpwalk -v 1 -c pnpk.net localhost > c:\snmp.log

こんな感じでやってみてください。再度このコマンドを実行すると

c:\snmp.log

に先ほど激しくスクロールしていた文字がテキストファイルで保存されているはずです。

関連する記事

Comments:0

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://pnpk.net/cms/archives/282/trackback
Listed below are links to weblogs that reference
SNMPWALKを使ってみる from http://pnpk.net

Home > 未分類 > SNMPWALKを使ってみる

Return to page top