Chinaunix首页 | 论坛 | 博客
  • 博客访问: 410066
  • 博文数量: 403
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: -70
  • 用 户 组: 普通用户
  • 注册时间: 2016-09-05 12:45
文章分类

全部博文(403)

文章存档

2014年(3)

2013年(1)

2012年(3)

2011年(21)

2010年(13)

2009年(64)

2008年(9)

2007年(36)

2006年(253)

分类: LINUX

2009-10-28 15:09:59

首先保证机器上要安装net-snmp

  1. # rpm -qa|grep snmp   
  2. net-snmp-5.3.0.1-25.25  

被查询的机器上需要开启snmpd服务:
1. 编辑/etc/snmp/snmpd.conf,suse 10上该文件默认是不能工作的,将文件替换成下面的内容即可。

  1. # First, map the community name (COMMUNITY) into a security name   
  2. # (local and mynetwork, depending on where the request is coming   
  3. # from):   
  4.   
  5. #       sec.name  source          community   
  6. com2sec notConfigUser  default  public  
  7.   
  8. ####   
  9. # Second, map the security names into group names:   
  10.   
  11. #               sec.model  sec.name   
  12. group   notConfigGroup v1           notConfigUser   
  13.   
  14. group   notConfigGroup   v2c           notConfigUser   
  15.   
  16. ####   
  17. # Third, create a view for us to let the groups have rights to:   
  18.   
  19. #           incl/excl subtree                          mask   
  20. view all    included  .1                               80   
  21.   
  22. ####   
  23. # Finally, grant the 2 groups access to the 1 view with different   
  24. # write permissions:   
  25.   
  26. #                context sec.model sec.level match  read   write  notif   
  27. access notConfigGroup ""      any       noauth    exact  all    none   none  

2. 启动snmpd

  1. #service snmpd restart  

3. 配置snmpd自动运行

  1. # chkconfig -e snmpd   
  2. snmpd  3  

4. 通过snmp查询所有网卡名字

  1. # snmpwalk -v 2c -c public localhost IF-MIB::ifDescr   
  2. IF-MIB::ifDescr.1 = STRING: lo   
  3. IF-MIB::ifDescr.2 = STRING: eth0  

5. 查询指定网卡状态

  1. # snmpwalk -v 2c -c public localhost IF-MIB::ifOperStatus.2   
  2. IF-MIB::ifOperStatus.2 = INTEGER: up(1)  

6. 查询网卡流量

  1. # snmpwalk -v 2c -c public localhost IF-MIB::ifHCOutOctets.2    //网卡出流量   
  2. IF-MIB::ifHCOutOctets.2 = Counter64: 3118479769   
  3. # snmpwalk -v 2c -c public localhost IF-MIB::ifHCInOctets.2    //入流量   
  4. IF-MIB::ifHCInOctets.2 = Counter64: 2352396350  
阅读(2216) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~