13.2. snmptrapd の設定

snmptrapd デーモンには、snmp-gateway サービスの作成時に指定する必要のある認証設定が含まれているため、snmp-gateway をデプロイする前に Simple Network Management Protocol (SNMP) ターゲットを設定することが重要です。

SNMP ゲートウェイ機能は、Prometheus スタックで生成されたアラートを SNMP 管理プラットフォームに公開する手段を提供します。snmptrapd ツールに基づいて、宛先への SNMP トラップを設定できます。このツールを使用すると、1 つ以上の SNMP トラップリスナーを確立できます。

設定には以下のパラメーターが重要となります。

  • engine-id は、デバイスの一意の識別子 (16 進数) であり、SNMPV3 ゲートウェイで必要とされています。Red Hat では、このパラメーターに `8000C53F_CLUSTER_FSID_WITHOUT_DASHES_` を使用することを推奨しています。
  • SNMP_COMMUNITY_FOR_SNMPV2 パラメーターである snmp-community は、SNMPV2c ゲートウェイに対して public です。
  • AUTH_PROTOCOL である auth-protocol は、SNMPV3 ゲートウェイでは必須であり、デフォルトでは SHA になります。
  • SNMPV3 ゲートウェイでは、PRIVACY_PROTOCOL である privacy-protocol は必須となります。
  • PRIVACY_PASSWORD は、暗号化された SNMPV3 ゲートウェイでは必須となります。
  • SNMP_V3_AUTH_USER_NAME はユーザー名であり、SNMPV3 ゲートウェイでは必須となります。
  • SNMP_V3_AUTH_PASSWORD はパスワードであり、SNMPV3 ゲートウェイでは必須となります。

前提条件

  • 稼働中の Red Hat Ceph Storage クラスターがある。
  • ノードへの root レベルのアクセス。
  • Red Hat Enterprise Linux システムに firewalld をインストールします。

