システム間アイリスにカスタムSNMP OIDを作成する


この記事はSNMPを使ってAA IRISインスタンスを監視するタスクに捧げられます.アイリスの一部のユーザーは、おそらく何らかの方法でそれをすでにしています.SNMPを介しての監視は、標準的なIRISのパッケージによって長い間サポートされているが、すべての必要なパラメータは“箱の外に”利用可能です.たとえば、CSPセッションの数を監視し、ライセンスの使用に関する詳細な情報を取得し、使用するシステムの特定のKPIとそのようなものを取得するのが良いでしょう.この記事を読んだ後に、あなたはSNMPを使っている虹彩モニタリングにあなたのパラメタを加える方法を知っています.

我々が既に持っているもの


IRMPはSNMPを使用して監視することができます.サポートされているものの完全なリストは< installRange dir >/snmp/のファイルにあります.isc - irisというファイルを見つけます.そこのMIB.特に、ライセンスやセッションについてどのような情報が得られるか知りたいです.このテーブルは、システム間のルートから始まる階層に対応するOIDを含みます.
oid
名称
説明
データ型
4.1.1.1.10
使用する
このIrisインスタンスで使用される現在のライセンス数
整数
4.1.1.1.11
イリスシリンダーハイ
このアイリスインスタンスに使用されるライセンスのための高水マーク
整数
.4.2.15
ライセンス
ライセンスの要求は、利用可能なライセンスを超えています
トラップメッセージ
4.1.1.1.6
アイリスシュプール
このIrisインスタンスの現在のユーザ数
整数
パッケージは、例えば、CSPセッション、ライセンス情報の数、およびもちろん、特定のKPIのものを持っていません.
以下に私たちが知りたいことの例を示します.
  • CSPユーザ数
  • ユーザ数によるライセンスの制限
  • 許可満了日
  • パフォーマンス分析のためにいくつかのパラメータを加えましょう.パラメータ自体はパッケージにありますが、分あたりの増加を知りたいと思います.例えば:
  • 分あたりのグローバル参照数の増加
  • 分単位で実行するコマンド数.
  • 分あたりのルーチン呼び出しの数
  • 「あなたの」パラメータを加える方法


    あなたは、に依存することができますMonitoring InterSystems IRIS Using SNMP ドキュメント.
    IRIのテストインスタンス( IRIS )は2020.3.0.200.0 . comです.オペレーティングシステムは、Ubuntu 18.04.4 LTS ( Docker Image IntersystemsDC/IRIS Community : 2020.3.0.200.0 ZPMを使用しています.
    我々の議題はこちら
  • メトリックを収集するためのクラスを作成します.
  • IRISで新しいクラスを登録して、有効にしてください^^ sysmonmgrを使ってください.
  • ユーザMIBを作成するMonitorTools.SNMP クラスメソッド.私たちは一時的なペンとして99990を使用しますIANA その後.この手順は無料ですが、1週間または2週間かかるとの行に沿っていくつかの電子メール交換が必要です.
  • 接続されているIRISサブエージェントで監視サービスを開始します.
  • 我々はすべての我々の新しく作成されたOIDのアクセスがあることを確認するSnmpWalkを使用します.
  • 第三者監視システムに我々のOIDを加えてください.使いましょうZabbix , 例えば.zabbixドキュメントが利用可能ですhere . 監視が起きていることを確認しましょう.
  • システムのスタートアップリストにシステム名モニタの開始位置を追加します.
  • 今、ポイントでポイントしましょう.

    1 .メトリクスを収集するクラスを作成する


    Metaicsコレクションクラスは拡張されます.%Monitor.Adaptor . 端末では% sys名前空間に切り替えて隠しモニタをエクスポートします.サンプルクラス:
    %SYS>do $system.OBJ.Export("Monitor.Sample.cls","/tmp/Monitor_Sample.xml")
    Exporting to XML started on 10/16/2020 09:33:55
    Exporting class: Monitor.Sample
    Export finished successfully.
    
    テスト名前空間が我々の作業領域であると仮定しましょう.それに切り替えてモニタをインポートしましょう.サンプルクラス:
    TEST>do $system.OBJ.Load("/tmp/Monitor_Sample.xml", "ck")
    
    さて、我々は、“既に何を持っている”セクションで説明されている6メトリックの監視メカニズムの実装を説明するクラスを作成します.
    Class monitoring.snmp.Metrics 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 = "Monitoring";
    /// CSP sessions count
    Property Sessions As %Monitor.Integer;
    /// License user limit
    Property KeyLicenseUnits As %Monitor.Integer;
    /// License key expiration date
    Property KeyExpirationDate As %Monitor.String;
    /// Global references speed
    Property GloRefSpeed As %Monitor.Integer;
    /// Number of commands executed
    Property ExecutedSpeed As %Monitor.Integer;
    /// Number of routine loads/save
    Property RoutineLoadSpeed As %Monitor.Integer;
    /// 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 ..Sessions = ..getSessions()
          set ..KeyLicenseUnits = ..getKeyLicenseUnits()
          set ..KeyExpirationDate = ..getKeyExpirationDate()
    
          set perfList = ..getPerformance()
          set ..GloRefSpeed = $listget(perfList,1)
          set ..ExecutedSpeed = $listget(perfList,2)
          set ..RoutineLoadSpeed = $listget(perfList,3)
    
          quit $$$OK
    }
    /// Get CSP sessions count
    Method getSessions() As %Integer
    {
         // This method will only work if we don't use WebAddon:
        // quit $system.License.CSPUsers() 
        //
        // This will work even if  we use WebAddon:
        set csp = ""
        try {
            set cn = $NAMESPACE
            znspace "%SYS"
            set db = ##class(SYS.Stats.Dashboard).Sample()
            set csp = db.CSPSessions
            znspace cn
        } catch e {
            set csp = "0"
        }
        quit csp
    }
    /// Get license user's power
    Method getKeyLicenseUnits() As %Integer
    {
        quit $system.License.KeyLicenseUnits()
    }
    /// Get license expiration date in human-readable format
    Method getKeyExpirationDate() As %String
    {
        quit $zdate($system.License.KeyExpirationDate(),3)
    }
    /// Get performance metrics (gloref, rourines etc.)
    Method getPerformance(param As %String) As %Integer
    {
        set cn = $NAMESPACE
        znspace "%SYS"
        set m = ##class(SYS.Monitor.SystemSensors).%New()
        do m.GetSensors()
        znspace cn
        quit $listbuild(m.SensorReading("GlobalRefsPerMin"), 
                        m.SensorReading("RoutineCommandsPerMin"), 
                        m.SensorReading("RoutineLoadsPerMin"))
    }
    }
    
    getSampled ()メソッドが本当に必要なデータを取得することを確認してください.
    TEST>set metrics = ##class(monitoring.snmp.Metrics).%New()
    
    TEST>write metrics.GetSample()
    1
    TEST>zwrite metrics 
    [email protected]  ; <OREF>
    +----------------- general information ---------------
    |      oref value: 3
    |      class name: monitoring.snmp.Metrics
    | reference count: 2
    +----------------- attribute values ------------------
    |      ExecutedSpeed = 2653596
    |        GloRefSpeed = 35863
    |  KeyExpirationDate = "2021-10-30"
    |    KeyLicenseUnits = 5
    |   RoutineLoadSpeed = 38
    |           Sessions = 5
    +-----------------------------------------------------
    

    2 .新しいクラスをIRISで登録してアクティブにしましょう


    端末を開き、テスト名前空間に切り替えます.
    # iris session iris -U TEST
    TEST>do ^%SYSMONMGR
    1. Select item 5, Manage Application Monitor.
    
    2. Select item 2, Manage Monitor Classes.
    
    3. Select item 3, Register Monitor System Classes.
    Exporting to XML started on 10/16/2020 10:05:39
    Exporting class: Monitor.Sample
    Export finished successfully.
    
    Load started on 10/16/2020 10:05:39
    Loading file /usr/irissys/mgr/Temp/VonCEUzQ8gWgfQ.stream as xml
    Imported class: Monitor.Sample, using worker jobs
    Compiling class Monitor.Sample
    Compiling table Monitor.Sample
    Compiling routine Monitor.Sample.1
    Load finished successfully.
    
    4. Select item 1, Activate/Deactivate Monitor Class
    Class??
    Num MetricsClassName Activated
    1) %Monitor.System.AuditCount N
    …
    15) monitoring.snmp.Metrics N
    Class? 15 monitoring.snmp.Metrics
    Activate class? Yes => Yes
    
    5. Select item 7, Exit
    
    6. Select item 6, Exit
    
    7. Select item 1, Start/Stop System Monitor
    
    8. Select item 2, Stop System Monitor
    Stopping System Monitor… System Monitor not running!
    
    9. Select item 1, Start System Monitor
    Starting System Monitor… System Monitor started
    
    10. Select item 3, Exit
    
    11. Select item 4, View System Monitor State
    Component                     State
    System Monitor                     OK
    %SYS.Monitor.AppMonSensor          OK
    
    12. Select item 7, Exit
    

    3 .ユーザMIBを作成する


    ユーザMIBはMonitorTools.SNMP クラスメソッド.この例では、偽のペンを使用しましょうIANA その後.登録番号を見ることができますhere . 例えば、システム間のペンは16563です.
    16563
    InterSystems
    Robert Davis
    rdavis&intersystems.com
    
    私たちはMonitorTools.SNMP クラスとそのCreateMIB() MIBファイルを作成する方法.このメソッドは10引数をとります:
    引数の名前と型
    説明

    としてappname
    アプリケーション名
    メトリックのアプリケーションパラメータの値.SNMPメトリクスクラス
    文字列としての名前空間
    名前空間
    テスト
    整数値
    カンパニーペン
    99990(フィクション)
    整数として
    会社内のOIDアプリケーション
    42
    ストリングとしての会社
    会社名(大文字)
    フィクション
    文字列としてのプレフィックス
    すべてのSNMPオブジェクトのプレフィックス
    フィクション
    % stringとしてコンパイルする
    略称接頭辞
    有限会社
    MIBNAME %文字列
    MIBファイルの名前
    ISC - TEST
    文字列
    連絡先情報(住所)
    デフォルト値を残しましょう:地球、ロシア、どこかの森林の中で、サブジェクト:ISC -テスト.MIB
    リスト%
    verboseと等価です.MIBファイルのタスク進行状況を表示する
    1
    MIBファイルの作成です.
    %SYS>do ##class(MonitorTools.SNMP).CreateMIB("Monitoring","TEST",99990,42,"fiction","fict","fiction","ISC-TEST",,1)
    Create SNMP structure for Application - Monitoring
         Group - Metrics
              ExecutedSpeed = Integer
              GloRefSpeed = Integer
              KeyExpirationDate = String
              KeyLicenseUnits = Integer
              RoutineLoadSpeed = Integer
              Sessions = Integer
    
    Create MIB file for Monitoring
         Generate table Metrics
              Add object ExecutedSpeed, Type = Integer
              Add object GloRefSpeed, Type = Integer
              Add object KeyExpirationDate, Type = String
              Add object KeyLicenseUnits, Type = Integer
              Add object RoutineLoadSpeed, Type = Integer
              Add object Sessions, Type = Integer
    MIB done.
    
    新しいMIB ISCテストがあります.現在の< sys/dir >/mgr/testフォルダのMIBです.

    4 .接続されているIRISサブエージェントで監視サービスを開始する


    システム管理を開きましょう:> security -> service - monitor monitor ( click )-> service enable ( check )


    また、IRIが起動されたときにSNMPサブエージェントを起動したいことを指定します.

    LinuxではSNMP監視用のNet SNMPパッケージを使用します.それで、我々はそれをインストールして、サブエージェントと共に使用されるのを構成して、サブエージェントと話すマスターエージェントのためのデフォルトの1としてポート705を指定します.
    SNMPDについての小さい記事.confファイルを補完する設定ファイルmanual が見つかるcyberciti . 設定の最終セットです.
    # apt-get update
    # apt-get install -y snmpd snmp
    # grep '^[^#]' /etc/snmp/snmpd.conf
    master agentx
    agentXSocket TCP:localhost:705
    com2sec local localhost public
    group MyRWGroup v1 local
    group MyRWGroup v2c local
    group MyRWGroup usm local
    view all included .1 80
    view system included .iso.org.dod
    access MyROGroup "" any noauth exact all none none
    access MyRWGroup "" any noauth exact all all none
    syslocation server (edit /etc/snmp/snmpd.conf)
    syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
    dontLogTCPWrappersConnects yes
    
    Linuxでsnmpdとsnmptrapdデーモンを再起動しましょう.その後、SNMPサービスを起動してSNMP IRISサブエージェントをアクティブにします.
    %SYS>do start^SNMP
    
    %SYS>; Check SNMP subagent status
    
    %SYS>zwrite ^SYS("MONITOR")
    ^SYS("MONITOR","SNMP")="RUN"
    ^SYS("MONITOR","SNMP","NAMESPACE")="%SYS"
    ^SYS("MONITOR","SNMP","PID")=2035
    ^SYS("MONITOR","SNMP","PORT")=705
    ^SYS("MONITOR","SNMP","STARTUP")="SNMP agent started on port 705, timeout=20, winflag=0, Debug=0"
    ^SYS("MONITOR","SNMP","STATE")="Terminated - 10/16/2020 10:40:31.7147AM"
    ^SYS("MONITOR","SNMP","WINSTART")=0
    

    5 .我々自身、新しく作成されたユーザOIDのものだけが利用できるのをチェックしてください


    これはSNMPWalkを使って行うことができます.
    # snmpwalk -On -v 2c -c public localhost 1.3.6.1.4.1.99990
    .1.3.6.1.4.1.99990.42.1.1.1.1.4.73.82.73.83 = INTEGER: 1928761
    .1.3.6.1.4.1.99990.42.1.1.1.2.4.73.82.73.83 = INTEGER: 226351
    .1.3.6.1.4.1.99990.42.1.1.1.3.4.73.82.73.83 = STRING: "2021-10-30"
    .1.3.6.1.4.1.99990.42.1.1.1.4.4.73.82.73.83 = INTEGER: 5
    .1.3.6.1.4.1.99990.42.1.1.1.5.4.73.82.73.83 = INTEGER: 306
    .1.3.6.1.4.1.99990.42.1.1.1.6.4.73.82.73.83 = INTEGER: 2
    
    # If you get such result
    # .1.3.6.1.4.1.99990 = No Such Object available on this agent at this OID
    # try to restart SNMP subagent in IRIS in this way:
    # do stop^SNMP
    # do start^SNMP
    
    ISC‐TESTMIBファイルには、OIDのシーケンスが含まれます.
    FictMetricsR ::=
           SEQUENCE {
            fictExecutedSpeed   Integer32,
            fictGloRefSpeed   Integer32,
            fictKeyExpirationDate   DisplayString,
            fictKeyLicenseUnits   Integer32,
            fictRoutineLoadSpeed   Integer32,
            fictSessions   Integer32
           }
    
    したがって、例えば、セッションの数は、最後のOID 1.3.6.1.4.1.99990.42.1.1.1.6です.SMPダッシュボードに表示されるセッションの数と比較できます.

    外部監視システムにOIDを追加しましょう


    使いましょうZabbix . zabbixドキュメントが見つかります.here . ZABBIX用の詳細なLinuxインストールと設定ガイドが利用可能ですhere . Zabbixは、グラフを描くことができるだけでなく、プレーンテキスト(私たちのケースでは、ライセンスの有効期限とライセンスユニット)を監視することができますシステムとして選択されました.我々のローカルホストに我々の6つのメトリックを加えた後items ( type : SNMPv 2エージェント)graphs と平文のパラメータscreen )次の写真を見てください.

    上記はライセンス満了と利用可能なナンバースロットの数に関する情報です.グラフは自分で話す.

    7 .システムモニタの起動をテスト名前空間のスタートアップリストに追加しましょう


    かなりよいdocument アイリスの起動と停止時に実行されるユーザールーチンについて.これを% Zstartと% Zstopと呼びます.
    私たちが興味を持っているのは、システム・モニタ(^% sysmonmgr)がシステム・スタート中にテスト・ネームスペースで始まることです.デフォルトでは、このモニタは% sys名前空間でのみ起動します.したがって、私たちは^ % ZSTARTプログラムを見るだけです.ソースは% Zstartです.Mac(% sys名前空間に保存して保存).
    ROUTINE %ZSTART
    
    %ZSTART; User startup routine.
    SYSTEM;
        ; IRIS starting
        do $zu(9,"","Starting System Monitor in TEST namespace by ^%ZSTART...Begin")
        znspace "TEST"
        set sc = ##class(%SYS.Monitor).Start()
        do $system.OBJ.DisplayError(sc)
        if (sc = 1) {
        do $zutil(9,"","Starting System Monitor in TEST namespace by ^%ZSTART...OK")
        } else {
        do $zutil(9,"","Starting System Monitor in TEST namespace by ^%ZSTART...ERROR")
        }
        ; Starting SNMP
        znspace "%SYS"
        do start^SNMP
        quit
    LOGIN;
        ; a user logs into IRIS (user account or telnet)
        quit
    JOB;
        ; JOB'd process begins
        quit
    CALLIN;
        ; a process enters via CALLIN interface
        quit
    
    もう一つの方法は、^ % sysmonmgrを使います.
    %SYS>do ^%SYSMONMGR
    
    1. Select item 3, Configure System Monitor Classes.
    
    2. Select item 2, Configure Startup Namespaces.
    
    3. Select item 2, Add Namespace.
    Namespace? TEST
    
    4. Select item 1, List Start Namespaces.
    Option? 1
         TEST
    
    5. Select item 4, Exit.
    
    6. Select item 3, Exit.
    
    7. Select item 8, Exit.
    
    今すぐ再起動した後にSNMP統計が収集され続けるようにIRISを再起動しましょう.
    これです.おそらく、いくつかの監視パラメータやコードの私の選択に疑問がありますが、タスクは原理的にそのような監視を実装する可能性を示すことでした.余分なパラメータを追加したり、後でコードをリファクタリングできます.
    また、アイリス設定をDockerInstaller , しかし、それはこの記事の範囲にありません.