zabbix_export:
  version: '6.4'
  template_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Templates/Applications
  templates:
    - uuid: 29f7c5e662214feb82c63903c6354bba
      template: 'Application - TrustView API - Certificate Revocation List'
      name: 'Application - TrustView API - Certificate Revocation List'
      description: |
        Created by Alex Glavind, Region Nordjylland
        Created on 19-09-2024
        Created for TrustView v. 5.26.166
      groups:
        - name: Templates/Applications
      items:
        - uuid: 7a9ee068b83b47ca8f15f6af6a7a11ba
          name: 'TrustView: Get Monitored CRLs'
          type: HTTP_AGENT
          key: trustview.get.crls
          delay: 15m
          history: '0'
          value_type: TEXT
          url: '{$TRUSTVIEW.URL}/api/v1/monitoredobject/monitoredrevocationlist?fields=id,name,CN,expiry?max=5000&expiryafter={$TRUSTVIEW.EXPIRY.AFTER}&monitoredobjectstatus=Active'
          query_fields:
            - name: id
          headers:
            - name: X-TRUSTVIEW-APIKEY
              value: '{$TRUSTVIEW.API.KEY}'
            - name: accept
              value: application/json
          output_format: JSON
          tags:
            - tag: Application
              value: 'Zabbix raw items'
      discovery_rules:
        - uuid: fe1156fc0f4848389b9858f21bb46600
          name: 'TrustView CRL Discovery'
          type: DEPENDENT
          key: trw.crl.discovery
          delay: '0'
          item_prototypes:
            - uuid: 73be6c13e0b143c0896284e346091c87
              name: 'TrustView: CRL comment ({#CRL.NAME})'
              type: DEPENDENT
              key: 'trustview.crl.comment[{#CRL.ID}]'
              value_type: TEXT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.body.monitoredobjects[?(@.id == {#CRL.ID})].comment'
                - type: RTRIM
                  parameters:
                    - '"]'
                - type: LTRIM
                  parameters:
                    - '["'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 24h
              master_item:
                key: trustview.get.crls
            - uuid: d693653f48a047098eaf2d6665445796
              name: 'TrustView: CRL expiry ({#CRL.NAME})'
              type: DEPENDENT
              key: 'trustview.crl.expiry[{#CRL.ID}]'
              units: unixtime
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.body.monitoredobjects[?(@.id == {#CRL.ID})].expiry'
                - type: RTRIM
                  parameters:
                    - '"]'
                - type: LTRIM
                  parameters:
                    - '["'
                - type: JAVASCRIPT
                  parameters:
                    - 'return Math.floor(Date.parse(value) / 1000);'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 24h
              master_item:
                key: trustview.get.crls
              trigger_prototypes:
                - uuid: fc90289ad3c04345bb4cf08f2f7ce356
                  expression: 'last(/Application - TrustView API - Certificate Revocation List/trustview.crl.expiry[{#CRL.ID}])<(last(/Application - TrustView API - Certificate Revocation List/trustview.crl.expiry[{#CRL.ID}])-{$TRUSTVIEW.CRL.EXPIRY.WARN:"{#CRL.ID}"})'
                  name: 'TRW-0001: The CRL of "{#CRL.NAME}" expires in {$TRUSTVIEW.CRL.EXPIRY.WARN:"{#CRL.ID}"}'
                  priority: WARNING
                  description: |
                    This problem has been triggered because the Certificate Revocation List of the monitored CRL in TrustView expires in {$TRUSTVIEW.CRL.EXPIRY.WARN:"{#CRL.ID}"}).
                    You should publish a new CRL to avoid issues with your PKI.
                    If you fail to update the CRL, clients will stop trusting the certificate chain and the certificates will stop working.
                - uuid: a4d1f5b8b699437387a249e85b4cb6ec
                  expression: 'last(/Application - TrustView API - Certificate Revocation List/trustview.crl.expiry[{#CRL.ID}])<(last(/Application - TrustView API - Certificate Revocation List/trustview.crl.expiry[{#CRL.ID}])-{$TRUSTVIEW.CRL.EXPIRY.CRIT:"{#CRL.ID}"})'
                  name: 'TRW-0002: The CRL of "{#CRL.NAME}" expires in {$TRUSTVIEW.CRL.EXPIRY.CRIT:"{#CRL.ID}"}'
                  priority: HIGH
                  description: |
                    This problem has been triggered because the Certificate Revocation List of the monitored CRL in TrustView expires in {$TRUSTVIEW.CRL.EXPIRY.CRIT:"{#CRL.ID}"}.
                    You should publish a new CRL to avoid issues with your PKI.
                    If you fail to update the CRL, clients will stop trusting the certificate chain and the certificates will stop working.
            - uuid: 30d182b250954a36b8c2fff3c7e13260
              name: 'TrustView: CRL id ({#CRL.NAME})'
              type: DEPENDENT
              key: 'trustview.crl.id[{#CRL.ID}]'
              value_type: TEXT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.body.monitoredobjects[?(@.id == {#CRL.ID})].id'
                - type: RTRIM
                  parameters:
                    - '"]'
                - type: LTRIM
                  parameters:
                    - '["'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 24h
              master_item:
                key: trustview.get.crls
            - uuid: 4d33d4764a694991b1111318f1882554
              name: 'TrustView: CRL name ({#CRL.NAME})'
              type: DEPENDENT
              key: 'trustview.crl.name[{#CRL.ID}]'
              value_type: TEXT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.body.monitoredobjects[?(@.id == {#CRL.ID})].name'
                - type: RTRIM
                  parameters:
                    - '"]'
                - type: LTRIM
                  parameters:
                    - '["'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 24h
              master_item:
                key: trustview.get.crls
          master_item:
            key: trustview.get.crls
          lld_macro_paths:
            - lld_macro: '{#CRL.COMMENT}'
              path: $.comment
            - lld_macro: '{#CRL.EXPIRY}'
              path: $.expiry
            - lld_macro: '{#CRL.ID}'
              path: $.id
            - lld_macro: '{#CRL.NAME}'
              path: $.name
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.body.monitoredobjects[*]'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
      tags:
        - tag: Application
          value: TrustView
      macros:
        - macro: '{$TRUESTVIEW.CRL.EXPIRY.CRIT}'
          value: 5d
          description: 'How long before Zabbix should trigger at problem regardin CRL expiry (Critical)'
        - macro: '{$TRUSTVIEW.API.KEY}'
          value: '<Insert your API key here>'
          description: 'The API key for TrustView. Remember to create the API key in the TrustView GUI and assign the proper permissions'
        - macro: '{$TRUSTVIEW.CRL.EXPIRY.WARN}'
          value: 10d
          description: 'How long before Zabbix should trigger at problem regardin CRL expiry (Warning)'
        - macro: '{$TRUSTVIEW.URL}'
          value: '<The URL of truestview>'
          description: 'The URL your TrustView application'