手順

  1. SNMP 管理ホストで、SNMP パッケージをインストールします。

    例:

    [root@host01 ~]# dnf install -y net-snmp-utils net-snmp

  2. SNMP のポート 162 を開いて、アラートを受信します。

    例:

    [root@host01 ~]# firewall-cmd --zone=public --add-port=162/udp
    [root@host01 ~]# firewall-cmd --zone=public --add-port=162/udp --permanent

  3. 管理情報ベース (MIB) を実装して、SNMP 通知を理解し、宛先ホストでの SNMP サポートを強化します。メインリポジトリーから raw ファイルをコピーします: https://github.com/ceph/ceph/blob/master/monitoring/snmp/CEPH-MIB.txt

    例:

    [root@host01 ~]# curl -o CEPH_MIB.txt -L https://raw.githubusercontent.com/ceph/ceph/master/monitoring/snmp/CEPH-MIB.txt
    [root@host01 ~]# scp CEPH_MIB.txt root@host02:/usr/share/snmp/mibs

  4. snmptrapd ディレクトリーを作成します。

    例:

    [root@host01 ~]# mkdir /root/snmptrapd/

  5. SNMP バージョンに基づいて、各プロトコルの snmptrapd ディレクトリーに設定ファイルを作成します。

    構文

    format2 %V\n% Agent Address: %A \n Agent Hostname: %B \n Date: %H - %J - %K - %L - %M - %Y \n Enterprise OID: %N \n Trap Type: %W \n Trap Sub-Type: %q \n Community/Infosec Context: %P \n Uptime: %T \n Description: %W \n PDU Attribute/Value Pair Array:\n%v \n -------------- \n
    createuser -e 0x_ENGINE_ID_ SNMPV3_AUTH_USER_NAME AUTH_PROTOCOL SNMP_V3_AUTH_PASSWORD PRIVACY_PROTOCOL PRIVACY_PASSWORD
    authuser log,execute SNMP_V3_AUTH_USER_NAME
    authCommunity   log,execute,net SNMP_COMMUNITY_FOR_SNMPV2

    • SNMPV2c の場合、以下のように snmptrapd_public.conf ファイルを作成します。

      例:

      format2 %V\n% Agent Address: %A \n Agent Hostname: %B \n Date: %H - %J - %K - %L - %M - %Y \n Enterprise OID: %N \n Trap Type: %W \n Trap Sub-Type: %q \n Community/Infosec Context: %P \n Uptime: %T \n Description: %W \n PDU Attribute/Value Pair Array:\n%v \n -------------- \n
      
      authCommunity   log,execute,net public

      ここでの public 設定は、snmp-gateway サービスをデプロイするときに使用される snmp_community 設定と一致する必要があります。

    • 認証のみの SNMPV3 の場合は、以下のように snmptrapd_auth.conf ファイルを作成します。

      例:

      format2 %V\n% Agent Address: %A \n Agent Hostname: %B \n Date: %H - %J - %K - %L - %M - %Y \n Enterprise OID: %N \n Trap Type: %W \n Trap Sub-Type: %q \n Community/Infosec Context: %P \n Uptime: %T \n Description: %W \n PDU Attribute/Value Pair Array:\n%v \n -------------- \n
      createuser -e 0x8000C53Ff64f341c655d11eb8778fa163e914bcc myuser SHA mypassword
      authuser log,execute myuser

      0x8000C53Ff64f341c655d11eb8778fa163e914bcc 文字列は engine_id で、myusermypassword は認証情報です。パスワードのセキュリティーは、SHA アルゴリズムによって定義されます。

      これは、snmp-gateway デーモンをデプロイするための設定に対応します。

      例:

      snmp_v3_auth_username: myuser
      snmp_v3_auth_password: mypassword

    • 認証と暗号化を使用する SNMPV3 の場合、以下のように snmptrapd_authpriv.conf ファイルを作成します。

      例:

      format2 %V\n% Agent Address: %A \n Agent Hostname: %B \n Date: %H - %J - %K - %L - %M - %Y \n Enterprise OID: %N \n Trap Type: %W \n Trap Sub-Type: %q \n Community/Infosec Context: %P \n Uptime: %T \n Description: %W \n PDU Attribute/Value Pair Array:\n%v \n -------------- \n
      createuser -e 0x8000C53Ff64f341c655d11eb8778fa163e914bcc myuser SHA mypassword DES mysecret
      authuser log,execute myuser

      0x8000C53Ff64f341c655d11eb8778fa163e914bcc 文字列は engine_id で、myusermypassword は認証情報です。パスワードセキュリティーは SHA アルゴリズムで定義され、DES はプライバシー暗号化のタイプになります。

      これは、snmp-gateway デーモンをデプロイするための設定に対応します。

      例:

      snmp_v3_auth_username: myuser
      snmp_v3_auth_password: mypassword
      snmp_v3_priv_password: mysecret

  6. SNMP 管理ホストでデーモンを実行します。

    構文

    /usr/sbin/snmptrapd -M /usr/share/snmp/mibs -m CEPH-MIB.txt -f -C -c /root/snmptrapd/CONFIGURATION_FILE -Of -Lo :162

    例:

    [root@host01 ~]# /usr/sbin/snmptrapd -M /usr/share/snmp/mibs -m CEPH-MIB.txt -f -C -c /root/snmptrapd/snmptrapd_auth.conf -Of -Lo :162

  7. ストレージクラスターでアラートがトリガーされた場合は、SNMP 管理ホストで出力を監視できます。SNMP トラップと、MIB によってデコードされたトラップを確認します。

    例:

    NET-SNMP version 5.8
     Agent Address: 0.0.0.0
     Agent Hostname: <UNKNOWN>
     Date: 15 - 5 - 12 - 8 - 10 - 4461391
     Enterprise OID: .
     Trap Type: Cold Start
     Trap Sub-Type: 0
     Community/Infosec Context: TRAP2, SNMP v3, user myuser, context
     Uptime: 0
     Description: Cold Start
     PDU Attribute/Value Pair Array:
    .iso.org.dod.internet.mgmt.mib-2.1.3.0 = Timeticks: (292276100) 3 days, 19:52:41.00
    .iso.org.dod.internet.snmpV2.snmpModules.1.1.4.1.0 = OID: .iso.org.dod.internet.private.enterprises.ceph.cephCluster.cephNotifications.prometheus.promMgr.promMgrPrometheusInactive
    .iso.org.dod.internet.private.enterprises.ceph.cephCluster.cephNotifications.prometheus.promMgr.promMgrPrometheusInactive.1 = STRING: "1.3.6.1.4.1.50495.1.2.1.6.2[alertname=CephMgrPrometheusModuleInactive]"
    .iso.org.dod.internet.private.enterprises.ceph.cephCluster.cephNotifications.prometheus.promMgr.promMgrPrometheusInactive.2 = STRING: "critical"
    .iso.org.dod.internet.private.enterprises.ceph.cephCluster.cephNotifications.prometheus.promMgr.promMgrPrometheusInactive.3 = STRING: "Status: critical
    - Alert: CephMgrPrometheusModuleInactive
      Summary: Ceph's mgr/prometheus module is not available
      Description: The mgr/prometheus module at 10.70.39.243:9283 is unreachable. This could mean that the module has been disabled or the mgr itself is down.
    Without the mgr/prometheus module metrics and alerts will no longer function. Open a shell to ceph and use 'ceph -s' to determine whether the mgr is active. If the mgr is not active, restart it, otherwise you can check the mgr/prometheus module is loaded with 'ceph mgr module ls'  and if it's not listed as enabled, enable it with 'ceph mgr module enable prometheus'"

    上記の例では、Prometheus モジュールが無効になった後にアラートが生成されます。

関連情報