centos6.4安装前准备
yum install gcc gcc-c++ -yyum -y install perl-CPAN
Ubuntu14.04 安装前准备
apt-get install gcc -yapt-get install libperl-dev
下载完后分别上传到指定的文件夹
[root@host-10-0-10-10 sbin]# cd /home/xiaoqiang/tools/ #我的工具目录(这里Ubuntu和Centos一样)tar xzvf net-snmp-5.7.1.tar.gzroot@test:/home/xiaoqiang/tools# lsnet-snmp-5.7.1 net-snmp-5.7.1.tar.gz
安装(这里Ubuntu和CentOS一样)
cd net-snmp-5.7.1 ./configure --prefix=/usr/local/snmp --with-mib-modules='ucd-snmp/diskio ip-mib/ipv4InterfaceTable' #接下来一路回车make && make install
配置
cd /usr/local/snmp mkdir etc #创建 etc目录cd /home/xiaoqiang/tools/net-snmp-5.7.1/ #回到源文件目录cp EXAMPLE.conf /usr/local/snmp/etc/cd /usr/local/snmp/etc/mv EXAMPLE.conf snmpd.conf
修改/usr/local/snmp/etc/snmpd.conf 3处地方
1、AGENT BEHAVIOUR模块的最后一行注释去掉,将原来没注释的注释掉。agentAddress udp:161 #保留这个内容2、ACTIVE MONITORING模块(设置版本) # send SNMPv1 traps# trapsink localhost public 将这一行原为未注释的注释 # send SNMPv2c traps trap2sink localhost public 将这个原为注释的取消注释3、ACCESS CONTROL模块 rocommunity public default -V systemonly 将该句改为 rocommunity public default最后保存
/usr/local/snmp/sbin/snmpd -c /usr/local/snmp/etc/snmpd.conf 启动服务 snmpget -v 2c -c public localhost sysName.0 snmpget -v 2c -c public 127.0.0.1 sysName.0 snmpget -v 2c -c public 192.168.1.229 sysName.0 snmpget -v 2c -c public localhost .1.3.6.1.2.1.1.5.0 snmpget -v 2c -c public 127.0.0.1 .1.3.6.1.2.1.1.5.0 snmpget -v 2c -c public 192.168.1.229 .1.3.6.1.2.1.1.5.0 检测lsof -i :161 #设置开机启动root@test:/home/xiaoqiang/tools/net-snmp-5.7.1# echo "/usr/local/snmp/sbin/snmpd -c /usr/local/snmp/etc/snmpd.conf" >> /etc/rc.local echo "export PATH=/usr/local/snmp/bin:$PATH" >> /etc/profile #配置环境变量