第六十五章 使用 SNMP 监控 IRIS - 用户定义的 SNMP 监视器类示例

简介: 第六十五章 使用 SNMP 监控 IRIS - 用户定义的 SNMP 监视器类示例

第六十五章 使用 SNMP 监控 IRIS - 用户定义的 SNMP 监视器类示例

本节介绍如何定义可通过 SNMP 查询的用户应用程序监视器类的示例。应用程序监视器仅包括 SNMP 数据中具有 %Monitor 数据类型的属性。

Example Sample Class

以下是此示例的示例类:

Class SNMP.Example Extends %Monitor.Adaptor
{

  /// Give the application a name. This allows you to group different 
  /// classes together under the same application level in the SNMP MIB.
  /// The default is the same as the Package name.
  Parameter APPLICATION = "MyApp";

  /// This groups a set of properties together at the "table" level of the
  /// SNMP MIB hierarchy. The default is the Class name.
  Parameter GROUPNAME = "MyTable";

  /// An integer metric counter
  Property Counter1 As %Monitor.Integer;

  /// Another integer metric counter
  Property Counter2 As %Monitor.Integer;

  /// A status indicator as a string data type
  Property Status As %Monitor.String;

  /// The method is REQUIRED. It is where the Application Monitor
  /// calls to collect data samples, which then get picked up by the
  /// ^SNMP server process when requested.
  Method GetSample() As %Status
  {
    set ..Counter1=$r(200)
    set ..Counter2=200+$r(100)
    set n=$r(4)
    set ..Status=$s(n=1:"Crashed",n=2:"Warning",n=3:"Error",1:"Normal")
    Quit $$$OK
  }

}

在用户命名空间中编译此类之前, IRIS 必须将支持类加载到命名空间中;需要这些类来存储 SNMP 的数据样本。

要加载这些类,请运行 ^%SYSMONMGR,如本指南“使用系统监视器”一章中使用 ^%SYSMONMGR 管理应用程序监视器中所述,并执行以下操作:

  • 选择选项 2,管理监视器类。
  • 选择选项 3Register Monitor System Classes

编译示例类时,它会创建 SNMP.Sample.Example 类来存储示例数据。

重要提示:不要明确删除生成的示例类;如果同时选择删除应用监控和生成的示例类,虽然删除了监控类例程,但示例类例程仍然存在,这会导致错误。为确保正确删除所有示例类例程,只删除生成它的应用程序监视器类;当您删除监视器类时,监视器类和生成的示例类以及这两个类的相关例程都会被删除。例如,要删除示例类(例如 SNMP.Sample.Example),请使用管理门户删除生成它的监视器类(即 SNMP.Example)。

运行 ^%SYSMONMGR 以激活示例类并启动应用程序监视器以收集示例:

  1. 选择选项 2,管理监视器类。
  2. 选择选项 1,激活/停用监视器类。
  3. 要查看已注册监视器类的编号列表,请输入 ?
  4. 输入要激活的监控类的数量;例如,要激活名为 SNMP.Example 的用户定义类,请在类名旁边输入数字。
  5. 选择选项 6,Exit(返回到 Application Monitor 主菜单)。
  6. 选择选项 1,管理应用程序监视器。
  7. 选择选项 1,启动应用程序监视器。
  8. 选择选项 5,Exit(返回到 Application Monitor 主菜单)。
  1. 选择选项 6,Exit(退出 Application Monitor 主菜单)。

注意:有关配置和使用应用程序监视器的信息,请参阅本指南“使用系统监视器”一章中的应用程序监视器。

Example of Creating a User MIB

要创建 SNMP MIB,请从 %SYS 命名空间运行 MonitorTools.SNMP:CreateMIB 方法

该方法的输入参数类似于以下内容:

CreateMIB("MyApp","USER",99990,1,"mycorp","myapp","mc","MC-MYAPP","Unknown",1)

重要提示:请勿使用 99990 作为生产企业 ID;每个组织都应向 IANA 注册自己的 ID

USER>set $namespace = "%SYS"
 
%SYS>Do ##class(MonitorTools.SNMP).CreateMIB("MyApp","USER",99990,1,"mycorp",
"myapp","mc","MC-MYAPP","Unknown",1)
 
 
Create SNMP structure for Application - MyApp
 
     Group - MyTable
          Counter1 = Integer
          Counter2 = Integer
          Status = String
 
 
Create MIB file for MyApp
 
     Generate table MyTable
          Add object Counter1
          Add object Counter2
          Add object Status
 
 
%SYS>

这会在默认目录 (install-dir\mgr\User) 中创建 MC-MYAPP.MIB 文件,可以将其加载到 SNMP 管理应用程序中。

注意:可能需要在系统上重新启动 SNMP 主代理和 IRIS ^SNMP 服务,然后才能识别此 MIB

--
-- MIB file generated for mcMyApp product.
--
-- Sep 16, 2008
--

