zabbix_export:
  version: '7.2'
  template_groups:
    - uuid: 43d0fe04c7094000829b0d28c6e3470c
      name: 'Custom Templates'
    - uuid: 7018d0e63c324f68a0aa8f298ee14101
      name: 'Templates/Network devices'
  templates:
    - uuid: ef5836b050364554afe4fa926d6cccb3
      template: 'SolidBE Fortigate 7.4 Subtemplate SDWAN'
      name: 'SolidBE Fortigate 7.4 Subtemplate SDWAN'
      description: 'SolidBE Zabbix template for Fortiswitch managed by FortiGate'
      vendor:
        name: SolidBE
        version: 7.2-4
      groups:
        - name: 'Custom Templates'
        - name: 'Templates/Network devices'
      items:
        - uuid: d0e417061b854aaa9b8b60f4caf57794
          name: 'FortiGate HTTP SDWAN Healthchecks JSON'
          type: HTTP_AGENT
          key: fgt.http.monitor.virtual-wan.health-check
          history: '0'
          value_type: TEXT
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$..results.*'
          timeout: 3s
          url: 'https://{$FGATE.API.FQDN}:{$FGATE.API.PORT}/api/v2/monitor/virtual-wan/health-check'
          headers:
            - name: Authorization
              value: 'Bearer {$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
      discovery_rules:
        - uuid: c52f1b38f63f487ba0b46cf90e20a34b
          name: 'FortiGate HTTP SDWAN Healthchecks Discovery'
          type: DEPENDENT
          key: fgt.http.monitor.virtual-wan.health-check.discovery
          filter:
            conditions:
              - macro: '{#SDWHCSTATUS}'
                value: ^n\/a$
                operator: NOT_MATCHES_REGEX
          lifetime_type: DELETE_IMMEDIATELY
          item_prototypes:
            - uuid: 4636981935e74b11a85712bdfeb96904
              name: 'Fortigate HTTP SDWAN Healthcheck {#SDWHCNAME}/{#SDWHCINTERFACE} SLA met'
              type: DEPENDENT
              key: 'fgt.http.monitor.virtual-wan.health-check.sla_targets_met[{#SDWHCNAME},{#SDWHCINTERFACE}]'
              history: 30d
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.["{#SDWHCNAME}"].["{#SDWHCINTERFACE}"].sla_targets_met.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '28800'
              master_item:
                key: fgt.http.monitor.virtual-wan.health-check
              tags:
                - tag: component
                  value: sdwan
                - tag: interface
                  value: '{#SDWHCINTERFACE}'
                - tag: sdwan
                  value: '{#SDWHCNAME}'
            - uuid: 93d4041f77044c8dbb5604fae5ae0039
              name: 'Fortigate HTTP SDWAN Healthcheck {#SDWHCNAME}/{#SDWHCINTERFACE} Status'
              type: DEPENDENT
              key: 'fgt.http.monitor.virtual-wan.health-check.status[{#SDWHCNAME},{#SDWHCINTERFACE}]'
              history: 365d
              value_type: TEXT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.["{#SDWHCNAME}"].["{#SDWHCINTERFACE}"].status'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '28800'
              master_item:
                key: fgt.http.monitor.virtual-wan.health-check
              tags:
                - tag: component
                  value: sdwan
                - tag: interface
                  value: '{#SDWHCINTERFACE}'
                - tag: sdwan
                  value: '{#SDWHCNAME}'
          master_item:
            key: fgt.http.monitor.virtual-wan.health-check
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const obj = JSON.parse(value);
                  
                  var output = [];
                  
                  Object.keys(obj).forEach(function (healthcheckname) {
                    Object.keys(obj[healthcheckname]).forEach(function (interfacename) {
                      output.push({
                        '{#SDWHCNAME}': healthcheckname, 
                        '{#SDWHCSTATUS}': obj[healthcheckname][interfacename].status, 
                        '{#SDWHCINTERFACE}': interfacename
                       })
                    });
                  });
                  
                  return JSON.stringify(output);
      macros:
        - macro: '{$FGATE.API.FQDN}'
        - macro: '{$FGATE.API.PORT}'
          value: '443'
        - macro: '{$FGATE.API.TOKEN}'
        - macro: '{$FGT.FSW.VLAN.MATCH}'
          value: ^()$
