SNMP配置
1.安装
1 | yum install net-snmp #snmp 客户端 |
2 | yum install net-snmp-utils #snmp 管理端,如果使用snmp trap则需要安装net-snmp |
修改查看设备节点的权限
view:定义了可以查看哪些节点设备的信息。
snmp默认配置只能查看.1.3.6.1.2.1.1和.1.3.6.1.2.1.25.1.1节点下的设备信息,而主机CPU和内存等设备都不在这些节点下,所以无法获取这些数据。
在/etc/snmp/snmpd.conf
中,找到如下位置:
1 | #### |
2 | # Third, create a view for us to let the group have rights to: |
3 | |
4 | # Make at least snmpwalk -v 1 localhost -c public system fast again. |
5 | # name incl/excl subtree mask(optional) |
6 | view systemview included .1.3.6.1.2.1.1 |
7 | view systemview included .1.3.6.1.2.1.25.1.1 |
8 | view systemview included .1 #增加 |
取消如下注释
1 | proc mountd |
2 | |
3 | # Make sure there are no more than 4 ntalkds running, but 0 is ok too. |
4 | proc ntalkd 4 |
5 | |
6 | # Make sure at least one sendmail, but less than or equal to 10 are running. |
7 | proc sendmail 10 1 |
8 | exec echotest /bin/echo hello world |
9 | disk / 10000 |
10 | load 12 14 14 |
配置community
1 | # sec.name source community |
2 | #com2sec notConfigUser default public |
3 | |
4 | com2sec notConfigUser 127.0.0.1 mypublic |
5 | com2sec notConfigUser 172.16.16.0/24 public |
测试
1 | snmpnetstat -v 2c -c mypublic localhost |
2 | snmpwalk -v 2c -c public localhost hrStorageDescr |
3 | snmpwalk -v 2c -c public localhost host |