• [转]linux系统下安装配置netsnmp


    关于net-snmp
    维基百科简介:http://zh.wikipedia.org/zh/NET-SNMP
     
    安装配置共分以下几步
    1.获取源文件
    2.解压缩
    3.配置configure参数
    4.编译安装
    5.配置snmpd.conf文件
    6.设置环境变量
    7.添加自启动脚本
    8.启动snmp服务
    9.测试snmp服务
     
     
    第一步:
    获取源文件
    wget http://sourceforge.net/projects/net-snmp/files/net-snmp/5.3.3/net-snmp-5.3.3.tar.gz
     
    第二步:
    解压缩
    gunzip net-snmp-5.3.3.tar.gz
    tar -xvf net-snmp-5.3.3.tar
     
    第三步:
    配置configure参数
    cd net-snmp-5.3.3
    ./configure --prefix=/usr/local/net-snmp --enable-mfd-rewrites --with-default-snmp-version="2" --with-sys-location="China" --with-sys-contact="Email:songyunkui@kingsoft.com" --with-logfile="/usr/local/net-snmp/log/snmpd.log"  --with-persistent-directory="/var/net-snmp"
    --ps:参数包括了 将要安装的文件路径允许用新的重写可用的模块默认的版本设备的地址信息设备的联系人信息日志文件 永久数据存放目录
    温馨提示:在这里如果我们不指定版本、设备地址、设备联系人、log文件及永久数据目录的话那么在接下来的配置时会让我们进行交互选择,刚开始安装时这几个选项把我整蒙了
    配置最后(大概一分钟左右)会生成configure的摘要信息,也许会有warning不过不用理他
    ---------------------------------------------------------
                Net-SNMP configuration summary:
    ---------------------------------------------------------
     
      SNMP Versions Supported:    1 2c 3
      Net-SNMP Version:           5.3.3
      Building for:               linux
      Network transport support:  Callback Unix TCP UDP
      SNMPv3 Security Modules:    usm
      Agent MIB code:             mibII ucd_snmp snmpv3mibs notification notification-log-mib target agent_mibs agentx disman/event-mib disman/schedule utilities host
      SNMP Perl modules:          disabled
      Embedded perl support:      disabled
      Authentication support:     MD5 SHA1
      Encryption support:         DES AES
      WARNING:  New version of the Event MIB which may be subtly different from the original implementation - configure with 'disman/old-event-mib' for the previous version
     
     
    ---------------------------------------------------------
     
    第四步:
    编译并安装
    make && make install
    这个会稍微花点时间也就3-5分钟吧
     
     
    第五步:
    配置snmp.conf文件
    首先我们把源文件中的EXAMPLE.conf文件复制到/usr/local/net-snmp/share/snmp目录下并命名为snmp.conf
    cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmp.conf ##这个命令大家应该都懂的
     
    编辑snmp.conf文件
    找到
    #       sec.name  source          community 这个配置项
    #(sec.name:安全体名称 
    #source:定义请求的来源,在IP协议中,这个数据是IP地址。在net-snmp中用来对来源IP加以控制,但这个特性不是SNMP规定的,是net-snmp扩展的 .
    #community:共同体名称 )
    #原来的
    com2sec local     localhost       COMMUNITY
    com2sec mynetwork NETWORK/24      COMMUNITY
     
    #修改后的
    com2sec local     localhost       public
    com2sec mynetwork 192.168.8.30   public
    com2sec mynetwork 192.168.11.29   public
     
     
    第六步:
    设置net-snmp的环境变量
    设置环境变量 在/etc/profile文件下追加
    PATH=/usr/local/net-snmp/bin:/usr/local/net-snmp/sbin:$PATH
    export PATH
     
    第七步:
    添加到启动文件
    在/etc/rc.local文件末尾追加
    /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf&
     
    第八步:
    重新启动net-snmp服务
    /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmp.conf&
     
    第九步:
    测试
    本地通过localhost访问
    [root@localhost snmp]# snmpwalk -v 2c -c public localhost if
    IF-MIB::ifIndex.1 = INTEGER: 1
    IF-MIB::ifIndex.3 = INTEGER: 3
    IF-MIB::ifIndex.4 = INTEGER: 4
    IF-MIB::ifIndex.5 = INTEGER: 5
    IF-MIB::ifIndex.6 = INTEGER: 6
    IF-MIB::ifDescr.1 = STRING: lo
    IF-MIB::ifDescr.3 = STRING: eth0
    IF-MIB::ifDescr.4 = STRING: eth1
    IF-MIB::ifDescr.5 = STRING: sit0
    IF-MIB::ifDescr.6 = STRING: usb0
    本地通过ip访问
    [root@localhost snmp]# snmpwalk -v 2c -c public 192.168.8.30 if
    IF-MIB::ifIndex.1 = INTEGER: 1
    IF-MIB::ifIndex.3 = INTEGER: 3
    IF-MIB::ifIndex.4 = INTEGER: 4
    IF-MIB::ifIndex.5 = INTEGER: 5
    IF-MIB::ifIndex.6 = INTEGER: 6
    IF-MIB::ifDescr.1 = STRING: lo
    IF-MIB::ifDescr.3 = STRING: eth0
    IF-MIB::ifDescr.4 = STRING: eth1
    IF-MIB::ifDescr.5 = STRING: sit0
    IF-MIB::ifDescr.6 = STRING: usb0
    IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
    IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
    IF-MIB::ifType.4 = INTEGER: ethernetCsmacd(6)
    IF-MIB::ifType.5 = INTEGER: tunnel(131)
  • 相关阅读:
    MyBatis(第三方缓存整合原理&ehcache适配包下载)
    MyBatis(缓存机制)
    MyBatis(动态SQL2)
    MyBatis(动态SQL)
    MyBatis(映射文件中使用foreach标签时报错,属性collection的问题)
    MyBatis映射文件(编写SQL语句;可有可无(无的时候,使用注解编程))
    Python virtualenv with Sublime Text 3
    python & mongo问题记录
    CentOS On VirtualBox
    MySQL GROUP BY用法
  • 原文地址:https://www.cnblogs.com/sidesky/p/3092742.html
Copyright © 2020-2023  润新知