snmp安装


yum -y install net-snmp-libs net-snmp net-snmp-utils

系统镜像里面就有这些包。可yum安装

 

snmpwalk集合

snmpwalk + -c SNMP读密码 + -v 1或2(SNMP版本) + 交换机或路由器IP地址 + OID(对象标示符)
(-v指版本,-c 指密钥,即客户端snmp.conf里所设置)

(具体OID请自行查找)
1、snmpwalk -v 2c -c public 9.0.0.1 .1.3.6.1.2.1.4.20 取得IP信息

2、snmpwalk -v 2c -c public 9.0.0.1 system 查看系统信息

3、snmpwalk -v 2c -c public 9.0.0.1 ifDescr 获取网卡信息

4、snmpwalk -v 2c -c public 9.0.0.1 所有系统信息都获取

5、snmpwalk -v 2c -c public 9.0.0.1 1.3.6.1.4.1.9.9.109.1.1.1.1.7.1 获取CPU使用率

在日常监控中,经常会用到snmp服务,而snmpwalk命令则是测试系统各种信息最有效的方法,命令格式:
snmpwalk -c SNMP读密码 -v 1或2(代表SNMP版本) 交换机或路由器IP地址 OID(对象标示符)

 

snmpwalk详情

1、snmpwalk -v 2c -c public 9.0.0.1 .1.3.6.1.2.1.4.20 取得IP信息

[root@mcw telnet]# snmpwalk -v 2c -c Bxxxxxx 172.x.x.x .1.3.6.1.2.1.1
SNMPv2-MIB::sysDescr.0 = STRING: MySecSSL3600
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.32328.1.2.1
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (2727) 0:00:27.27
SNMPv2-MIB::sysContact.0 = STRING: Secworld Corp.
SNMPv2-MIB::sysName.0 = STRING: SecSSL
SNMPv2-MIB::sysLocation.0 = STRING: China
SNMPv2-MIB::sysServices.0 = INTEGER: 72
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.7 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.8 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for the SNMP User-based Sec
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering.
SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.10 = Timeticks: (0) 0:00:00.00
[root@mcw telnet]# echo $?
0

2、snmpwalk -v 2c -c public 9.0.0.1 system 查看系统信息

[root@mcw telnet]# snmpwalk -v 2c -c Bxxxxxx 172.x.x.x system
SNMPv2-MIB::sysDescr.0 = STRING: MySecSSL3600
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.32328.1.2.1
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (391115) 1:05:11.15
SNMPv2-MIB::sysContact.0 = STRING: Secworld Corp.
SNMPv2-MIB::sysName.0 = STRING: SecSSL
SNMPv2-MIB::sysLocation.0 = STRING: China
SNMPv2-MIB::sysServices.0 = INTEGER: 72
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.7 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.8 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering.
SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.10 = Timeticks: (0) 0:00:00.00

3、snmpwalk -v 2c -c public 9.0.0.1 ifDescr 获取网卡信息

[root@mcw telnet]# snmpwalk -v 2c -c Bxxxxxx 172.x.x.x ifDescr
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: dummy0
IF-MIB::ifDescr.3 = STRING: teql0
IF-MIB::ifDescr.4 = STRING: tunl0
IF-MIB::ifDescr.5 = STRING: sit0
IF-MIB::ifDescr.6 = STRING: ip6tnl0
IF-MIB::ifDescr.7 = STRING: eth0
IF-MIB::ifDescr.8 = STRING: eth1
IF-MIB::ifDescr.9 = STRING: eth2
IF-MIB::ifDescr.10 = STRING: eth3
IF-MIB::ifDescr.11 = STRING: eth4
IF-MIB::ifDescr.12 = STRING: eth5
IF-MIB::ifDescr.13 = STRING: eth7
IF-MIB::ifDescr.14 = STRING: eth6
IF-MIB::ifDescr.15 = STRING: br0
IF-MIB::ifDescr.16 = STRING: br1
IF-MIB::ifDescr.17 = STRING: br2
IF-MIB::ifDescr.18 = STRING: br3
IF-MIB::ifDescr.19 = STRING: bond0
IF-MIB::ifDescr.20 = STRING: bond1
IF-MIB::ifDescr.21 = STRING: bond2
IF-MIB::ifDescr.22 = STRING: bond3
IF-MIB::ifDescr.23 = STRING: tun8806
IF-MIB::ifDescr.24 = STRING: tun8808
IF-MIB::ifDescr.25 = STRING: tun8807
IF-MIB::ifDescr.26 = STRING: tun8809

4、snmpwalk -v 2c -c public 10.103.33.1 .1.3.6.1.2.1.25.1 得到取得windows端的系统进程用户数等

其中-v是指版本,-c 是指密钥,也就是客户端snmp.conf里面所设置的,下面类同.
[root@mcw telnet]# snmpwalk -v 2c -c Bxxxxxx 172.x.x.x .1.3.6.1.2.1.25.1
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (515953528) 59 days, 17:12:15.28
HOST-RESOURCES-MIB::hrSystemDate.0 = STRING: 2021-11-1,17:34:18.0,+8:0
HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0 = INTEGER: 393216
HOST-RESOURCES-MIB::hrSystemInitialLoadParameters.0 = STRING: "initrd=linux.gz root=/dev/ram rw console=ttyS0,9600
"
HOST-RESOURCES-MIB::hrSystemNumUsers.0 = Gauge32: 0
HOST-RESOURCES-MIB::hrSystemProcesses.0 = Gauge32: 127
HOST-RESOURCES-MIB::hrSystemMaxProcesses.0 = INTEGER: 0

5、snmpwalk -v 2c -c public 10.103.33.1 .1.3.6.1.2.1.25.2.2 取得系统总内存

[root@mcw telnet]# snmpwalk -v 2c -c Bxxxxxx 172.x.x.x .1.3.6.1.2.1.25.2.2
HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 8069916 KBytes

6、snmpwalk -v 2c -c public 10.103.33.1 hrSystemNumUsers 取得系统用户数

[root@mcw telnet]# snmpwalk -v 2c -c Bxxxxxx 172.x.x.x hrSystemNumUsers
HOST-RESOURCES-MIB::hrSystemNumUsers.0 = Gauge32: 0

7、检查snmpd服务是否已在运行:

[toptea@toptea ~]$ ps -ef|grep snmp
root 1117 1 0 2018 ? 01:43:25 /usr/sbin/snmpd TCP:10161 UDP:10161 -LS0-6d -f
# netstat -nlup | grep "161"
#netstat -anp |grep snmpd
udp 0 0 0.0.0.0:161 0.0.0.0:* 16986/snmpd

 

 

 

 

 

参考链接:https://blog.csdn.net/jorson2000a/article/details/81461099

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/machangwei-8/p/15481634.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!

相关课程

4092 178.2元 198元 9折