zabbix_export:
  version: '6.0'
  date: '2024-02-25T06:30:53Z'
  groups:
    - uuid: 22941f4e01294888a9bed3aae15f6ef9
      name: Templates/AWNET
  templates:
    - uuid: d60632a7a4b94709b0455e1bec6ce54a
      template: 'Linux software RAID monitoring'
      name: 'Linux software RAID monitoring'
      description: 'version: v0.r202402.2'
      groups:
        - name: Templates/AWNET
      discovery_rules:
        - uuid: 533db42d1dc340e593a8d4761eda1347
          name: 'Данные устройств'
          key: aw.linux.mdadm.list
          delay: 5m
          lifetime: 1d
          item_prototypes:
            - uuid: 2fd74bd606d241d1bf34759ed1449ad5
              name: 'MD RAID {#DEVICE}: Количество активных устройства'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.active-devices[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["active devices"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: 9706ad0fa9814755a5fec3aeb074785c
              name: 'MD RAID {#DEVICE}: Общий полезный объём'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.array-size[{#DEVICE}]'
              delay: '0'
              units: B
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["array size"]'
                - type: REGEX
                  parameters:
                    - '^([0-9]+)'
                    - \1
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: ecbe2d984e0a4cd2a23bdefed863b3e7
              name: 'MD RAID {#DEVICE}: Время создания массива'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.creation-time[{#DEVICE}]'
              delay: '0'
              trends: '0'
              value_type: TEXT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["creation time"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: 1542cad0f9934df78e884eaee0220061
              name: 'MD RAID {#DEVICE}: Количество событий, произошедших с массивом'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.events[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["events"]'
                - type: SIMPLE_CHANGE
                  parameters:
                    - ''
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: 7fbc5180754444c79702eabcd19213cf
              name: 'MD RAID {#DEVICE}: Количество отказавших устройства'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.failed-devices[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["failed devices"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
              trigger_prototypes:
                - uuid: 617dd8c5ae984a759a9f4a55e2e6edfe
                  expression: 'last(/Linux software RAID monitoring/aw.linux.mdadm.d.failed-devices[{#DEVICE}])<>0'
                  name: 'Наличие отказавших устройств в массиве {#DEVICE}'
                  priority: HIGH
            - uuid: db60d1b47ebd479386aace38ad0b503f
              name: 'MD RAID {#DEVICE}: Устройств в массиве'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.raid-devices[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["raid devices"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: 3ac9863ea63948bbbeb0d45f6816d926
              name: 'MD RAID {#DEVICE}: Тип массива'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.raid-level[{#DEVICE}]'
              delay: '0'
              trends: '0'
              value_type: CHAR
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["raid level"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
              trigger_prototypes:
                - uuid: 7ea6e8b61acc4eb6a068e4a289725fd7
                  expression: 'change(/Linux software RAID monitoring/aw.linux.mdadm.d.raid-level[{#DEVICE}])<>0'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'nodata(/Linux software RAID monitoring/aw.linux.mdadm.d.raid-level[{#DEVICE}],1h)=1'
                  name: 'Изменился тип массива {#DEVICE}'
                  priority: INFO
            - uuid: f04b15b7f32a4e62b4e6a302c60a8fe4
              name: 'MD RAID {#DEVICE}: Состояние составляющих блочных устройств'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.raw-state[{#DEVICE}]'
              delay: '0'
              trends: '0'
              value_type: TEXT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["raw state"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: 8cc07323b6084b00be54e9f5f2adcd6c
              name: 'MD RAID {#DEVICE}: Количество запасных устройств'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.spare-devices[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["spare devices"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
              trigger_prototypes:
                - uuid: 77a85a17674b4b5aa7e023b56290ed61
                  expression: 'change(/Linux software RAID monitoring/aw.linux.mdadm.d.spare-devices[{#DEVICE}])<0'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'nodata(/Linux software RAID monitoring/aw.linux.mdadm.d.spare-devices[{#DEVICE}],1h)=1'
                  name: 'Уменьшилось количество запасных устройств в {#DEVICE}'
                  priority: HIGH
            - uuid: 7bf13d288746481da7aa1ba863e24dcf
              name: 'MD RAID {#DEVICE}: Состояние массива'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.state[{#DEVICE}]'
              delay: '0'
              trends: '0'
              value_type: CHAR
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["state"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '__NO STATUS__'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
              trigger_prototypes:
                - uuid: 6a4bcf95112c4dfd91b1108b1a4bb8f8
                  expression: 'last(/Linux software RAID monitoring/aw.linux.mdadm.d.state[{#DEVICE}])<>"clean" and last(/Linux software RAID monitoring/aw.linux.mdadm.d.state[{#DEVICE}])<>"active"'
                  name: 'Неожиданное состояние массива {#DEVICE}'
                  priority: AVERAGE
                  dependencies:
                    - name: 'Отсутствуют данные о состоянии массива {#DEVICE}'
                      expression: 'last(/Linux software RAID monitoring/aw.linux.mdadm.d.state[{#DEVICE}])="__NO STATUS__"'
                - uuid: fadccd30aba941cf97d00224117492d2
                  expression: 'last(/Linux software RAID monitoring/aw.linux.mdadm.d.state[{#DEVICE}])="__NO STATUS__"'
                  name: 'Отсутствуют данные о состоянии массива {#DEVICE}'
                  priority: HIGH
            - uuid: 2e82148caae345bf99c201497d278edd
              name: 'MD RAID {#DEVICE}: Общее количество устройств в массиве'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.total-devices[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["total devices"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: d19120bc1e374ba69d140a60011a7389
              name: 'MD RAID {#DEVICE}: Используемое на  каждом устройстве пространство под массив'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.used-dev-size[{#DEVICE}]'
              delay: '0'
              units: B
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["used dev size"]'
                - type: REGEX
                  parameters:
                    - '^([0-9]+)'
                    - \1
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
            - uuid: 2bf72ad31e7d4a9d99e9b1fc27eaace0
              name: 'MD RAID {#DEVICE}: Количество устройств в работе'
              type: DEPENDENT
              key: 'aw.linux.mdadm.d.working-devices[{#DEVICE}]'
              delay: '0'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["working devices"]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - '86400'
              master_item:
                key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
              trigger_prototypes:
                - uuid: 6f76dffea3164025a379f012606f29b4
                  expression: 'change(/Linux software RAID monitoring/aw.linux.mdadm.d.working-devices[{#DEVICE}])<>0'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'nodata(/Linux software RAID monitoring/aw.linux.mdadm.d.working-devices[{#DEVICE}],1h)=1'
                  name: 'Изменилос количество работающих устройств в массиве {#DEVICE}'
                  priority: AVERAGE
            - uuid: 48d73b212abe49f797703669391eb431
              name: '_ MD RAID {#DEVICE}: Сырые данные'
              key: 'aw.linux.mdadm.get-stat[{#DEVICE}]'
              history: '0'
              trends: '0'
              value_type: TEXT
              preprocessing:
                - type: JAVASCRIPT
                  parameters:
                    - |
                      var res = {};
                      var flag = true;
                      var buf = value.split('\n');
                      for (var li in buf) {
                          var l = buf[li]
                          if (l.match(/^ +Number +Major +Minor/)) {
                              flag = false;
                              res["raw state"] = ""
                          }
                      
                          if (flag) {
                              var _buf = l.split(' : ');
                              if (_buf.length >= 2) {
                                  res[_buf[0].trim().toLowerCase()] = _buf[1].trim();
                              }
                          } else {
                              res["raw state"] += l + '\n';
                      
                          }
                      
                      }
                      
                      return JSON.stringify(res)
              tags:
                - tag: Application
                  value: 'MD RAID'
                - tag: Устройство
                  value: '{#DEVICE}'
          trigger_prototypes:
            - uuid: 7b81377396ad4602a684da37ea8fdb35
              expression: 'change(/Linux software RAID monitoring/aw.linux.mdadm.d.array-size[{#DEVICE}])<>0 or change(/Linux software RAID monitoring/aw.linux.mdadm.d.used-dev-size[{#DEVICE}])<>0'
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: 'nodata(/Linux software RAID monitoring/aw.linux.mdadm.d.used-dev-size[{#DEVICE}],1h)=1 and nodata(/Linux software RAID monitoring/aw.linux.mdadm.d.array-size[{#DEVICE}],1h)=1'
              name: 'Изменились размеры массива {#DEVICE}'
              opdata: 'Полезный размер: {ITEM.LASTVALUE1} -> {ITEM.VALUE1}; занимаемое на устройствах пространство: {ITEM.LASTVALUE2} -> {ITEM.VALUE2}'
              priority: INFO
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var res = []
                  var buf = value.split('\n');
                  for (var li in buf) {
                      var l = buf[li].trim()
                      if (l.length > 2) {
                          res.push({
                              '{#DEVICE}': l
                          })
                      }
                  }
                  
                  return JSON.stringify(res)
