【サーバ運用】snmpdが自動起動しないぞ

とある事情で会社から自宅サーバをリブートした後で、
帰宅して自宅サーバから届いたメールを確認していたら
mrtgが出したリポートが死ぬほど(280通くらい)届いてました。
どうみてもperlsnmp系のトラブルなので調査開始。

まずはcronでmrtgが動かないように止めておきます。
これをやっておかないとメールが5分おき(cronでそう設定してある)
に届くんでうるさいったらないので。

# jove /etc/crontab

さて、作業開始。
まずはcronに届いていたメールを確認してみます。

SNMP Error:
no response received
SNMPv1_Session (remote host: "xxx" [192.168.1.254].161)
community: "testsnmp"
request ID: 529295257
PDU bufsize: 8000 bytes
timeout: 2s
retries: 5
backoff: 1)
at /usr/local/lib/perl5/site_perl/5.8.8/SNMP_util.pm line 490
SNMPGET Problem for ifInOctets.2 ifOutOctets.2 sysUptime sysName on testsnmp@xxx::::::v4only
at /usr/local/bin/mrtg line 2044
2006-12-03 23:20:01: WARNING: skipping because at least the query for ifInOctets.2 on xxx did not succeed
2006-12-03 23:20:01: WARNING: no data for ifInOctets&ifOutOctets:testsnmp@xxx. Skipping further queries for Host xxx in this round.
2006-12-03 23:20:12: ERROR: Target[www.xxx_1][_IN_] ' $target->[0]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[www.xxx_1][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[cpu][_IN_] ' $target->[2]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[cpu][_OUT_] ' $target->[2]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[disk][_IN_] ' $target->[4]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[disk][_OUT_] ' $target->[4]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[mem][_IN_] ' $target->[6]{$mode} ' did not eval into defined data
2006-12-03 23:20:12: ERROR: Target[mem][_OUT_] ' $target->[6]{$mode} ' did not eval into defined data


うーん……多分snmpdが起動してないかも知れませんね。
一応プロセスを確認してみましょう。

# ps awux |grep snmp
#

……あー、やっぱり。起動してませんね。
起動してない原因は……なんだろう?(笑
とりあえず起動スクリプトを確認してみよう。

# /usr/local/etc/rc.d/snmpd rcvar
# snmpd
$snmpd_enable=YES

ふーむ……rc.confの記述に間違いはなさそうです。
何でだろう……解らんのでファイルのタイムスタンプを確認してみよう。
何かのミスで勝手に変更されちゃったのかも知れないし。

# ls -la /usr/local/etc/rc.d/snmp*
-r-xr-xr-x 1 root wheel 1269 12 3 19:55 /usr/local/etc/rc.d/snmpd
-r-xr-xr-x 1 root wheel 813 12 3 19:55 /usr/local/etc/rc.d/snmptrapd

……

ん?

何でsnmpd.shが無くなってるんだ?(笑

これは起動しないわけだわ……
何かの事故でsnmpd.shが消失したためだったようです。
とりあえず

# cp -p /usr/local/etc/rc.d/snmpd /usr/local/etc/rc.d/snmpd.sh
# cp -p /usr/local/etc/rc.d/snmptrapd /usr/local/etc/rc.d/snmptrapd.sh

としてsnmpd.shとsnmptrapd.shを作成してリブート。
無事にsnmpdが起動している状態を確認して作業完了です。