Snmp服務無法啟動問題(CentOS5)



贊助商連結


shung0116
2009-01-13, 08:53 PM
請教各位前輩
以CentOS來架設linux主機,但以下列方式啟動snmpd服務時
/etc/rc.d/init.d/snmpd start 或 service snmpd start
它服務可以啟動,但是當我檢查其狀態(service snmpd status) 都會出現下列的錯誤訊息
-->snmp 已停止執行但pid檔案仍在

而snmp 我是用yum -y install snmp來安裝的,是否有方式可修正呢?
謝謝

贊助商連結


bx2aa
2009-01-13, 11:42 PM
請教各位前輩
以CentOS來架設linux主機,但以下列方式啟動snmpd服務時
/etc/rc.d/init.d/snmpd start 或 service snmpd start
它服務可以啟動,但是當我檢查其狀態(service snmpd status) 都會出現下列的錯誤訊息
-->snmp 已停止執行但pid檔案仍在

而snmp 我是用yum -y install snmp來安裝的,是否有方式可修正呢?
謝謝
RHEL 5
umount /dev/hdc
mount /dev/hdc /mnt <------ 把 第二張光碟放進光碟機

rpm -ivh /mnt/Server/lm_sensors-2.10.0-3.1.i386.rpm

umount /dev/hdc
放第三張光碟
mount /dev/hdc /mnt
rpm -ivh /mnt/Server/net-snmp-5.3.1-14.el5.i386.rpm

service snmpd restart

用其他台
C:\Downloads\mrtg-2.16.2\mrtg-2.16.2\contrib\snmpping>snmpping.pl 192.168.0.146
=> Linux localhost.localdomain 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686

bx2aa
2009-01-14, 12:27 AM
CentOS 5.2 全新
僅裝 基礎系統 和 開發工具 和 函式庫
[root@localhost /]# rpm -ivh /mnt/CentOS/lm_sensors-2.10.0-3.1.i386.rpm
warning: /mnt/CentOS/lm_sensors-2.10.0-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:lm_sensors ########################################### [100%]
[root@localhost /]# rpm -ivh /mnt/CentOS/net-snmp-5.3.1-24.el5.i386.rpm
warning: /mnt/CentOS/net-snmp-5.3.1-24.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:net-snmp ########################################### [100%]
[root@localhost /]# chkconfig snmpd on
[root@localhost /]# service snmpd restart
正在停止 snmpd: [失敗]
正在啟動 snmpd: [ 確定 ]
[root@localhost /]#

[root@localhost /]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:snmp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:162
ACCEPT udp -- anywhere anywhere state NEW udp dpt:snmp
ACCEPT udp -- anywhere anywhere state NEW udp dpt:snmp
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:DF:B8:69
inet addr:192.168.0.109 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:b869/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1632 errors:0 dropped:0 overruns:0 frame:0
TX packets:1649 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:151478 (147.9 KiB) TX bytes:704536 (688.0 KiB)
Base address:0x10f0 Memory:e8820000-e8840000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)

一樣用 MRTG 的 snmpping.pl
在 XP
C:\Downloads\mrtg-2.16.2\mrtg-2.16.2\contrib\snmpping>snmpping.pl 192.168.0.109
=> Linux localhost.localdomain 2.6.18-92.el5 #1 SMP Tue Jun 10 18:49:47 EDT 2008 i686

shung0116
2009-01-15, 06:49 PM
前輩的步驟 我有照作 但遇到下列的狀況 如下語法所示
[root@anderson2 tmp]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

執行iptables -L 只有下面幾行 沒有前輩所列的其它rule
而ifconfig是檢測網路組態設定用

且在執行snmpping.pl 192.168.1.35 會出現下列的訊息
-->Can't locate BER.pm in @INC <@INC contains: ../../run C:/Perl/site/lib C:/Perl/lib .> at C:\mrtg-2.16.2\mrtg-2.16.2\contrib\snmpping\snmpping.pl line 3. BEGIN failed--compilation aborted at C:\mrtg-2.16.2\mrtg-2.16.2\contrib\snmpping\snmpping.pl line 3

是否我有那個步驟有錯呢?煩請前輩指點
謝謝

bx2aa
2009-01-15, 09:35 PM
編輯 \contrib\snmpping\snmpping.pl
修改 use lib qw(../../run); 為 use lib qw(../../lib/mrtg2);

iptables -L
是我當時用的
你用 service iptables stop 就不用管 iptables -L

shung0116
2009-01-16, 07:46 PM
但是執行後卻出現下列的錯誤訊息
-->SNMP Error:
receiving response PDU: Unknown error
SNMPv1_Session <remote host: "192.168.1.35" [192.168.1.35].161>
community:"public"
request ID:-1913781773
PDU bufsize: 8000 bytes
timeout:2s
retries:5
backoff:1>
at c:\mrtg-2.16.2\contrib\snmpping\snmpping.pl line 15

