suse安装snmp_suse 10如何通过snmp查询网卡状态

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

# rpm -qa|grep snmp

net-snmp-5.3.0.1-25.25# 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

# (localandmynetwork, depending on where the request is coming

# from):

#       sec.name  source          community

com2sec notConfigUserdefaultpublic

####

# Second, map the security names into group names:

#               sec.model  sec.name

group   notConfigGroup v1           notConfigUser

group   notConfigGroup   v2c           notConfigUser

####

# Third, create a viewforus 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# 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#service snmpd restart

3. 配置snmpd自动运行

# chkconfig -e snmpd

snmpd  3# chkconfig -e snmpd

snmpd 3

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

# snmpwalk -v 2c -cpubliclocalhost IF-MIB::ifDescr

IF-MIB::ifDescr.1 = STRING: lo

IF-MIB::ifDescr.2 = STRING: eth0# 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 -cpubliclocalhost IF-MIB::ifOperStatus.2

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

IF-MIB::ifOperStatus.2 = INTEGER: up(1)

6. 查询网卡流量

# snmpwalk -v 2c -cpubliclocalhost IF-MIB::ifHCOutOctets.2//网卡出流量

IF-MIB::ifHCOutOctets.2 = Counter64: 3118479769

# snmpwalk -v 2c -cpubliclocalhost IF-MIB::ifHCInOctets.2//入流量

IF-MIB::ifHCInOctets.2 = Counter64: 2352396350

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值