免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2706 | 回复: 5

请教关于snmp的一些问题 [复制链接]

论坛徽章:
0
发表于 2010-11-19 14:40 |显示全部楼层
最近在做一个利用snmp管理客户端(pc或tc)的项目,对snmp很不熟悉。

有一些问题,想请教一下各位

1 snmp如何探测设备?

2 管理端是否可以向 agent发送数据,或者远程执行agent上的命令?

多谢各位了。

论坛徽章:
0
发表于 2010-11-19 15:20 |显示全部楼层
现在想法是这样的
初步选用net-snmp,在agent上安装net-snmp,并且加入自己的mib库(从网上获得),在这个自定义的mib中,增加自己特殊的oid,例如.1.3.6.1.4.1.8888.1 ,将该变量设定为某个特定值,例如XXX

是否可以采用这样的方式来探测局域网中的设备呢?

轮询子网的每一台设备,发送get-request 获取oid .1.3.6.1.4.1.8888.1的值,来判断是否是自己想要的设备

论坛徽章:
5
IT运维版块每日发帖之星
日期:2015-08-06 06:20:00IT运维版块每日发帖之星
日期:2015-08-10 06:20:00IT运维版块每日发帖之星
日期:2015-08-23 06:20:00IT运维版块每日发帖之星
日期:2015-08-24 06:20:00IT运维版块每日发帖之星
日期:2015-11-12 06:20:00
发表于 2010-11-19 20:04 |显示全部楼层
据说可以

论坛徽章:
0
发表于 2010-11-20 08:30 |显示全部楼层
通过这样的方式来探测设备,应该是可行,可是效率上有点慢,试了一下,轮询60个IP,大概需要6分钟的时间,请问

1 还有没有高效一些的探测设备的机制,或者标准的探测机制是什么

2 如何在manager侧远程执行agent上的命令,如何从manager向agent端发送数据?

论坛徽章:
0
发表于 2010-11-20 17:58 |显示全部楼层
没有人回答吗?
自己顶一下。

关于这两个问题:

1 发现设备,打算暂时先这样做了

2 关于manager 远程执行agent上的命令(例如是shutdown),或者发送数据到agent上,初步想法是这样,在mib里增加一个oid,例如叫 commandId(.1.3.6.1.4.1.8888.2) , 用mib2c生成这个mib对应的.c和.h文件,在.c文件的
commandId的get-request的处理函数中,加入system(“shutdown -h now”),编译成动态库,然后在agent的snmpd.conf中加载这个动态库。
当manager发送一个get-request commandId的请求时,希望的结果是调用这个system,但是试验中这条system命令并没起作用
这地方难道要用net-snmp自身的api去执行某个函数吗?
或者用set-request 才可以?

感觉很迷惑,哪位大侠来给指点一下吧。

论坛徽章:
0
发表于 2010-11-20 19:35 |显示全部楼层
本帖最后由 wadext 于 2010-11-20 19:36 编辑

好吧,就当汇报进度了。

以下是net-snmp 邮件列表里一个朋友的回复:

Hi good to see you are progressing.  

Q1: you can shorten the timeout. That will help move stuff along. Or instead of looking for agents, you can maybe incorporate a protocol like bonjour or mdns? Google those and see. I forgot details on them

Q2: did you create an init_<module> and in there call the init function created by mib2c ? You also might want to make that one a set request, instead of get.

Good luck
David

On Nov 20, 2010 1:44 AM,  <xuteng@huaihuacity.com> wrote:
> Thanks David, and I still have to bother you with two questions.
>
> By now ,my practice is :
>
> I wrote my own mib which has two oids ,a vendorId (.1.3.6.1.4.1.8888.1, a string type ,read-only ,for detecting device) ,a commandId ((.1.3.6.1.4.1.8888.2, a string type, read-only ,for execute command on the agent) , add this mib to the agent
>
> question 1 : in detecting phase:
> I send the get-request for oid vendorID to the lan subnet , once anyone return the vendorId I wanted , the manager recognise the responser . In my test case, polling 60 IPs cost 6 minutes, it's a little slow, is anyother more effective way to detecte devices I wanted?
>
> question 2: in execute phase
> I want the agent to execute a command such as shutdown when the manager send a get-request for commandId, so ,I used the mib2c to generate .h and .c from the mib I defined myself , in the get-request-handler for commandId, I added a function system("shutdown -h now") , then compile these files to a dynamic library mylib.so , loaded it in the snmpd.conf on the agent ,restart snmpd service . but it doesn't work ,why ? How should I do ?
>
> Thanks
>
> Best Regards
>
> wade


他的意思好像是说:

1 关于发现设备 可以使用额外的bonjour 或者 mdns 协议来发现设备

2 关于manager远程执行agent上的命令,要是用set-request 而不是get-request

刚查了一下bonjour,好像是mac上的一种技术,不知道它的跨平台性能如何,哪位大侠了解麻烦给解释一下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP