首页 > 代码库 > yum安装snmp

yum安装snmp

1.安装 snmp服务

[root@localhost] yum install -y net-snmp net-snmp-utils

2.配置snmp服务

第一步:
(yum安装snmpd的配置文件为/etc/snmp/snmpd.conf ,一份非常详细的文档,先备份一份snmpd.conf)

[root@localhost] mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
3.运行snmp服务

[root@localhost] service snmpd start
Starting snmpd:                                            [  OK  ]

4.设置成开机自动运行snmpd服务

[root@localhost] chkconfig snmpd on
[root@localhost] chkconfig –list|grep snmpd
snmpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

 

SNMP报错

创建SNMP – Interface Statistics报错,如下:

Created graph: db-m2-slave-2 - Traffic - |query_ifName|

ERROR: no Data Source associated. Check Template

 

[root@squid-2 html]# snmpwalk -c public -v 2c 10.254.3.73 ifHCInOctets

IF-MIB::ifHCInOctets = No more variables left in this MIB View (It is past the end of the MIB tree)

 

[root@squid-2 html]# snmpwalk -c public -v 2c 10.254.3.73 if

IF-MIB::ifTable = No Such Object available on this agent at this OID

 

[root@squid-2 html]# snmpwalk -c public -v 2c 10.254.3.73 if

IF-MIB::ifTable = No more variables left in this MIB View (It is past the end of the MIB tree)

 

解决方法

在snmpd.conf配置文件里面,查找以下字段:

## incl/excl subtree mask

#view all included .1 80

将该行前面的"#"去掉.

之后重启snmpd服务解决。