snmp
来源:原创
时间:2022-10-31
作者:脚本小站
分类:Linux
centos安装snmp:
yum -y install net-snmp-utils net-snmp
启动:
systemctl start snmpd.service
配置服务:
#### 第一步 # First, map the community name "public" into a "security name" # sec.name source community com2sec notConfigUser default 123456 # notConfigUser用户名,123456密码 #### 第二步 # Second, map the security name into a group name: # groupName securityModel securityName group notConfigGroup v1 notConfigUser # v1代表v1版本,v2c代表v2c版本 group notConfigGroup v2c notConfigUser # notConfigGroup这是组名,v2c是权限,notConfigUser是用户 #### 第三步 # Third, create a view for us to let the group have rights to: # Make at least snmpwalk -v 1 localhost -c public system fast again. # name incl/excl subtree mask(optional) view systemview included .1.3.6.1.2.1.1 # 定义视图,systemview是视图名称 view systemview included .1.3.6.1.2.1.25.1.1 # 这一串数字是oid,每个oid都代表一个监控指标 # oid的前几个数字允许,就代表有相同前缀的oid都允许 view systemview included .1.3. # .1.3 开头的都可以访问 view systemview included ./ # 可以访问所有 #### 最后一步 # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access notConfigGroup "" any noauth exact systemview none none # 将systemview赋权给notConfigGroup组
测试:两种方式效果一样
]# snmpwalk -v 2c -c 123456 192.168.199.183 .1.3.6.1.2.1.25.1.1 HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (354360417) 41 days, 0:20:04.17 ~]# snmpwalk -v 2c -c 123456 192.168.199.183 hrSystemUptime HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (354360876) 41 days, 0:20:08.76
流量监控:
snmpwalk -v 2c -c public 192.168.199.183 ifHCOutOctets #网口出流量 snmpwalk -v 2c -c public 192.168.199.183 ifHCInOctets #网口入流量 snmpwalk -v 2c -c public 192.168.199.183 ifOperStatus #网口状态 snmpwalk -v 2c -c public 192.168.199.183 ifDescr #网口名称 snmpwalk -v 2c -c public 192.168.199.183 laLoad #1,5,10分钟负载
snmp oid列表:
cnblogs.com/lsgxeva/p/9220974.html