zabbix_export:
  version: '5.2'
  date: '2022-09-10T20:57:37Z'
  groups:
    -
      name: Templates
  templates:
    -
      template: Template_NUT
      name: Template_NUT
      groups:
        -
          name: Templates
      applications:
        -
          name: NUT
        -
          name: 'NUT Raw'
      items:
        -
          name: 'NUT JSON'
          key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
          history: '0'
          trends: '0'
          value_type: TEXT
          applications:
            -
              name: 'NUT Raw'
      discovery_rules:
        -
          name: 'Discover UPS'
          type: DEPENDENT
          key: nut.discovery
          delay: '0'
          item_prototypes:
            -
              name: '{#UPS_NAME} - Battery Charge'
              type: DEPENDENT
              key: 'nut.battery.charge["{#UPS_NAME}"]'
              delay: '0'
              value_type: FLOAT
              units: '%'
              applications:
                -
                  name: NUT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''battery.charge'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
              trigger_prototypes:
                -
                  expression: '{last()}<{$NUT_CHARGE_CRIT}'
                  name: 'UPS "{#UPS_NAME}" charge is critical: {ITEM.LASTVALUE}'
                  priority: HIGH
                -
                  expression: '{last()}<{$NUT_CHARGE_LOW}'
                  name: 'UPS "{#UPS_NAME}" charge is low: {ITEM.LASTVALUE}'
                  priority: HIGH
            -
              name: '{#UPS_NAME} - Battery Voltage'
              type: DEPENDENT
              key: 'nut.battery.voltage["{#UPS_NAME}"]'
              delay: '0'
              value_type: FLOAT
              units: V
              applications:
                -
                  name: NUT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''battery.voltage'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
            -
              name: '{#UPS_NAME} - Input Frequency'
              type: DEPENDENT
              key: 'nut.input.freq["{#UPS_NAME}"]'
              delay: '0'
              value_type: FLOAT
              units: Hz
              applications:
                -
                  name: NUT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''input.frequency'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
            -
              name: '{#UPS_NAME} - Input Voltage'
              type: DEPENDENT
              key: 'nut.input.voltage["{#UPS_NAME}"]'
              delay: '0'
              value_type: FLOAT
              units: V
              applications:
                -
                  name: NUT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''input.voltage'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
              trigger_prototypes:
                -
                  expression: '{min(120)}>={$NUT_VOLTAGE_HIGH} or {max(120)}<={$NUT_VOLTAGE_LOW}'
                  name: 'UPS "{#UPS_NAME}" voltage is out of bounds: {ITEM.LASTVALUE}'
                  priority: AVERAGE
            -
              name: '{#UPS_NAME} - Load'
              type: DEPENDENT
              key: 'nut.load["{#UPS_NAME}"]'
              delay: '0'
              value_type: FLOAT
              units: '%'
              applications:
                -
                  name: NUT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''ups.load'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
              trigger_prototypes:
                -
                  expression: '{last()}>{$NUT_LOAD_CRIT}'
                  name: 'UPS "{#UPS_NAME}" load is critical: {ITEM.LASTVALUE}'
                  priority: HIGH
                -
                  expression: '{last()}>{$NUT_LOAD_HIGH}'
                  name: 'UPS "{#UPS_NAME}" load is high: {ITEM.LASTVALUE}'
                  priority: HIGH
            -
              name: '{#UPS_NAME} - Output Voltage'
              type: DEPENDENT
              key: 'nut.output.voltage["{#UPS_NAME}"]'
              delay: '0'
              value_type: FLOAT
              units: V
              applications:
                -
                  name: NUT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''output.voltage'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
            -
              name: '{#UPS_NAME} - Status'
              type: DEPENDENT
              key: 'nut.status["{#UPS_NAME}"]'
              delay: '0'
              history: 7d
              trends: '0'
              value_type: CHAR
              applications:
                -
                  name: NUT
              valuemap:
                name: 'NUT UPS Status'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$.vars[''{#UPS_NAME}''][''ups.status'']'
              master_item:
                key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
              trigger_prototypes:
                -
                  expression: '{last()}="CAL"'
                  name: 'UPS "{#UPS_NAME}" status is calibrating'
                  priority: INFO
                -
                  expression: '{last()}="CHRG"'
                  name: 'UPS "{#UPS_NAME}" status is charging'
                  priority: INFO
                -
                  expression: '{last()}="BYPASS"'
                  name: 'UPS "{#UPS_NAME}" status is in bypass'
                  priority: WARNING
                -
                  expression: '{regexp({$NUT_STATUS_OK})}=0'
                  name: 'UPS "{#UPS_NAME}" status is not healthy: {ITEM.LASTVALUE}'
                  priority: HIGH
                -
                  expression: '{last()}="OB"'
                  name: 'UPS "{#UPS_NAME}" status is on battery'
                  priority: AVERAGE
          master_item:
            key: 'nut["{$NUT_HOST}", "{$NUT_PORT}", "{$NUT_USERNAME}", "{$NUT_PASSWORD}"]'
          lld_macro_paths:
            -
              lld_macro: '{#UPS_NAME}'
              path: $.name
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$.list.*'
      macros:
        -
          macro: '{$NUT_CHARGE_CRIT}'
          value: '10'
          description: 'Battery charge crit low threshold'
        -
          macro: '{$NUT_CHARGE_LOW}'
          value: '30'
          description: 'Battery charge low threshold'
        -
          macro: '{$NUT_HOST}'
          value: 127.0.0.1
          description: 'Host to query'
        -
          macro: '{$NUT_LOAD_CRIT}'
          value: '90'
          description: 'UPS load crit threshold'
        -
          macro: '{$NUT_LOAD_HIGH}'
          value: '70'
          description: 'UPS load high threshold'
        -
          macro: '{$NUT_PASSWORD}'
          description: 'Password to use'
        -
          macro: '{$NUT_PORT}'
          value: '3493'
          description: 'Port to query'
        -
          macro: '{$NUT_STATUS_OK}'
          value: ^OL|OB|CHRG|TRIM|BOOST|CAL$
          description: 'Regex of statuses which are considered healthy'
        -
          macro: '{$NUT_TEMP_CRIT}'
          value: '50'
          description: 'Temperature crit threshold'
        -
          macro: '{$NUT_TEMP_HIGH}'
          value: '40'
          description: 'Temperature high threshold'
        -
          macro: '{$NUT_USERNAME}'
          description: 'Username to use (leave empty to disable auth)'
        -
          macro: '{$NUT_VOLTAGE_HIGH}'
          value: '250'
          description: 'High voltage bound'
        -
          macro: '{$NUT_VOLTAGE_LOW}'
          value: '50'
          description: 'Low voltage bound'
  value_maps:
    -
      name: 'NUT UPS Status'
      mappings:
        -
          value: BOOST
          newvalue: 'Boosting Voltage'
        -
          value: BYPASS
          newvalue: Bypass
        -
          value: CAL
          newvalue: Calibrating
        -
          value: CHRG
          newvalue: Charging
        -
          value: CP
          newvalue: 'Cable Power'
        -
          value: DISCHRG
          newvalue: Discharging
        -
          value: FSD
          newvalue: 'Forced Shutdown'
        -
          value: LB
          newvalue: 'Low Battery'
        -
          value: none
          newvalue: Unknown
        -
          value: OB
          newvalue: 'On Battery'
        -
          value: 'OFF'
          newvalue: 'Load Off'
        -
          value: OL
          newvalue: Online
        -
          value: OVER
          newvalue: Overloaded
        -
          value: RB
          newvalue: 'Replace Battery'
        -
          value: SD
          newvalue: 'Shutdown Load'
        -
          value: TRIM
          newvalue: 'Trimming Voltage'
