SNMP NOTE

SNMP是基于TCP/IP协议族的网络管理标准,它的前身是简单网关监控协议(SGMP),用来对通信线路进行管理。随后,人们对SGMP进行了很大的修改,特别是加入了符合Internet定义的SMI和MIB:体系结构,改进后的协议就是著名的SNMP。SNMP的目标是管理互联网Internet上众多厂家生产的软硬件平台,因此SNMP受Internet标准网络管理框架的影响也很大。现在SNMP已经出到第三个版本的协议,其功能较以前已经大大地加强和改进了。

SNMP简单网络管理协议   RRRDTool   cacti    nagios               基于DUP 协议
 linux 中的snmp的软件包
 net-snmp    -->agent       net-snmp-utils  -->NMS:command
  配置文件  /etc/snmpd/snmpd.conf      /etc/sysconfig/snmp*   修改配置文件  控制监控的对象
  修改  community
  windows  安装snmp方法    在控制面板中的程序里 添加组件里 选中snmp协议
  监控的实现   可以通过  snmp sommand(探测)  remote script(远程服务器执行脚本)
  rrdtool ---》绘图工具
  cacti---》 php网站  展示程序   时间序列数据       
  nagios  ---》非时间序列   监控简单的有限的状态    状态转换     状态监控工具   
  SNMP   Ssimple Network Management  Protocol
  NMS  ->network management station   UDP:162  for trapp  <------>agent UDP:161            community 社团 属于同一个社团认证   read-only   read-write  trap    notify  通知
  MIB -II  management information base     informantion      MIB库     文件位置    /usr/share/snmp/mibs
  fault man   故障
  configuration man  配置管理
  accounting man    记账管理
  performance man    性能管理
  security man    安全管理
  
   SNMP   默认启动两个community  一个public  一个 private
    operations
      get
      getnext
      getbulk
      set
      getresponse  
 snmpwalk -v 2c -c public localhost host 检测是否可以正常获得返回的数据

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)
解决方法
1.在/etc/snmp/snmpd.conf配置文件里面,查找以下字段:
## incl/excl subtree mask
#view all included .1 80
将该行前面的"#"去掉
2.在/etc/snmp/snmpd.conf文件中查找并修改粗体部分内容
access   notConfigGroup ""       any       noauth     exact   systemview none none
改成
access   notConfigGroup ""       any       noauth     exact   all     none none
3.重启snmpd服务解决
[root@squid-2 html]service snmpd restart
三.SNMP的使用,利用这个和crontab定时器,可以实现定时对指定机器的性能监控
假设community为public
#snmpwalk -v 2c -c public localhost [OID]
Linux下一些常用的OID
CPU的
Load
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3
CPU
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0
-------------------------------------------------------------------------------
内存的
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
-------------------------------------------------------------------
硬盘的
Path where the disk is mounted: .1.3.6.1.4.1.2021.9.1.2.1
Path of the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1
Total size of the disk/partion (kBytes): .1.3.6.1.4.1.2021.9.1.6.1
Available space on the disk: .1.3.6.1.4.1.2021.9.1.7.1
Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1
Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1
Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1
----------------------------------------------------------------
windows下常用的OID
CPU
.1.3.6.1.2.1.25.3.3.1.2
如果有一个双核cpu则有2个值,显示当前负载
---------------------------------------------------------------
内存,硬盘
内存跟硬盘都统一在mib2.host.hrStorage里 1.3.6.1.2.1.25.2
hrStorageType节点,hrStorageFixedDisk表示硬盘,hrStorageVirtualMemory是虚拟内存,hrStorageRam是内存
根据id号查:
hrStorageAllocationUnits是簇的大小
hrStorageSize是有多少簇,两者想乘就是总容量
hrStorageUsed是已使用多少,跟总容量相除就是占用率
---------------------------------------------------------------
系统运行时间
System Uptime: .1.3.6.1.2.1.1.3.0
注:linux系统的话也可直接用uptime命令获得
---------------------------------------------------------------
网络设备的
ifIndex         1.3.6.1.2.1.2.2.1.1.0        端口索引号
ifDescr        1.3.6.1.2.1.2.2.1.2.0        端口描述
ifType        1.3.6.1.2.1.2.2.1.3.0        端口类型
ifMtu        1.3.6.1.2.1.2.2.1.4.0         最大传输包字节数
ifSpeed        1.3.6.1.2.1.2.2.1.5.0         端口速度
ifPhysAddress        1.3.6.1.2.1.2.2.1.6.0        物理地址
ifOperStatus        1.3.6.1.2.1.2.2.1.8.0        操作状态
ifLastChange        1.3.6.1.2.1.2.2.1.9.0        上次状态更新时间
ifInOctets        1.3.6.1.2.1.2.2.1.10.0         输入字节数
ifInUcastPkts        1.3.6.1.2.1.2.2.1.11.0         输入非广播包数
ifInNUcastPkts        1.3.6.1.2.1.2.2.1.12.0         输入广播包数
ifInDiscards        1.3.6.1.2.1.2.2.1.13.0         输入包丢弃数
ifInErrors        1.3.6.1.2.1.2.2.1.14.0         输入包错误数
ifInUnknownProtos        1.3.6.1.2.1.2.2.1.15.0        输入未知协议包数
ifOutOctets        1.3.6.1.2.1.2.2.1.16.0         输出字节数
ifOutUcastPkts        1.3.6.1.2.1.2.2.1.17.0         输出非广播包数
ifOutNUcastPkts        1.3.6.1.2.1.2.2.1.18.0        输出广播包数
ifOutDiscards        1.3.6.1.2.1.2.2.1.19.0         输出包丢弃数
ifOutErrors         1.3.6.1.2.1.2.2.1.20.0         输出包错误数
ifOutQLen        1.3.6.1.2.1.2.2.1.21.0         输出队长


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值