net-snmp time-out问题

dd43188 2011-05-01 01:01:42
最近在做毕设,题目是linux环境下周围活动主机信息状态的收集,用的是net-snmp,经过不懈努力终于装好了,参考的是一本叫做<net-snmp安装配置手册>,张兵写的。
snmpwalk -v 2c -c public localhost if
配置完net-snmp后用上边的命令对其进行本地测试,一直显示的是Timeout: No Response from localhost。
我本机是win7的用虚拟机装的red hat 9。本机上有用tomcat假设的一个服务器。本机和服务器桥接上网。
我怀疑是snmpd.conf这个设置的问题,应为我不太会填那个IP。
这是我在里边修改的内容
# sec.name source community
com2sec local localhost public
com2sec mynetwork 192.168.1.105 public //这个是本机的IP

忘高手帮忙解答下,救人如救火啊,这几天就要交了。。。还需要什么信息尽管说,在这先谢谢了。。。
...全文
1822 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wander1006 2012-05-03
  • 打赏
  • 举报
回复
[root@cc~]# service snmpd restart
Stopping snmpd: [FAILED]
Starting snmpd: [FAILED]
[root@cc ~]# snmpd -L
Error opening specified endpoint ""
Server Exiting with code 1


也遇到了和楼主差不多的问题,求解!!
zhangjizhou 2012-02-13
  • 打赏
  • 举报
回复
推测是防火墙的原因
dd43188 2011-05-01
  • 打赏
  • 举报
回复
不如加Q吧,你QQ多少
dd43188 2011-05-01
  • 打赏
  • 举报
回复

###############################################################################
#
# EXAMPLE.conf:
# An example configuration file for configuring the ucd-snmp snmpd agent.
#
###############################################################################
#
# This file is intended to only be an example. If, however, you want
# to use it, it should be placed in /usr/local/net-snmp/etc/snmp/snmpd.conf.
# When the snmpd agent starts up, this is where it will look for it.
#
# You might be interested in generating your own snmpd.conf file using
# the "snmpconf" program (perl script) instead. It's a nice menu
# based interface to writing well commented configuration files. Try it!
#
# Note: This file is automatically generated from EXAMPLE.conf.def.
# Do NOT read the EXAMPLE.conf.def file! Instead, after you have run
# configure & make, and then make sure you read the EXAMPLE.conf file
# instead, as it will tailor itself to your configuration.

# All lines beginning with a '#' are comments and are intended for you
# to read. All other lines are configuration commands for the agent.

#
# PLEASE: read the snmpd.conf(5) manual page as well!
#


###############################################################################
# Access Control
###############################################################################

# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY
# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO
# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.

# By far, the most common question I get about the agent is "why won't
# it work?", when really it should be "how do I configure the agent to
# allow me to access it?"
#
# By default, the agent responds to the "public" community for read
# only access, if run out of the box without any configuration file in
# place. The following examples show you other ways of configuring
# the agent so that you can change the community names, and give
# yourself write access as well.
#
# The following lines change the access permissions of the agent so
# that the COMMUNITY string provides read-only access to your entire
# NETWORK (EG: 10.10.10.0/24), and read/write access to only the
# localhost (127.0.0.1, not its real ipaddress).
#
# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.

####
# First, map the community name (COMMUNITY) into a security name
# (local and mynetwork, depending on where the request is coming
# from):

# sec.name source community
com2sec mynetwork 127.0.0.1 public
com2sec mynetwork 192.168.1.105 public
####
# Second, map the security name into a group name:

# groupName securityModel securityName
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser
group my_group v1 mynetwork
group my_group v2c mynetwork
####
# Third, create a view for us to let the group have rights to:

# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80
####
# Finally, grant the group read-only access to the systemview view.

# group context sec.model sec.level prefix read write notif
#access notConfigGroup "" any noauth exact systemview none none
access my_group "" any noauth exact all none none

#-----------------------------------------------------------------------------

dd43188 2011-05-01
  • 打赏
  • 举报
回复
还是不行
[root@localhost root]# snmpd -L
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
[root@localhost root]# Error opening specified endpoint ""
Server Exiting with code 1

[root@localhost root]#

报告一个糟糕的问题,我刚才试了下service snmpd start 直接说没有这个服务-。- 问题比较多,dream哥不要放弃我呀,哈哈,谢谢了饿

snmpd代码如下
steptodream 2011-05-01
  • 打赏
  • 举报
回复
修改你的snmpd.conf 对应的下面那些段做如下修改 然后重启snmpd再测试


# sec.name source community
com2sec mynetwork 127.0.0.1 public
com2sec mynetwork 192.168.1.105 public
####
# Second, map the security name into a group name:

# groupName securityModel securityName
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser
group my_group v1 mynetwork
group my_group v2c mynetwork
####
# Third, create a view for us to let the group have rights to:

# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80
####
# Finally, grant the group read-only access to the systemview view.

# group context sec.model sec.level prefix read write notif
#access notConfigGroup "" any noauth exact systemview none none
access my_group "" any noauth exact all none none
dd43188 2011-05-01
  • 打赏
  • 举报
回复
执行结果如下

[root@localhost net-snmp-5.4.1]# netstat -uan | grep 161
udp 0 0 0.0.0.0:161 0.0.0.0:*
[root@localhost net-snmp-5.4.1]# ps -ef | grep snmpd
root 32718 1 0 11:21 ? 00:00:00 snmpd
root 403 2880 0 11:34 pts/0 00:00:00 grep snmpd
[root@localhost net-snmp-5.4.1]# ps -ef | grep snmpd
dd43188 2011-05-01
  • 打赏
  • 举报
回复
dream哥神算,执行如下
[root@localhost net-snmp-5.4.1]# netstat -uan | grep 161
udp 0 0 0.0.0.0:161 0.0.0.0:*
[root@localhost net-snmp-5.4.1]#
dd43188 2011-05-01
  • 打赏
  • 举报
回复
上边说的啰嗦了
反正就是启动失败了
[root@localhost net-snmp-5.4.1]# snmpd -L
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
[root@localhost net-snmp-5.4.1]# Error opening specified endpoint ""
Server Exiting with code 1

[root@localhost net-snmp-5.4.1]#
steptodream 2011-05-01
  • 打赏
  • 举报
回复
看看161的udp端口是否监听即可(按我的猜测十有八九你的snmpd启动失败了)
netstat -uan | grep 161
或者
ps -ef | grep snmpd
dd43188 2011-05-01
  • 打赏
  • 举报
回复
其中有一部设置的自启动 在rc.local里添加了 /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf &
启动如下,snmpd -L –Denseirb是在网上看的,说会显示启动信息,但是为什么会有错误信息呢,请楼上指点
[root@localhost net-snmp-5.4.1]# snmpd

[root@localhost net-snmp-5.4.1]# snmpd -L –Denseirb
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load()
[root@localhost net-snmp-5.4.1]# getaddrinfo: –Denseirb Name or service not known
Error opening specified endpoint "–Denseirb"
Server Exiting with code 1
steptodream 2011-05-01
  • 打赏
  • 举报
回复
你启动snmpd了吗
dd43188 2011-05-01
  • 打赏
  • 举报
回复
自己顶一个先~~

18,830

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