SNMP 是应用在 IP 网络管理网络节点(服务器、OLT、路由器、交换机等)的一种标准协议,属于应用层协议,通过 SNMP 可以获得设备的主要运行参数信息,帮助管理员解决出现的问题,我用到的开发工具包括C#、JavaScript、Echarts等。

本次介绍如何监控OLT设备的主要工作参数指标,包括上行口状态、板卡cpu利用率、内存利用率和温度等,其他需要监控的指标自己可以摸索。

OLT设备的oid信息由于保密的需要做了隐藏
public string zxAnOltsysName = "1.3.6.1.2.1.1.5.0";  //C320设备名称
public string zxAnOltsysDescr = "1.3.6.1.2.1.1.1.0";  //C320设备描述
public string zxAnOltGei1Status = "1.3.6.1.2.1.2.2.*";   //C320上行口
public string zxAnCardOperStatus = "1.3.6.1.4.1.3902.*";//块卡状态
public string zxAnCardCpuLoad = "1.3.6.1.4.1.3902.*";//板卡cpu利用率
public string zxAnCardMemUsage = "1.3.6.1.4.1.3902.*";//内存利用率
public string zxAnOltTemperature = "1.3.6.1.4.1.3902.*"; //温度
public string zxAnOltOnuAddress = "1.3.6.1.4.1.3902.*"; //带的ONUmac

