转自:http://blog.sina.com.cn/s/blog_63cf1c510101e7en.html
获取机器名:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 sysName.0
SNMPv2-MIB::sysName.0 = STRING: ubuntu-3
获取OS信息:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Linux ubuntu-3 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64
获取ip地址:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 ipAdEntAddr
IP-MIB::ipAdEntAddr.127.0.0.1 = IpAddress: 127.0.0.1
IP-MIB::ipAdEntAddr.192.168.100.100 = IpAddress: 192.168.100.100
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 ipAddressType.ipv4
IP-MIB::ipAddressType.ipv4."127.0.0.1" = INTEGER: unicast(1)
IP-MIB::ipAddressType.ipv4."192.168.100.100" = INTEGER: unicast(1)
TCP连接状态:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnState
TCP-MIB::tcpConnState.0.0.0.0.21.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.22.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.8000.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.192.168.100.100.22.192.168.2.171.50461 = INTEGER: established(5)
TCP-MIB::tcpConnState.192.168.100.100.3306.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.192.168.100.100.3306.192.168.100.100.59299 = INTEGER: established(5)
TCP-MIB::tcpConnState.192.168.100.100.3306.192.168.100.100.59300 = INTEGER: established(5)
TCP-MIB::tcpConnState.192.168.100.100.3306.192.168.100.100.59301 = INTEGER: established(5)
TCP本地连接地址:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnLocalAddress
TCP-MIB::tcpConnLocalAddress.0.0.0.0.21.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.0.0.0.0.22.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.0.0.0.0.8000.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.192.168.100.100.22.192.168.2.171.50461 = IpAddress: 192.168.100.100
TCP本地端口:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnLocalPort
TCP-MIB::tcpConnLocalPort.0.0.0.0.21.0.0.0.0.0 = INTEGER: 21
TCP-MIB::tcpConnLocalPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 22
TCP-MIB::tcpConnLocalPort.0.0.0.0.8000.0.0.0.0.0 = INTEGER: 8000
TCP-MIB::tcpConnLocalPort.192.168.100.100.22.192.168.2.171.50461 = INTEGER: 22
TCP-MIB::tcpConnLocalPort.192.168.100.100.3306.0.0.0.0.0 = INTEGER: 3306
TCP-MIB::tcpConnLocalPort.192.168.100.100.3306.192.168.100.100.59299 = INTEGER: 3306
TCP-MIB::tcpConnLocalPort.192.168.100.100.3306.192.168.100.100.59300 = INTEGER: 3306
TCP-MIB::tcpConnLocalPort.192.168.100.100.3306.192.168.100.100.59301 = INTEGER: 3306
TCP远程地址:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnRemAddress
TCP-MIB::tcpConnRemAddress.0.0.0.0.21.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.0.0.0.0.22.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.0.0.0.0.8000.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.192.168.100.100.22.192.168.2.171.50461 = IpAddress: 192.168.2.171
TCP-MIB::tcpConnRemAddress.192.168.100.100.3306.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.192.168.100.100.3306.192.168.100.100.59299 = IpAddress: 192.168.100.100
TCP-MIB::tcpConnRemAddress.192.168.100.100.3306.192.168.100.100.59300 = IpAddress: 192.168.100.100
TCP-MIB::tcpConnRemAddress.192.168.100.100.3306.192.168.100.100.59301 = IpAddress: 192.168.100.100
TCP远程端口:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnRemPort
TCP-MIB::tcpConnRemPort.0.0.0.0.21.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.0.0.0.0.8000.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.192.168.100.100.22.192.168.2.171.50461 = INTEGER: 50461
TCP-MIB::tcpConnRemPort.192.168.100.100.3306.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.192.168.100.100.3306.192.168.100.100.59299 = INTEGER: 59299
TCP-MIB::tcpConnRemPort.192.168.100.100.3306.192.168.100.100.59300 = INTEGER: 59300
TCP-MIB::tcpConnRemPort.192.168.100.100.3306.192.168.100.100.59301 = INTEGER: 59301
TCP连接状态(ipv4和ipv6地址):
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnectionState
TCP-MIB::tcpConnectionState.ipv4."192.168.100.100".22.ipv4."192.168.2.171".50461 = INTEGER: established(5)
TCP-MIB::tcpConnectionState.ipv6."00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:64:07".8082.ipv6."00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:02:9e".5890 = INTEGER: timeWait(11)
TCP连接状态,IPV4地址:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnectionState.ipv4
TCP-MIB::tcpConnectionState.ipv4."192.168.100.100".22.ipv4."192.168.2.171".50461 = INTEGER: established(5)
TCP-MIB::tcpConnectionState.ipv4."192.168.100.100".3306.ipv4."192.168.100.100".59299 = INTEGER: established(5)
TCP-MIB::tcpConnectionState.ipv4."192.168.100.100".3306.ipv4."192.168.100.100".59300 = INTEGER: established(5)
TCP-MIB::tcpConnectionState.ipv4."192.168.100.100".3306.ipv4."192.168.100.100".59301 = INTEGER: established(5)
TCP连接进程:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpConnectionProcess.ipv4
TCP-MIB::tcpConnectionProcess.ipv4."192.168.100.100".22.ipv4."192.168.2.171".50461 = Gauge32: 0
TCP-MIB::tcpConnectionProcess.ipv4."192.168.100.100".3306.ipv4."192.168.100.100".59299 = Gauge32: 0
TCP-MIB::tcpConnectionProcess.ipv4."192.168.100.100".3306.ipv4."192.168.100.100".59300 = Gauge32: 0
TCP-MIB::tcpConnectionProcess.ipv4."192.168.100.100".3306.ipv4."192.168.100.100".59301 = Gauge32: 0
tcp监听进程:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 tcpListenerProcess
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".21 = Gauge32: 0
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".22 = Gauge32: 0
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".8000 = Gauge32: 0
TCP-MIB::tcpListenerProcess.ipv4."192.168.100.100".3306 = Gauge32: 0
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00".22 = Gauge32: 0
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00".8000 = Gauge32: 0
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00".8082 = Gauge32: 0
UDP地址:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 udpLocalAddress
UDP-MIB::udpLocalAddress.0.0.0.0.51598 = IpAddress: 0.0.0.0
UDP-MIB::udpLocalAddress.192.168.100.100.161 = IpAddress: 192.168.100.100
UDP端口:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 udpLocalPort
UDP-MIB::udpLocalPort.0.0.0.0.51598 = INTEGER: 51598
UDP-MIB::udpLocalPort.192.168.100.100.161 = INTEGER: 161
系统启动时间:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSystemUptime.0
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (17454578) 2 days, 0:29:05.78
系统日期:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSystemDate.0
HOST-RESOURCES-MIB::hrSystemDate.0 = STRING: 2013-9-2,15:23:24.0,+8:0
系统启动参数:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSystemInitialLoadParam
HOST-RESOURCES-MIB::hrSystemInitialLoadParam
"
登陆系统用户数:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSystemNumUsers.0
HOST-RESOURCES-MIB::hrSystemNumUsers.0 = Gauge32: 1
系统进程数:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSystemProcesses.0
HOST-RESOURCES-MIB::hrSystemProcesses.0 = Gauge32: 70
系统最大进程数(可能有问题,只获取到0了):
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSystemMaxProcesses.0
HOST-RESOURCES-MIB::hrSystemMaxProcesses.0 = INTEGER: 0
系统内存数:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrMemorySize.0
HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 2050228 KBytes
系统资源描述:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrStorageDescr
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Memory buffers
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: Cached memory
HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: Shared memory
获取系统设备信息(CPU):
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrDeviceDescr
HOST-RESOURCES-MIB::hrDeviceDescr.768 = STRING: GenuineIntel: Pentium(R) Dual-Core
HOST-RESOURCES-MIB::hrDeviceDescr.769 = STRING: GenuineIntel: Pentium(R) Dual-Core
HOST-RESOURCES-MIB::hrDeviceDescr.1025 = STRING: network interface lo
HOST-RESOURCES-MIB::hrDeviceDescr.1026 = STRING: network interface eth0
HOST-RESOURCES-MIB::hrDeviceDescr.3072 = STRING: Guessing that there's a floating point co-processor
系统进程列表:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSWRunName
HOST-RESOURCES-MIB::hrSWRunName.1 = STRING: "init"
HOST-RESOURCES-MIB::hrSWRunName.2 = STRING: "kthreadd"
HOST-RESOURCES-MIB::hrSWRunName.3 = STRING: "ksoftirqd/0"
HOST-RESOURCES-MIB::hrSWRunName.5 = STRING: "kworker/u:0"
HOST-RESOURCES-MIB::hrSWRunName.6 = STRING: "migration/0"
HOST-RESOURCES-MIB::hrSWRunName.7 = STRING: "watchdog/0"
HOST-RESOURCES-MIB::hrSWRunName.8 = STRING: "migration/1"
HOST-RESOURCES-MIB::hrSWRunName.10 = STRING: "ksoftirqd/1"
HOST-RESOURCES-MIB::hrSWRunName.11 = STRING: "kworker/0:1"
获取进程执行路径:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSWRunPath
HOST-RESOURCES-MIB::hrSWRunPath.1 = STRING: "/sbin/init"
HOST-RESOURCES-MIB::hrSWRunPath.2 = STRING: "kthreadd"
HOST-RESOURCES-MIB::hrSWRunPath.3 = STRING: "ksoftirqd/0"
HOST-RESOURCES-MIB::hrSWRunPath.5 = STRING: "kworker/u:0"
HOST-RESOURCES-MIB::hrSWRunPath.6 = STRING: "migration/0"
HOST-RESOURCES-MIB::hrSWRunPath.7 = STRING: "watchdog/0"
获取进程运行参数:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSWRunParameters
HOST-RESOURCES-MIB::hrSWRunParameters.982 = STRING: "-8 38400 tty1"
HOST-RESOURCES-MIB::hrSWRunParameters.1687 = ""
HOST-RESOURCES-MIB::hrSWRunParameters.1953 = STRING: "/root/optools/game.py"
HOST-RESOURCES-MIB::hrSWRunParameters.2797 = ""
HOST-RESOURCES-MIB::hrSWRunParameters.3183 = STRING: "-server -Xms512m -Xmx512m -XX:MaxPermSize=256m -cp /usr/local/mobileGame/conf:/usr/local/mobileGame/bin/mobileGame.jar com.joywa"
HOST-RESOURCES-MIB::hrSWRunParameters.3947 = STRING: "-D"
HOST-RESOURCES-MIB::hrSWRunParameters.4135 = ""
HOST-RESOURCES-MIB::hrSWRunParameters.4267 = ""
HOST-RESOURCES-MIB::hrSWRunParameters.4368 = STRING: "-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid"
进程执行CPU占用
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSWRunPerfCPU
HOST-RESOURCES-MIB::hrSWRunPerfCPU.1 = INTEGER: 71
HOST-RESOURCES-MIB::hrSWRunPerfCPU.2 = INTEGER: 0
HOST-RESOURCES-MIB::hrSWRunPerfCPU.3 = INTEGER: 116
HOST-RESOURCES-MIB::hrSWRunPerfCPU.5 = INTEGER: 54
HOST-RESOURCES-MIB::hrSWRunPerfCPU.6 = INTEGER: 0
HOST-RESOURCES-MIB::hrSWRunPerfCPU.7 = INTEGER: 32
HOST-RESOURCES-MIB::hrSWRunPerfCPU.8 = INTEGER: 0
HOST-RESOURCES-MIB::hrSWRunPerfCPU.10 = INTEGER: 87
进程执行内存占用:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 hrSWRunPerfMem
HOST-RESOURCES-MIB::hrSWRunPerfMem.1 = INTEGER: 2280 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.2 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.3 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.5 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.6 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.7 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.8 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.10 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.11 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.12 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.13 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.14 = INTEGER: 0 KBytes
CPU 1、5、15分钟负载:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 .1.3.6.1.4.1.2021.10.1.3.1
UCD-SNMP-MIB::laLoad.1 = STRING: 0.09
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100.1.3.6.1.4.1.2021.10.1.3
UCD-SNMP-MIB::laLoad.1 = STRING: 0.08
UCD-SNMP-MIB::laLoad.2 = STRING: 0.12
UCD-SNMP-MIB::laLoad.3 = STRING: 0.11
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100 laLoad
UCD-SNMP-MIB::laLoad.1 = STRING: 0.14
UCD-SNMP-MIB::laLoad.2 = STRING: 0.13
UCD-SNMP-MIB::laLoad.3 = STRING: 0.11
内存:
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 2050228 kB
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 1071036 kB
hartnett@awakenjoys:~$ snmpwalk -v 2c -c public 192.168.100.100
UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 5261240 kB
Memory Statistics
• Total Swap Size: .1.3.6.1.4.1.2021.4.3.0
• Available Swap Space: .1.3.6.1.4.1.2021.4.4.0
• Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0
• Total RAM used: .1.3.6.1.4.1.2021.4.6.0
• Total RAM Free: .1.3.6.1.4.1.2021.4.11.0
• Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
• Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
• Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0