全部博文(403)
分类: LINUX
2009-10-28 15:09:59
首先保证机器上要安装net-snmp
# rpm -qa|grep snmp net-snmp-5.3.0.1-25.25
被查询的机器上需要开启snmpd服务:
1. 编辑/etc/snmp/snmpd.conf,suse 10上该文件默认是不能工作的,将文件替换成下面的内容即可。
# First, map the community name (COMMUNITY) into a security name # (local and mynetwork, depending on where the request is coming # from): # sec.name source community com2sec notConfigUser default public #### # Second, map the security names into group names: # sec.model sec.name group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser #### # Third, create a view for us to let the groups have rights to: # incl/excl subtree mask view all included .1 80 #### # Finally, grant the 2 groups access to the 1 view with different # write permissions: # context sec.model sec.level match read write notif access notConfigGroup "" any noauth exact all none none
2. 启动snmpd
#service snmpd restart
3. 配置snmpd自动运行
# chkconfig -e snmpd snmpd 3
4. 通过snmp查询所有网卡名字
# snmpwalk -v 2c -c public localhost IF-MIB::ifDescr IF-MIB::ifDescr.1 = STRING: lo IF-MIB::ifDescr.2 = STRING: eth0
5. 查询指定网卡状态
# snmpwalk -v 2c -c public localhost IF-MIB::ifOperStatus.2 IF-MIB::ifOperStatus.2 = INTEGER: up(1)
6. 查询网卡流量