zabbix_export:
  version: '7.0'
  host_groups:
    - uuid: 1cc1b7a0eedc40dbae712cae4e8b204a
      name: Test
  hosts:
    - host: Host
      name: Host
      groups:
        - name: Test
      discovery_rules:
        - name: 'Block devices discovery'
          type: ZABBIX_ACTIVE
          key: vfs.dev.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DEVNAME}'
                value: '{$VFS.DEV.DEVNAME.MATCHES}'
                formulaid: A
              - macro: '{#DEVNAME}'
                value: '{$VFS.DEV.DEVNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#DEVTYPE}'
                value: disk
                formulaid: C
          item_prototypes:
            - name: '{#DEVNAME}: Disk average queue size (avgqu-sz)'
              type: DEPENDENT
              key: 'vfs.dev.queue_size[{#DEVNAME}]'
              delay: '0'
              value_type: FLOAT
              description: 'The current average disk queue; the number of requests outstanding on the disk while the performance data is being collected.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[10]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
              master_item:
                key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              tags:
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#DEVNAME}'
            - name: '{#DEVNAME}: Disk read rate'
              type: DEPENDENT
              key: 'vfs.dev.read.rate[{#DEVNAME}]'
              delay: '0'
              value_type: FLOAT
              units: '!r/s'
              description: 'r/s (read operations per second) - the number (after merges) of read requests completed per second for the device.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[0]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              tags:
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#DEVNAME}'
            - name: '{#DEVNAME}: Disk read time (rate)'
              type: DEPENDENT
              key: 'vfs.dev.read.time.rate[{#DEVNAME}]'
              delay: '0'
              value_type: FLOAT
              description: 'The rate of total read time counter; used in `r_await` calculation.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[3]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
              master_item:
                key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              tags:
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#DEVNAME}'
            - name: '{#DEVNAME}: Disk utilization'
              type: DEPENDENT
              key: 'vfs.dev.util[{#DEVNAME}]'
              delay: '0'
              value_type: FLOAT
              units: '%'
              description: 'The percentage of elapsed time during which the selected disk drive was busy while servicing read or write requests.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[9]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
                - type: MULTIPLIER
                  parameters:
                    - '0.1'
              master_item:
                key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              tags:
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#DEVNAME}'
            - name: '{#DEVNAME}: Disk write rate'
              type: DEPENDENT
              key: 'vfs.dev.write.rate[{#DEVNAME}]'
              delay: '0'
              value_type: FLOAT
              units: '!w/s'
              description: 'w/s (write operations per second) - the number (after merges) of write requests completed per second for the device.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[4]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              tags:
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#DEVNAME}'
            - name: '{#DEVNAME}: Disk write time (rate)'
              type: DEPENDENT
              key: 'vfs.dev.write.time.rate[{#DEVNAME}]'
              delay: '0'
              value_type: FLOAT
              description: 'The rate of total write time counter; used in `w_await` calculation.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[7]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
              master_item:
                key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              tags:
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#DEVNAME}'
            - name: '{#DEVNAME}: Get stats'
              type: ZABBIX_ACTIVE
              key: 'vfs.file.contents[/sys/block/{#DEVNAME}/stat]'
              delay: 1s
              history: '0'
              value_type: TEXT
              trends: '0'
              description: 'The contents of get `/sys/block/{#DEVNAME}/stat` to get the disk statistics.'
              preprocessing:
                - type: JAVASCRIPT
                  parameters:
                    - 'return JSON.stringify(value.trim().split(/ +/));'
              tags:
                - tag: component
                  value: raw
          graph_prototypes:
            - name: '{#DEVNAME}: Disk read/write rates'
              graph_items:
                - color: 199C0D
                  item:
                    host: Host
                    key: 'vfs.dev.read.rate[{#DEVNAME}]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: Host
                    key: 'vfs.dev.write.rate[{#DEVNAME}]'
            - name: '{#DEVNAME}: Disk utilization and queue'
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: Host
                    key: 'vfs.dev.queue_size[{#DEVNAME}]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: Host
                    key: 'vfs.dev.util[{#DEVNAME}]'
      macros:
        - macro: '{$VFS.DEV.DEVNAME.MATCHES}'
          value: .+
        - macro: '{$VFS.DEV.DEVNAME.NOT_MATCHES}'
          value: '^(loop[0-9]*|sd[a-z][0-9]+|nbd[0-9]+|sr[0-9]+|fd[0-9]+|dm-[0-9]+|ram[0-9]+|ploop[a-z0-9]+|md[0-9]*|hcp[0-9]*|zram[0-9]*)'
      inventory_mode: DISABLED