於是我使用下列的方式telnet 192.168.1.35 161 發現似乎服務並沒有開啟
於是我在CentOS執行service snmpd start
但卻還是回到之前的老問題:snmpd已停止執行但pid檔案仍在

為什麼會這樣呢?
煩請前輩指點
謝謝

shung0116
2009-01-16, 08:00 PM
在Centos上,我本來想用另外的方式,如視窗方式來開啟snmpd服務,或者webmin視窗設定方式,但卻都發生下列狀況
-->服務有開啟,但是檢測其服務狀態,都是顯示:snmpd已停止執行但pid檔案仍在
(IPTABLES已停止)
謝謝

bx2aa
2009-01-17, 01:27 AM
開不起來就要看 /var/log/messages 有沒有訊息了!
tail -f /var/log/messages

另一台 snmpping.pl 看 tail -f 有沒有顯示訊息.

我都是隨便裝一裝, 然後就隨便開起來.

移除:
rpm -qa | grep snmp
snmpxxxxxxxx

rpm -e ........... 把 snmpxxxxxxxx 移掉

which snmpd
看有沒有還留著的 snmpd

netstat -a | grep :snmp
看還有沒有在執行

umount /dev/hdc
放光碟
mount /dev/hdc /mnt
rpm -ivh /mnt/CentOS/net-snmp-5.3.1-24.el5.i386.rpm

service snmpd restart

cat /etc/snmp/snmpd.conf
我的沒動過的
[root@localhost snmp]# cat snmpd.conf | grep -v "^#" | grep -v ^$
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact systemview none none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
[root@localhost snmp]#

snmpping.pl ???.???.???.??? public <------ 沒改過的
C:\Downloads\mrtg-2.16.2\mrtg-2.16.2\contrib\snmpping>snmpping.pl 192.168.0.146 public
=> Linux localhost.localdomain 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686

我改為
com2sec notConfigUser default bx2aa

C:\Downloads\mrtg-2.16.2\mrtg-2.16.2\contrib\snmpping>snmpping.pl 192.168.0.146 bx2aa
=> Linux localhost.localdomain 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686


我用
tail -f /var/log/messages

然後關或開 snmpd 或是登入都有訊息

[root@localhost log]# tail -f /var/log/messages
Jan 16 18:08:35 localhost snmpd[1912]: Received SNMP packet(s) from UDP: [192.168.0.129]:2149
Jan 16 18:10:30 localhost snmpd[1912]: Connection from UDP: [192.168.0.129]:2150
Jan 16 18:10:30 localhost snmpd[1912]: Received SNMP packet(s) from UDP: [192.168.0.129]:2150
Jan 16 18:10:50 localhost snmpd[1912]: Connection from UDP: [192.168.0.129]:2151
Jan 16 18:10:50 localhost snmpd[1912]: Received SNMP packet(s) from UDP: [192.168.0.129]:2151
Jan 16 18:11:10 localhost dhcpd: DHCPREQUEST for 192.168.0.129 from 00:00:00:00:00:0c via eth0: unknown lease 192.168.0.129.
Jan 16 18:13:19 localhost dhcpd: DHCPREQUEST for 192.168.0.129 from 00:00:00:00:00:0c via eth0: unknown lease 192.168.0.129.
Jan 16 18:14:21 localhost snmpd[1912]: Connection from UDP: [192.168.0.129]:2198
Jan 16 18:14:21 localhost snmpd[1912]: Received SNMP packet(s) from UDP: [192.168.0.129]:2198
Jan 16 18:14:27 localhost snmpd[1912]: Received TERM or STOP signal... shutting down...
Jan 16 18:14:47 localhost gdm[2357]: gdm_slave_session_start: /root 可以被相同群組的使用者寫入。
Jan 16 18:14:53 localhost gconfd (root-2622): 啟動 (2.14.0 版本),pid 2622,使用者‘root’
Jan 16 18:14:53 localhost gconfd (root-2622): 第 0 個位置的位址“xml:readonly:/etc/gconf/gconf.xml.mandatory”已解析為一個唯讀的設定來源
Jan 16 18:14:53 localhost gconfd (root-2622): 第 1 個位置的位址“xml:readwrite:/root/.gconf”已解析為一個可寫入的設定來源
Jan 16 18:14:53 localhost gconfd (root-2622): 第 2 個位置的位址“xml:readonly:/etc/gconf/gconf.xml.defaults”已解析為一個唯讀的設定來源
Jan 16 18:15:02 localhost hcid[1760]: Default passkey agent (:1.5, /org/bluez/applet) registered
Jan 16 18:15:03 localhost pcscd: winscard.c:219:SCardConnect() Reader E-Gate 0 0 Not Found
Jan 16 18:15:03 localhost last message repeated 4 times
Jan 16 18:15:06 localhost gconfd (root-2622): 第 0 個位置的位址“xml:readwrite:/root/.gconf”已解析為一個可寫入的設定來源
Jan 16 18:15:36 localhost snmpd[2792]: NET-SNMP version 5.3.1