zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: 8c3d8ebc2dbc4bd69fb567764fbb9aa7
      name: Templates/Custom/Applications
  templates:
    - uuid: 84246561a032485380b7e34d4048aa4f
      template: 'Custom - Systemd by Zabbix agent 2'
      name: 'Custom - Systemd by Zabbix agent 2'
      description: |
        Get systemd units metrics from plugin for the zabbix-agent2.
          1. Setup and configure zabbix-agent2 compiled with the Systemd monitoring plugin.
          2. Set filters with macros if you want to override default filter parameters.

        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/

        Generated by official Zabbix template tool "Templator"
      groups:
        - name: Templates/Custom/Applications
      discovery_rules:
        - uuid: ad56342ca5e248d5b705b6b14be60618
          name: 'AutoMount units discovery'
          type: ZABBIX_ACTIVE
          key: 'systemd.unit.discovery[automount]'
          delay: 30m
          filter:
            evaltype: AND
            conditions:
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.AUTOMOUNT.MATCHES}'
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.AUTOMOUNT.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.AUTOMOUNT.MATCHES}'
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.AUTOMOUNT.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.AUTOMOUNT.MATCHES}'
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.AUTOMOUNT.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover systemd automount units and their details.'
          item_prototypes:
            - uuid: 1eddfbe1bf4e429a9c4e6c1730d4f545
              name: '{#UNIT.NAME}: Mount state'
              type: ZABBIX_ACTIVE
              key: 'systemd.automount.active_state["{#UNIT.NAME}"]'
              description: 'The mount state of {#UNIT.NAME}.'
              valuemap:
                name: 'Unit Mount State'
              tags:
                - tag: component
                  value: automount
              trigger_prototypes:
                - uuid: cc216920cf9a444ab69dfa0e51e9b9fb
                  expression: 'avg(/Custom - Systemd by Zabbix agent 2/systemd.automount.active_state["{#UNIT.NAME}"],5m)<>1'
                  name: '{#UNIT.NAME}: Network Share is not mounted.'
                  priority: HIGH
                  description: 'The network share handled by the systemd unit {#UNIT.NAME} is not mounted.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 89ef20dd531e4bbc8fc20c2b1771bc1f
              name: '{#UNIT.NAME}: Path'
              type: DEPENDENT
              key: 'systemd.automount.path["{#UNIT.NAME}"]'
              value_type: TEXT
              description: 'The path where network share is automounted.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Where
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}",Automount]'
              tags:
                - tag: component
                  value: automount
            - uuid: 781c127eb58b4cc0b153d51eb89d7ffa
              name: '{#UNIT.NAME}: get unit info'
              type: ZABBIX_ACTIVE
              key: 'systemd.unit.get["{#UNIT.NAME}",Automount]'
              history: '0'
              value_type: TEXT
              description: |
                Returns all properties of a systemd automount unit.
                 Unit description: {#UNIT.DESCRIPTION}.
              tags:
                - tag: component
                  value: automount
                - tag: component
                  value: raw
        - uuid: 1b31d67b97c4463c91558c56f30506b8
          name: 'Mount units discovery'
          type: ZABBIX_ACTIVE
          key: 'systemd.unit.discovery[mount]'
          delay: 30m
          filter:
            evaltype: AND
            conditions:
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.MOUNT.MATCHES}'
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.MOUNT.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.MOUNT.MATCHES}'
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.MOUNT.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.MOUNT.MATCHES}'
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.MOUNT.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover systemd mount units and their details.'
          item_prototypes:
            - uuid: 0f9f5eb49cec4ac38c17f724a4824c58
              name: '{#UNIT.NAME}: Mount state'
              type: ZABBIX_ACTIVE
              key: 'systemd.mount.active_state["{#UNIT.NAME}"]'
              description: 'The mount state of {#UNIT.NAME}.'
              valuemap:
                name: 'Unit Mount State'
              tags:
                - tag: component
                  value: mount
                - tag: component
                  value: raw
              trigger_prototypes:
                - uuid: d21a9150adb64037910379c1ffe9a46a
                  expression: 'avg(/Custom - Systemd by Zabbix agent 2/systemd.mount.active_state["{#UNIT.NAME}"],5m)<>1'
                  name: '{#UNIT.NAME}: Network Share is not mounted.'
                  priority: HIGH
                  description: 'The network share handled by the systemd unit {#UNIT.NAME} is not mounted.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: aefd5eaf4c4340e9b12c862dd6687751
              name: '{#UNIT.NAME}: Path'
              type: DEPENDENT
              key: 'systemd.mount.path["{#UNIT.NAME}"]'
              value_type: TEXT
              description: 'The path where network share is mounted.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Where
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}",Mount]'
              tags:
                - tag: component
                  value: mount
            - uuid: 5cf902d4109e4149b0c72480d31abbea
              name: '{#UNIT.NAME}: Target'
              type: DEPENDENT
              key: 'systemd.mount.target["{#UNIT.NAME}"]'
              value_type: TEXT
              description: 'The target filesystem to be mounted.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.What
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}",Mount]'
              tags:
                - tag: component
                  value: mount
            - uuid: d9837862b790481ebb5dc9a5e1e0f8ad
              name: '{#UNIT.NAME}: Get unit info'
              type: ZABBIX_ACTIVE
              key: 'systemd.unit.get["{#UNIT.NAME}",Mount]'
              history: '0'
              value_type: TEXT
              description: |
                Returns all properties of a systemd mount unit.
                 Unit description: {#UNIT.DESCRIPTION}.
              tags:
                - tag: component
                  value: mount
                - tag: component
                  value: raw
        - uuid: 92c48a6e01d34d3296aa6520b8504f5c
          name: 'Service units discovery'
          type: ZABBIX_ACTIVE
          key: 'systemd.unit.discovery[service]'
          delay: 30m
          filter:
            evaltype: AND
            conditions:
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.SERVICE.MATCHES}'
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.SERVICE.MATCHES}'
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.SERVICE.MATCHES}'
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover systemd service units and their details.'
          item_prototypes:
            - uuid: 657ab462f883425ebdf9cbd0830d48d2
              name: '{#UNIT.NAME}: Active state'
              type: DEPENDENT
              key: 'systemd.service.active_state["{#UNIT.NAME}"]'
              history: 7d
              description: 'State value that reflects whether the unit is currently active or not. The following states are currently defined: "active", "reloading", "inactive", "failed", "activating", and "deactivating".'
              valuemap:
                name: 'Unit Active State'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ActiveState.state
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 30m
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}"]'
              tags:
                - tag: component
                  value: service
              trigger_prototypes:
                - uuid: 6522ccce55cf474ebf66550836db1274
                  expression: 'last(/Custom - Systemd by Zabbix agent 2/systemd.service.active_state["{#UNIT.NAME}"])<>1'
                  name: '{#UNIT.NAME}: Service is not running'
                  priority: WARNING
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: d1e25c96ec834aeb9b4ed9594c099a5e
              name: '{#UNIT.NAME}: Load state'
              type: DEPENDENT
              key: 'systemd.service.load_state["{#UNIT.NAME}"]'
              history: 7d
              description: 'State value that reflects whether the configuration file of this unit has been loaded. The following states are currently defined: "loaded", "error", and "masked".'
              valuemap:
                name: 'Unit Load State'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.LoadState.state
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 30m
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}"]'
              tags:
                - tag: component
                  value: service
            - uuid: a28aa60eab77405f8bed752f0d42536d
              name: '{#UNIT.NAME}: Unit file state'
              type: DEPENDENT
              key: 'systemd.service.unitfile_state["{#UNIT.NAME}"]'
              history: 7d
              description: 'Encodes the install state of the unit file of FragmentPath. It currently knows the following states: "enabled", "enabled-runtime", "linked", "linked-runtime", "masked", "masked-runtime", "static", "disabled", and "invalid".'
              valuemap:
                name: 'Unit File State'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.UnitFileState.state
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 30m
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}"]'
              tags:
                - tag: component
                  value: service
            - uuid: 1259d4e46cff41e78411d9c8f910f773
              name: '{#UNIT.NAME}: Active time'
              type: DEPENDENT
              key: 'systemd.service.uptime["{#UNIT.NAME}"]'
              history: 7d
              value_type: FLOAT
              units: s
              description: 'Number of seconds since unit entered the active state.'
              preprocessing:
                - type: JAVASCRIPT
                  parameters:
                    - |
                      data = JSON.parse(value);
                      if (data.ActiveEnterTimestamp > data.ActiveExitTimestamp) {
                        return Math.floor(Date.now() / 1000) - Number(data.ActiveEnterTimestamp) / 1000000;
                      }
                      return null;
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}"]'
              tags:
                - tag: component
                  value: service
              trigger_prototypes:
                - uuid: e538cae77b73469cb2288601d054a9a4
                  expression: 'last(/Custom - Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m'
                  name: '{#UNIT.NAME}: has been restarted'
                  event_name: '{#UNIT.NAME}: has been restarted (uptime < 10m)'
                  priority: INFO
                  description: 'Uptime is less than 10 minutes.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 3754982bd6f6439785ccaa6f2353141f
              name: '{#UNIT.NAME}: Get unit info'
              key: 'systemd.unit.get["{#UNIT.NAME}"]'
              history: '0'
              value_type: TEXT
              description: |
                Returns all properties of a systemd service unit.
                 Unit description: {#UNIT.DESCRIPTION}.
              tags:
                - tag: component
                  value: raw
                - tag: component
                  value: unit
        - uuid: 1ea5d6ba8d6d4a87a4bc284fbd7b655f
          name: 'Socket units discovery'
          type: ZABBIX_ACTIVE
          key: 'systemd.unit.discovery[socket]'
          delay: 30m
          filter:
            evaltype: AND
            conditions:
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.SOCKET.MATCHES}'
              - macro: '{#UNIT.ACTIVESTATE}'
                value: '{$SYSTEMD.ACTIVESTATE.SOCKET.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.SOCKET.MATCHES}'
              - macro: '{#UNIT.NAME}'
                value: '{$SYSTEMD.NAME.SOCKET.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.SOCKET.MATCHES}'
              - macro: '{#UNIT.UNITFILESTATE}'
                value: '{$SYSTEMD.UNITFILESTATE.SOCKET.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover systemd socket units and their details.'
          item_prototypes:
            - uuid: 602d0577af3d43c48801a465b27daa22
              name: '{#UNIT.NAME}: Connections accepted per sec'
              type: DEPENDENT
              key: 'systemd.socket.conn_accepted.rate["{#UNIT.NAME}"]'
              history: 7d
              description: 'The number of accepted socket connections (NAccepted) per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.NAccepted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}",Socket]'
              tags:
                - tag: component
                  value: socket
            - uuid: 68699098129d4c678106c28757221cd4
              name: '{#UNIT.NAME}: Connections connected'
              type: DEPENDENT
              key: 'systemd.socket.conn_count["{#UNIT.NAME}"]'
              history: 7d
              description: 'The current number of socket connections (NConnections).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.NConnections
              master_item:
                key: 'systemd.unit.get["{#UNIT.NAME}",Socket]'
              tags:
                - tag: component
                  value: socket
            - uuid: 6987485182ea4e8e916614ec04e406a4
              name: '{#UNIT.NAME}: Get unit info'
              key: 'systemd.unit.get["{#UNIT.NAME}",Socket]'
              history: '0'
              value_type: TEXT
              description: |
                Returns all properties of a systemd socket unit.
                 Unit description: {#UNIT.DESCRIPTION}.
              tags:
                - tag: component
                  value: raw
                - tag: component
                  value: socket
      tags:
        - tag: class
          value: software
        - tag: target
          value: systemd
      macros:
        - macro: '{$SYSTEMD.ACTIVESTATE.AUTOMOUNT.MATCHES}'
          value: active
          description: 'Filter of systemd automount units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.AUTOMOUNT.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd automount units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.MOUNT.MATCHES}'
          value: active
          description: 'Filter of systemd mount units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.MOUNT.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd mount units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.SERVICE.MATCHES}'
          value: active
          description: 'Filter of systemd service units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.SERVICE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd service units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.SOCKET.MATCHES}'
          value: active
          description: 'Filter of systemd socket units by active state'
        - macro: '{$SYSTEMD.ACTIVESTATE.SOCKET.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd socket units by active state'
        - macro: '{$SYSTEMD.NAME.AUTOMOUNT.MATCHES}'
          value: 'mnt-.*.automount'
          description: 'Filter of systemd automount units by name'
        - macro: '{$SYSTEMD.NAME.AUTOMOUNT.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd automount units by name'
        - macro: '{$SYSTEMD.NAME.MOUNT.MATCHES}'
          value: 'mnt-.*.mount'
          description: 'Filter of systemd mount units by name'
        - macro: '{$SYSTEMD.NAME.MOUNT.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd mount units by name'
        - macro: '{$SYSTEMD.NAME.SERVICE.MATCHES}'
          value: '.*'
          description: 'Filter of systemd service units by name'
        - macro: '{$SYSTEMD.NAME.SERVICE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd service units by name'
        - macro: '{$SYSTEMD.NAME.SOCKET.MATCHES}'
          value: '.*'
          description: 'Filter of systemd socket units by name'
        - macro: '{$SYSTEMD.NAME.SOCKET.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd socket units by name'
        - macro: '{$SYSTEMD.UNITFILESTATE.AUTOMOUNT.MATCHES}'
          value: enabled
          description: 'Filter of systemd automount units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.AUTOMOUNT.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd automount units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.MOUNT.MATCHES}'
          value: enabled
          description: 'Filter of systemd mount units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.MOUNT.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd mount units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.SERVICE.MATCHES}'
          value: enabled
          description: 'Filter of systemd service units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.SERVICE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd service units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.SOCKET.MATCHES}'
          value: enabled
          description: 'Filter of systemd socket units by unit file state'
        - macro: '{$SYSTEMD.UNITFILESTATE.SOCKET.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter of systemd socket units by unit file state'
      dashboards:
        - uuid: 12fa033063d048ef804cefb4e6da0cdb
          name: 'Systemd: Overview'
          pages:
            - name: Services
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '20'
                  fields:
                    - type: ITEM_PROTOTYPE
                      name: itemid.0
                      value:
                        host: 'Custom - Systemd by Zabbix agent 2'
                        key: 'systemd.service.active_state["{#UNIT.NAME}"]'
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: rows
                      value: '5'
                    - type: INTEGER
                      name: source_type
                      value: '3'
            - name: Sockets
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '20'
                  fields:
                    - type: ITEM_PROTOTYPE
                      name: itemid.0
                      value:
                        host: 'Custom - Systemd by Zabbix agent 2'
                        key: 'systemd.socket.conn_count["{#UNIT.NAME}"]'
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: rows
                      value: '5'
                    - type: INTEGER
                      name: source_type
                      value: '3'
      valuemaps:
        - uuid: 388fe7ab2eae41cfb54aea4b3320d7ea
          name: 'Unit Active State'
          mappings:
            - value: '0'
              newvalue: unknown
            - value: '1'
              newvalue: active
            - value: '2'
              newvalue: reloading
            - value: '3'
              newvalue: inactive
            - value: '4'
              newvalue: failed
            - value: '5'
              newvalue: activating
            - value: '6'
              newvalue: deactivating
        - uuid: 03ab348dc3f24e9a9100fd961cb9b11d
          name: 'Unit File State'
          mappings:
            - value: '0'
              newvalue: unknown
            - value: '1'
              newvalue: enabled
            - value: '2'
              newvalue: enabled-runtime
            - value: '3'
              newvalue: linked
            - value: '4'
              newvalue: linked-runtime
            - value: '5'
              newvalue: masked
            - value: '6'
              newvalue: masked-runtime
            - value: '7'
              newvalue: static
            - value: '8'
              newvalue: disabled
            - value: '9'
              newvalue: invalid
        - uuid: d46eedb7296d4eab81f1ef0165f7100d
          name: 'Unit Load State'
          mappings:
            - value: '0'
              newvalue: unknown
            - value: '1'
              newvalue: loaded
            - value: '2'
              newvalue: error
            - value: '3'
              newvalue: masked
        - uuid: a81fccf125ea4646845d1bd84dec4624
          name: 'Unit Mount State'
          mappings:
            - value: '0'
              newvalue: unknown
            - value: '1'
              newvalue: mounted
