阅读:2040回复:4
这是为什么??小弟想自己定义一个MIB,并实现SNMP Agent的扩展。为此默认安装了net-snmp-5.0.2a.tar.gz(完全安装了RedHat Linux 7.2),设置好snmpd.conf。关闭系统原有的snmp,修改启动脚本并重新启动,整个软件正常工作,可以通过软件进行远程操作。为了能使用mib2c,我进入perl,按照说明安装了所需要的perl模块。 现在想使用一下mib2c,进入/usr/local/bin执行如下命令: Bash# ./mib2c -c mib2c.scalar.conf ucdDemoMIB 发现产生了ucdDemoMIB.c和ucdDemoMIB.h两个文件。 而后我在/uer/local/share/snmp/mibs下做了一个UCD-TT.txt文件(是拷贝UCD-DEMO-MIB.txt并进行修改的),其内容是: ===================文件开始============================ UCD-TT DEFINITIONS ::= BEGIN IMPORTS MODULE-IDENTITY, OBJECT-TYPE, Integer32 FROM SNMPv2-SMI ucdavis FROM UCD-SNMP-MIB; ucdTtMIB MODULE-IDENTITY LAST-UPDATED \"0212090000Z\" ORGANIZATION \"Luminent\" CONTACT-INFO \"This mib is no longer being maintained by the University of California and is now in life-support-mode and being maintained by the net-snmp project. The best place to write for public questions about the net-snmp-coders mailing list at net-snmp-coders@lists.sourceforge.net. postal: Wes Hardaker P.O. Box 382 Davis CA 95617 email: net-snmp-coders@lists.sourceforge.net \" DESCRIPTION \"Test MIB.\" REVISION \"0212090000Z\" DESCRIPTION \"SMIv2 version converted from older MIB definitions.\" ::= { ucdavis 14 } ucdTtObjects OBJECT IDENTIFIER ::= { ucdTtMIB 1 } ucdTtPublic OBJECT IDENTIFIER ::= { ucdTtMIBObjects 1 } ucdTtResetKeys OBJECT-TYPE SYNTAX Integer32 (0..2147483647) MAX-ACCESS read-write STATUS current DESCRIPTION \"A set of value 1 to this object resets the demonstration user\'s auth and priv keys to the keys based on the P->Ku->Kul transformation of the value of the ucdDemoPasspharse object. Values other than 1 are ignored.\" ::= { ucdTtPublic 1 } ucdTtPublicString OBJECT-TYPE SYNTAX OCTET STRING (SIZE(0..1024)) MAX-ACCESS read-write STATUS current DESCRIPTION \"A publicly settable string that can be set for testing snmpsets. This value has no real usage other than testing purposes.\" ::= { ucdTtPublic 2 } ucdTtUserList OBJECT-TYPE SYNTAX OCTET STRING MAX-ACCESS read-only STATUS current DESCRIPTION \"The list of users affected by the ucdDemoResetKeys object.\" ::= { ucdTtPublic 3 } ucdTtPassphrase OBJECT-TYPE SYNTAX OCTET STRING MAX-ACCESS read-only STATUS current DESCRIPTION \"The demo passphrase that ucdDemoResetKeys changes each users localized key to based on the P->Ku->Kul transformation.\" ::= { ucdTtPublic 4 } END ======================文件末尾============================ 而后执行 Bash# ./mib2c -c mib2c.scalar.conf ucdTtMIB 但是不但没有产生我想要的C语言文件反而有一个出错信息: you didn\'t give a valid OID to start with at mib2c line 112. 这是为什么?请大虾们帮个忙,感激不仅!!! 酷小鸭(tugen@citiz.net) |
|
|
沙发#
发布于:2002-08-15 11:22
请问snmp.conf应该怎么配置啊?我的net-snmp还不能用啊!
|
|
板凳#
发布于:2002-08-16 08:27
最好不要用net-snmp先,因为它的mib2c是有针对性的,比如:非表标量、表标量等,即便是表的处理还有不同点。
看了其转换过来的代码,觉得应该比ucd-snmp更合理,但出于新软件有很少的参考资料,所以我们最后还是选择了ucd-snmp-4.2.5做扩展!!请你也使用这个吧!! MCF5272不带MMU,跑在上面的uCLinux不支持system V,所以用这个方案的朋友可以采用命名管道的方式实现进程间通信(一个小提议)。 |
|
|
地板#
发布于:2002-08-16 14:39
为什么我装了ucd-snmp,copy了一个管理程序原码,
#gcc -g -I/usr/local/include -o snmpapp snmpapp.c -L/usr/local/lib -lsnmp 出错,ld:cannot find lsnmp 如果把-lsnmp去掉,那就有一大堆函数不认识,我该怎么办呀? |
|
地下室#
发布于:2002-08-16 18:48
最好做个Makefile,这样也方便管理和程序修改!
这个文件不复杂,产生模块用于动态加载方便调试,成功后就可以直接编译进agent中,我们的Makefile是这样的: CC =gcc CFLAGS =-I /usr/local/include -g OBJS1 =shanghaiFOCI.o DLFLAGS =-fPIC -shared clean: rm $(OBJS1) shanghaiFOCI.so:shanghaiFOCI.c Makefile $(CC) $(CFLAGS) $(DLFLAGS) -c -o shanghaiFOCI.o shanghaiFOCI.c $(CC) $(CFLAGS) $(DLFLAGS) -o shanghaiFOCI.so shanghaiFOCI.o |
|
|