现在的位置: 首页 > 操作系统 > 正文

net-snmp(5.7.2) install and test in linux

2019年05月30日 操作系统 ⁄ 共 2046字 ⁄ 字号 评论关闭

1. download net-snmp-5.7.2 source from http://www.net-snmp.org/download.html

2. cd net-snmp-5.7.2

3. ./configure

增加配置项目:

./configure --prefix=/usr/local/net-snmp --enable-mfd-rewrites --with-default-snmp-version="2" --with-sys-contact="Aaron_E_mail:lvsong@yaolan.com" --with-sys-location="China" --with-logfile="/var/log/snmpd.log"
--with-persistent-directory="/var/net-snmp"

note:

refix:net-snmp将要安装的路径

enable-mfd-rewrites:允许用新的MFD重写可用的mid模块

with-default-snmp-version:默认的SNMP版本

with-sys-contact:可以配置该设备的联系人

with-sys-location:该设备的位置

with-logfile:日志文件路径

with-persistent-directory:不变数据存储目录如果不添加那么多的参数,就一个prefix的话,后面的参数,在安装过程中都会有提示,所以说那些参数不是现在就必须要写得,ok配置完成后输出如下信息

4. make

error1: /bin/ld: cannot find -lperl

fix:

apt-get install libperl-dev

/usr/local/bin# ln -s libperl.so.5.10 libperl.so

5. make install

6. snmptrap fail
snmptrap: error while loading shared libraries: libnetsnmp.so.30: cannot open shared object file: No such file or directory

fix:

/usr/local/lib下所有的包都copy到/usr/lib

7. 拷贝配置文件模板,修改后重启snmpd(可kill后重新打开)

将EXAMPLE.conf文件复制到/usr/local/net-snmp/share/snmp/,并重命名为snmpd.conf

[root@localhost net-snmp-5.3.2]# cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf

修改配置文件将配置文件修改成下面的参数Sec.name是定义的别名,在后面的组中使用,组要用来赋予权限,是只读还是读写,source是允许那个地址来连接你的snmp,我现在写的这个是允许172.21.0.88这个地址来连接,如果你需要使用一个网段的话,那么就可以这么写了172.21.0.0/24,这个看的明白吧,community是共同体的名称,你用client连接snmp使用的,相当于密码

com2sec local     localhost       COMMUNITY
com2sec mynetwork 172.21.0.88     public

#                context sec.model sec.level match  read   write  notif
access MyROGroup ""      any       noauth    exact  all    none   none
access MyRWGroup ""      any       noauth    exact  all    none   none

8.启动snmp并后台运行

[root@localhost net-snmp-5.3.2]# /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf &

9.设置环境变量为了下一步的测试

[root@localhost net-snmp-5.3.2]# PATH=/usr/local/net-snmp/bin:/usr/local/net-snmp/sbin:$PATH

10.测试使用到snmpwalk这个命令

[root@localhost net-snmp-5.3.2]# snmpwalk -v 2c -c public localhost if
如果能看到下面的信息恭喜能,net-snmp安装配置完成,你可以去client使用监控软件开始工作了这里记住了,每次对snmpd.conf文件修改后,如果要生效,必须要杀掉snmp的老进程,在启用新的,要开机自动启动进程,我们可以使用这个在/etc/rc.d/rc.local文件中添加

/usr/local/net-snmp/sbin/snmpd –d 就ok了.

抱歉!评论已关闭.