根据oid调用getOIDValue()函数获得对应的参数值。

 public Dictionary<string, string> getOIDValue(string host, string singleoid, string mcmtsCommunity){Dictionary<string, string> dic = new Dictionary<string, string>();try{OctetString community = new OctetString(mcmtsCommunity);AgentParameters param = new AgentParameters(community);param.Version = SnmpVersion.Ver2;IpAddress agent = new IpAddress(host);UdpTarget target = new UdpTarget((IPAddress)agent, 161, 1000, 1);Pdu pdu = new Pdu(PduType.Get);if (!singleoid.Contains("SNMP No-Such-Instance")){pdu.VbList.Add(singleoid);SnmpV2Packet result = (SnmpV2Packet)target.Request(pdu, param);// If result is null then agent didn't reply or we couldn't parse the reply.   if (result != null){// ErrorStatus other then 0 is an error returned by    // the Agent - see SnmpConstants for error definitions   if (result.Pdu.ErrorStatus == 0){for (int i = 0; i < result.Pdu.VbList.Count; i++){dic.Add(result.Pdu.VbList[i].Oid.ToString(), result.Pdu.VbList[i].Value.ToString());}}}target.Close();}else{dic = null;}}catch (Exception e){dic = null;}return dic;}
 public Dictionary<string, string> getWalkValueV2(string host, string irootOid, string mcmtsCommunity){Dictionary<string, string> dic = new Dictionary<string, string>();try{OctetString community = new OctetString(mcmtsCommunity);AgentParameters param = new AgentParameters(community);param.Version = SnmpVersion.Ver2;IpAddress agent = new IpAddress(host);UdpTarget target = new UdpTarget((IPAddress)agent, 161, 1000, 1);// Define Oid that is the root of the MIB//  tree you wish to retrieveOid rootOid = new Oid(irootOid); // ifDescrOid lastOid = (Oid)rootOid.Clone();Pdu pdu = new Pdu(PduType.GetBulk);pdu.NonRepeaters = 0;pdu.MaxRepetitions = 5;while (lastOid != null){if (pdu.RequestId != 0){pdu.RequestId += 1;}// Clear Oids from the Pdu class.pdu.VbList.Clear();// Initialize request PDU with the last retrieved Oidpdu.VbList.Add(lastOid);// Make SNMP requestSnmpV2Packet result = (SnmpV2Packet)target.Request(pdu, param);// You should catch exceptions in the Request if using in real application.// If result is null then agent didn't reply or we couldn't parse the reply.if (result != null){// ErrorStatus other then 0 is an error returned by // the Agent - see SnmpConstants for error definitionsif (result.Pdu.ErrorStatus != 0){// agent reported an error with the requestConsole.WriteLine("Error in SNMP reply. Error {0} index {1}",result.Pdu.ErrorStatus,result.Pdu.ErrorIndex);lastOid = null;break;}else{// Walk through returned variable bindingsforeach (Vb v in result.Pdu.VbList){// Check that retrieved Oid is "child" of the root OIDif (rootOid.IsRootOf(v.Oid)){//Console.WriteLine("{0} ({1}): {2}",v.Oid.ToString(),SnmpConstants.GetTypeName(v.Value.Type),v.Value.ToString());dic.Add(v.Oid.ToString(), v.Value.ToString());if (v.Value.Type == SnmpConstants.SMI_ENDOFMIBVIEW)lastOid = null;elselastOid = v.Oid;}else{// we have reached the end of the requested// MIB tree. Set lastOid to null and exit looplastOid = null;}}}}else{Console.WriteLine("No response received from SNMP agent.");}}target.Close();}catch (Exception e){dic = null;}return dic;}

把获得的参数值利用页面进行展示,如果发现指标异常,通过微信平台进行相应的报警,让维修人员尽快处理(由于时间关系,下一步在写相关的内容)

效果图

基于SNMP在网络监控中的应用1_OLT设备的监控相关推荐

  1. 基于SNMP的网络拓扑结构自动发现研究

    摘  要: 分析了简单网络管理协议(SNMP).网络管理模型以及地址解析协议(ARP),在此基础上提出了一种网络拓扑结构的自动发现方法. 关键词: 网络管理  SNMP  拓扑发现 国际标准化组织提出 ...

  2. 基于WFP等网络驱动实现局域网内所有设备通过代理上网

    by fanxiushu 2020-10-13 转载或引用请注明原始作者 开始之前,我们先来理解标题是什么意思. 这里所说的局域网内的所有设备通过代理上网,并不是在每台设备上安装某个代理软件然后再通过 ...

  3. ESD静电监控看板对工厂防静电设备实时监控和管理

    在工业信息化的促进下,工业正在朝着数字化.智能化.网络写综合集成化的方向发展,制造业的工厂不断朝着高度一体化.集成化的进度的进程前行.如果说这些设备损坏了的话,找不到原因,维修起来是非常麻烦的一件事. ...

  4. 查询公司资产数据库中的主机是否在zabbix的监控中

    由于需要知道公司资产中的相关服务器是否在zabbix的监控中,有些是不需要监控的,有些是资产更新之后zabbix没有监控的,要是一个个的去对比,比较麻烦,闲来无事,写了一个脚本,对比资产中的机器是否需 ...

  5. SNMP实现网络状态监控

    SNMP实现网络状态监控 每当我们遇到设备出现故障或需要进行管理时,我们总要去单独进入到该设备中去进行操作检测,这样既浪费时间又觉得工作量大,snmp协议可以帮我们解决这个问题,在众多的设备和服务器等 ...

  6. 基于prometheus的网络指标监控

    1 网络指标监控 网络设备(交换机.路由器.防火墙)本身并没有太多的监控方式,常规的是使用snmp,通过oid去采集网络设备的指标,例如,流量或者错包,不过近年来也出现了新的采集方式,例如,telem ...

  7. 如何建立网络监控中的网络性能基线?

    网络性能基线是网络性能监控中用来定义企业网络基础架构正常工作条件的一个衡量标准.工程师可以使用网络性能基线和网络监控进行比较,从而发现可能导致问题的流量变化.一个网络性能的好坏,直接影响到用户的体验和 ...

  8. 基于SNMP网络管理系统的实现 1

    个推作为国内最专业的第三方消息推送技术解决方案的服务商接入SDK用户数高达90亿,日活跃用户达6.5亿.日分发消息23亿.在实际的运维环境中,需要时刻对网络设备进行监控和管理,并包含了各种网络设备,包 ...

  9. python openstack vpc互通_深入浅出新一代云网络——VPC中的那些功能与基于OpenStack Neutron的实现(二)-带宽控制...

    在VPC功能实现第一篇中,简单介绍了一下VPC网络对租户间隔离能力的提升以及基于路由提供的一系列网络功能.在这一篇中,将继续介绍VPC网络中十分重要的一个内容:网络带宽的控制,共享以及分离. 首先是对 ...

最新文章

  1. 机器学习的大局:用神经网络和TensorFlow分类文本
  2. mysql 只允许本地登陆 centos,Centos中MySQL设置密码跟不允许匿名登陆
  3. Java性能优化推荐书!RocketMQ消息丢失场景及解决办法
  4. python3菜鸟教程中文-Python3 日期和时间
  5. CrowdRec:众包环境中,基于信任感知的工人推荐
  6. 计算机网络是如何通信的「三」
  7. 【数据结构与算法】之深入解析“罗马数字转整数”的求解思路与算法示例
  8. 基于nginx-rtmp-module模块实现的HTTP-FLV直播模块(nginx-http-flv-module)
  9. tableau 集动作_在Tableau中通过添加操作,控制集并高亮显示数据
  10. Python nonlocal 与 global 关键字解析
  11. Linux网络子系统中旧的报文接收接口netif_rx
  12. 提取source引擎.mdl模型,并转unity引擎.fbx
  13. 安科瑞DTSD/ADL400通讯协议说明-Susie 周
  14. [feather]StarlingUi框架——初识feather、界面启动及Ui加载
  15. Android 双卡双待支持检验SIM信息获取
  16. 在 stm32CubeMX下生成程序完成流水灯以及完成STM32的USART串口通讯程序实现STM32系统给上位机(win10)连续发送“hello windows”
  17. 中文分词算法之--最大匹配法
  18. 走到最后,摩拜连姓名都不能拥有?
  19. 【PCB专题】光绘(Gerber)文件的理解
  20. 机器视觉之图像预处理

热门文章

  1. 基于MFC实现电脑录屏小程序
  2. 转载linux图形界面编程基本知识(X11, xorg, gdm/gnome)
  3. 【读书笔记】《平凡的世界》- 路遥
  4. 自助云打印服务,路边打字复印店的终结者?V印产品体验
  5. 为了跳槽强刷1000道Android真题,面试资料分享
  6. 行测-判断推理-图形推理-位置规律-平移
  7. 飞桨领航团表彰来了!
  8. CCRC信息安全服务资质认证给企业带来的好处
  9. Keil uVision5新建工程模板
  10. C# 透明窗体,上面的label文字毛边怎么去掉,透明窗体字体有毛边的问题 处理办法,设置相近色