MC-MYAPP DEFINITIONS ::= BEGIN

IMPORTS

  MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE,
  Counter32, Gauge32, Integer32
  FROM SNMPv2-SMI
  DisplayString
  FROM SNMPv2-TC
  enterprises
  FROM RFC1155-SMI
  cacheSysIndex
  FROM ISC-IRIS;


mcMyApp MODULE-IDENTITY
    LAST-UPDATED "200809161700Z"
    ORGANIZATION "mycorp"
    CONTACT-INFO "
                    Unknown"
    DESCRIPTION ""
    ::= { mycorp 1 }

mycorp OBJECT IDENTIFIER ::= { enterprises 16563 }

myappObjects OBJECT IDENTIFIER ::= { mcMyApp 1 }

--
-- Begin tables
--

-- Table myappMyTable

myappMyTable         OBJECT-TYPE
       SYNTAX        SEQUENCE OF myappMyTableR
       MAX-ACCESS    not-accessible
       STATUS        current
       DESCRIPTION
       ""
   ::= { myappObjects 1 }

myappMyTableR        OBJECT-TYPE
       SYNTAX        myappMyTableR
       MAX-ACCESS    not-accessible
       STATUS        current
       DESCRIPTION
       "Conceptual row for MyTable table."
       INDEX  { cacheSysIndex }
   ::= { myappMyTable 1 }

myappMyTableR ::=
       SEQUENCE {
        myappCounter1   Integer32
        myappCounter2   Integer32
        myappStatus   DisplayString
       }

myappCounter1        OBJECT-TYPE
       SYNTAX        Integer32
       MAX-ACCESS    read-only
       STATUS        current
       DESCRIPTION
       ""
       ::= { myappMyTableR 1 }

myappCounter2        OBJECT-TYPE
       SYNTAX        Integer32
       MAX-ACCESS    read-only
       STATUS        current
       DESCRIPTION
       ""
       ::= { myappMyTableR 2 }

myappStatus          OBJECT-TYPE
       SYNTAX        DisplayString
       MAX-ACCESS    read-only
       STATUS        current
       DESCRIPTION
       "Status"
       ::= { myappMyTableR 3 }

--  End of MyTable table

myappTraps  OBJECT IDENTIFIER ::= { mcMyApp 2 }

-------------------------------------------------------------
 END

相关文章
|
30天前
|
监控 程序员 数据库
第六十四章 使用 SNMP 监控 IRIS - 扩展 IRIS MIB
第六十四章 使用 SNMP 监控 IRIS - 扩展 IRIS MIB
25 0
|
30天前
|
监控 网络协议 Unix
第六十三章 使用 SNMP 监控 IRIS - SNMP 故障排除
第六十三章 使用 SNMP 监控 IRIS - SNMP 故障排除
22 0
|
30天前
|
监控 网络协议 安全
第六十二章 使用 SNMP 监控 IRIS
第六十二章 使用 SNMP 监控 IRIS
23 0
|
11月前
|
监控 网络架构
Zabbix的snmp监控
Zabbix的snmp监控
83 0
|
10月前
|
运维 监控 数据安全/隐私保护
【运维知识进阶篇】zabbix5.0稳定版详解5(SNMP网络管理协议监控)
【运维知识进阶篇】zabbix5.0稳定版详解5(SNMP网络管理协议监控)
212 0
|
监控 数据安全/隐私保护 网络架构
【Zabbix】Zabbix基于SNMP监控配置
【Zabbix】Zabbix基于SNMP监控配置
470 0
|
存储 消息中间件 Prometheus
统一观测丨使用 Prometheus 监控 SNMP,我们该关注哪些指标?
统一观测丨使用 Prometheus 监控 SNMP,我们该关注哪些指标?
统一观测丨使用 Prometheus 监控 SNMP,我们该关注哪些指标?
|
存储 监控 Linux
zabbix使用snmp监控Linux主机(二十)
使用snmp监控Linux主机 1.snmp协议介绍 SNMP(简单网络管理协议)也是应用层的一种协议,默认端口号为161,我们平时监控Linux主机都是安装一个agent客户端进行监控,但是有的公司还需要监控网络设备和Windows主机,这时就不得不采用snmp协议去监控设备了
634 0
zabbix使用snmp监控Linux主机(二十)
|
存储 监控 安全
Zabbix SNMP监控安装、配置与服务器实例(学习笔记六)
SNMP可以监控路由器、打印机、UPS、摄像头、服务器等。 1、安装、配置snmp  yum install net-snmp* -y # vim /etc/snmp/snmpd.
2567 0
QGS
|
监控 安全 开发者
zabbix5.0.8-SNMP协议监控Windows10-PC
记zabbix5.0.8-SNMP协议监控Windows10-PC
QGS
189 0
zabbix5.0.8-SNMP协议监控Windows10-PC