zabbix_export:
  version: '7.4'
  template_groups:
    - uuid: 801371d3ecdf423bba05aa237dd201e8
      name: Templates/Microsoft
  templates:
    - uuid: ce995bf92d5d4ca7b8f2b61a9b62fae1
      template: APP_Zbx_HyperV
      name: APP_Zbx_HyperV
      description: 'Monitore les hyperV en standalone, un autre template doit être rajouté pour faire la partie cluster'
      groups:
        - name: Templates/Microsoft
      items:
        - uuid: 400390895ca443da99461c9ece231777
          name: 'Get number of snapshots'
          type: DEPENDENT
          key: hyperv.snapshots.number
          history: 30d
          trends: '0'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.parse(value).length;'
          master_item:
            key: 'wmi.getall[root\virtualization\v2,"select CreationTime,ElementName from Msvm_VirtualSystemSettingData where SuspendDataRoot Like ''Snapshots%''"]'
          tags:
            - tag: norme
              value: 'hyperv.snapshots.number{hyperion.normalisation.version="0"}'
          triggers:
            - uuid: 68ab3049535c4928a7217f1de762438c
              expression: 'last(/APP_Zbx_HyperV/hyperv.snapshots.number)>{$HYPERV.SNAPSHOTS.MAX}'
              name: 'Hyper-V number of snapshots > {$HYPERV.SNAPSHOTS.MAX}'
              priority: WARNING
        - uuid: 5fac5290f0cc43eab92ce34cf11866f9
          name: 'Get oldest date time of snapshots'
          type: DEPENDENT
          key: hyperv.snapshots.oldestDateTime
          history: 30d
          units: unixtime
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var value = JSON.parse(value);
                  var OlderSnapshot = null;
                  if (value.length > 0) {
                      for (var i = 0; i < value.length; i++) {
                          var current = value[i];
                          if (OlderSnapshot === null || current.CreationTime < OlderSnapshot.CreationTime) {
                              OlderSnapshot = current;
                          }
                  
                      }
                  
                      var OlderSnapshotCreationTime = OlderSnapshot.CreationTime;
                      var day = OlderSnapshotCreationTime.substring(6, 8);
                      var month = OlderSnapshotCreationTime.substring(4, 6);
                      var year = OlderSnapshotCreationTime.substring(0, 4);
                      var hour = OlderSnapshotCreationTime.substring(8, 10);
                      var minutes = OlderSnapshotCreationTime.substring(10, 12);
                      var seconds = OlderSnapshotCreationTime.substring(12, 14);
                      var milliseconds = OlderSnapshotCreationTime.substring(15, 18);
                  
                      var outDate = year + "-" + month + "-" + day + "T" + hour + ":" + minutes + ":" + seconds;
                      date = new Date(outDate);
                      return Math.round(date.getTime() / 1000);
                  } else {
                      return 0;
                  }
          master_item:
            key: 'wmi.getall[root\virtualization\v2,"select CreationTime,ElementName from Msvm_VirtualSystemSettingData where SuspendDataRoot Like ''Snapshots%''"]'
          tags:
            - tag: norme
              value: 'hyperv.snapshots.oldestDateTime{hyperion.normalisation.version="0"}'
          triggers:
            - uuid: cea3dcfc2fb34252b287746c6737491a
              expression: 'fuzzytime(/APP_Zbx_HyperV/hyperv.snapshots.oldestDateTime,{$HYPERV.SNAPSHOTS.MAXAGE})=0 and last(/APP_Zbx_HyperV/hyperv.snapshots.oldestDateTime)<>0'
              name: 'Hyper-V oldest snapshot has more than {$HYPERV.SNAPSHOTS.MAXAGE}'
              priority: AVERAGE
        - uuid: af794047f49a4d838e495e7edf9371b3
          name: 'HyperV Logical CPU Guest Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Logical Processor(_Total)\% Guest Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the processor in guest code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 18b35b2cde9f4ad89f3a3b82543dcb96
          name: 'HyperV Logical CPU Hypervisor Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Logical Processor(_Total)\% Hypervisor Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the processor in hypervisor code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 59655d1df7dc4e1aa10dea5df334f25e
          name: 'HyperV Logical CPU Idle Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Logical Processor(_Total)\% Idle Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the processor in an idle state.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
          triggers:
            - uuid: 171a9e7e43d14e1aba3150cc496682d7
              expression: 'avg(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor Logical Processor(_Total)\% Idle Time],#3)<10'
              name: 'HyperV Host Idle CPU < 10%'
              priority: AVERAGE
        - uuid: 711037b75dec4ffa88652e6d019f6134
          name: 'HyperV Root Virtual CPU Guest Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Root Virtual Processor(_Total)\% Guest Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor in guest code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: a70add860b6e459f9e65df12e7f6cee0
          name: 'HyperV Root Virtual CPU Hypervisor Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Root Virtual Processor(_Total)\% Hypervisor Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor in hypervisor code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: c5c34d1f70024380b726da7706f8f85c
          name: 'HyperV Root Virtual CPU Remote Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Root Virtual Processor(_Total)\% Remote Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor running on a remote node.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 86442b93b1e54175a26ab66eb395ef13
          name: 'HyperV Root Virtual CPU Total Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Root Virtual Processor(_Total)\% Total Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor in guest and hypervisor code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: d8e1af826fe14656b58fb1fb987debfc
          name: 'HyperV Virtual CPU Guest Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Virtual Processor(_Total)\% Guest Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor in guest code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: d604df9b5a7746ab808fa6519f7fbe54
          name: 'HyperV Virtual CPU Hypervisor Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Virtual Processor(_Total)\% Hypervisor Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor in hypervisor code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 51115671287d4399bcd157e19abe280d
          name: 'HyperV Virtual CPU Remote Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Virtual Processor(_Total)\% Remote Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor running on a remote node.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 77f4408c728246fdab45246c1de1cddc
          name: 'HyperV Virtual CPU Total Runtime %'
          key: 'perf_counter[\Hyper-V Hypervisor Virtual Processor(_Total)\% Total Run Time]'
          history: 30d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of time spent by the virtual processor in guest and hypervisor code.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 7b1d30f07b844c04ae5f0be614a8b9a2
          name: 'HyperV Number of Logical CPUs'
          key: 'perf_counter[\Hyper-V Hypervisor\Logical Processors]'
          delay: 5m
          history: 2w
          trends: 90d
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 3f957afe9cbf4e639418f68d167680a4
          name: 'HyperV Monitored Notifications'
          key: 'perf_counter[\Hyper-V Hypervisor\Monitored Notifications]'
          delay: 5m
          history: 2w
          trends: 90d
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 273eff013c0349e8837554a9ac9f9db2
          name: 'HyperV Number of Partitions (VMs)'
          key: 'perf_counter[\Hyper-V Hypervisor\Partitions]'
          delay: 5m
          history: 2w
          trends: 90d
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 08a7e6868aba45b998660259c3645748
          name: 'HyperV Total Pages'
          key: 'perf_counter[\Hyper-V Hypervisor\Total Pages]'
          delay: 5m
          history: 2w
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: d5a6abbf0e724170a4942c77021f51a0
          name: 'HyperV Number of Virtual CPUs'
          key: 'perf_counter[\Hyper-V Hypervisor\Virtual Processors]'
          delay: 5m
          history: 2w
          trends: 90d
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 3cb9a9ae78034f698b4dc57b7aff7b05
          name: 'HyperV VMs Critical'
          key: 'perf_counter[\Hyper-V Virtual Machine Health Summary\Health Critical]'
          history: 30d
          trends: 90d
          description: 'The number of critical VMs on a host.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
          triggers:
            - uuid: 789a715b8f504e9b87f8168779ffa746
              expression: 'last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Virtual Machine Health Summary\Health Critical])>0'
              name: 'Hyper-V host has critical VMs'
              priority: HIGH
              description: 'The number of VMs running in a critical state.'
        - uuid: 93b8c3f430d648cfabee92189d0590b2
          name: 'HyperV VMs OK'
          key: 'perf_counter[\Hyper-V Virtual Machine Health Summary\Health Ok]'
          history: 30d
          trends: 90d
          description: 'The number of OK VM''s on a host.'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
          triggers:
            - uuid: 33dded51b51542c09c2fc72a2702987d
              expression: 'last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Virtual Machine Health Summary\Health Ok])=0'
              name: 'Hyper-V host has 0 VMs in OK state'
              priority: WARNING
              description: 'Number of VMs in an OK state.'
        - uuid: 8c4c1e9cdb1e4dfa9868551026212cbb
          name: 'HyperV Virtual Switch B/s Received'
          key: 'perf_counter[\Hyper-V Virtual Switch(*)\Bytes Received/sec]'
          history: 30d
          value_type: FLOAT
          units: Bits/sec
          preprocessing:
            - type: MULTIPLIER
              parameters:
                - '8'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: 2c24ff61d3af48e9abba91556d674b30
          name: 'HyperV Virtual Switch B/s Sent'
          key: 'perf_counter[\Hyper-V Virtual Switch(*)\Bytes Sent/sec]'
          history: 30d
          value_type: FLOAT
          units: Bits/sec
          preprocessing:
            - type: MULTIPLIER
              parameters:
                - '8'
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'perf_counter{hyperion.normalisation.version="0"}'
        - uuid: ac24ccecabae4ecdaeb0929dba05f67e
          name: 'Number of VM with health Critical'
          key: 'perf_counter_en["\Hyper-V Virtual Machine Health Summary\Health Critical",]'
          delay: 5m
          history: 1d
          trends: '0'
          tags:
            - tag: norme
              value: 'perf_counter_en{hyperion.normalisation.version="0"}'
          triggers:
            - uuid: 2813764d703f43a5bcc45f4a97817ffc
              expression: 'last(/APP_Zbx_HyperV/perf_counter_en["\Hyper-V Virtual Machine Health Summary\Health Critical",]) <> 0'
              name: 'Some VM has critical health'
              priority: AVERAGE
        - uuid: 9b633c7cf28f4363a4036401a49a48f1
          name: 'Number of VM with health ok'
          key: 'perf_counter_en["\Hyper-V Virtual Machine Health Summary\Health OK",]'
          delay: 5m
          history: 1d
          trends: '0'
          tags:
            - tag: norme
              value: 'perf_counter_en{hyperion.normalisation.version="0"}'
        - uuid: 4c5f90ab7b214444801e899d33d4171f
          name: 'HyperV Service State'
          key: 'service.info[vmms]'
          delay: 5m
          history: 30d
          tags:
            - tag: Application
              value: 'HyperV Host'
            - tag: norme
              value: 'windows.service.status{service.name="W3SVC",hyperion.normalisation.version="1"}'
          triggers:
            - uuid: bd8c048e24d54eca89f052dc2c386910
              expression: 'last(/APP_Zbx_HyperV/service.info[vmms])<>0'
              name: 'HyperV service state'
              priority: HIGH
        - uuid: 488a9cfaff5e4b418adcd16348012500
          name: 'Get snapshots'
          key: 'wmi.getall[root\virtualization\v2,"select CreationTime,ElementName from Msvm_VirtualSystemSettingData where SuspendDataRoot Like ''Snapshots%''"]'
          delay: 1h
          history: 1d
          value_type: TEXT
          tags:
            - tag: norme
              value: 'wmi.getall{hyperion.normalisation.version="0"}'
      discovery_rules:
        - uuid: 5758f4ddbec74c1fb62ae13404112bb7
          name: 'Hyper-V Virtual Storage Device'
          key: 'perf_instance_en.discovery[Hyper-V Virtual Storage Device]'
          delay: 1h
          filter:
            conditions:
              - macro: '{#INSTANCE}'
                value: '.*vhdx'
          lifetime_type: DELETE_IMMEDIATELY
          item_prototypes:
            - uuid: 945c556944f9446a8924e0ce42cfdf50
              name: 'Hyper-V Virtual Storage Device {#INSTANCE} Read Bytes/sec'
              key: 'perf_counter_en[\Hyper-V Virtual Storage Device({#INSTANCE})\Read Bytes/sec,]'
              delay: 5m
              history: 1w
              value_type: FLOAT
              trends: 90d
              units: Bps
              tags:
                - tag: Application
                  value: 'Windows : Services : HyperV : Hyper-V Virtual Storage Device : {#INSTANCE}'
                - tag: norme
                  value: 'perf_counter_en{hyperion.normalisation.version="0"}'
            - uuid: 4450a4cb3ca34c67b78e154443972f67
              name: 'Hyper-V Virtual Storage Device {#INSTANCE} Write Bytes/sec'
              key: 'perf_counter_en[\Hyper-V Virtual Storage Device({#INSTANCE})\Write Bytes/sec,]'
              delay: 5m
              history: 1w
              value_type: FLOAT
              trends: 90d
              units: Bps
              tags:
                - tag: Application
                  value: 'Windows : Services : HyperV : Hyper-V Virtual Storage Device : {#INSTANCE}'
                - tag: norme
                  value: 'perf_counter_en{hyperion.normalisation.version="0"}'
        - uuid: 2f63232051ae4433b17f34d8436ffad1
          name: 'Windows services discovery'
          key: service.discovery
          delay: 1h
          filter:
            evaltype: FORMULA
            formula: '((A and B) or (C and D)) and (E and F)'
            conditions:
              - macro: '{#SERVICE.DISPLAYNAME}'
                value: '{$SERVICES.DISPLAYNAME.MATCHES}'
                formulaid: A
              - macro: '{#SERVICE.DISPLAYNAME}'
                value: '{$SERVICES.DISPLAYNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#SERVICE.NAME}'
                value: '{$SERVICE.NAME.MATCHES}'
                formulaid: C
              - macro: '{#SERVICE.NAME}'
                value: '{$SERVICE.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#SERVICE.STARTUPNAME}'
                value: '{$SERVICE.STARTUPNAME.MATCHES}'
                formulaid: E
              - macro: '{#SERVICE.STARTUPNAME}'
                value: '{$SERVICE.STARTUPNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
          item_prototypes:
            - uuid: 85a60f72ebb544a88c11f1470553cf16
              name: 'State of service "{#SERVICE.DISPLAYNAME}" ({#SERVICE.NAME})'
              key: 'service.info["{#SERVICE.NAME}",state]'
              history: 1w
              trends: '0'
              valuemap:
                name: 'Windows service state'
              tags:
                - tag: name
                  value: '{#SERVICE.DISPLAYNAME}'
                - tag: norme
                  value: 'service.info{service.name="{#SERVICE.NAME}",hyperion.normalisation.version="0"}'
                - tag: service
                  value: '{#SERVICE.NAME}'
              trigger_prototypes:
                - uuid: 622e420283694ef8847e299b6e3fa36c
                  expression: 'last(/APP_Zbx_HyperV/service.info["{#SERVICE.NAME}",state])=0'
                  name: 'State of service "{#SERVICE.DISPLAYNAME}" ({#SERVICE.NAME}) is not running'
                  priority: HIGH
      macros:
        - macro: '{$HYPERV.CPURATIO.HIGH}'
          value: '4'
        - macro: '{$HYPERV.CPURATIO.WARN}'
          value: '3'
        - macro: '{$HYPERV.SNAPSHOTS.MAX}'
          value: '14'
        - macro: '{$HYPERV.SNAPSHOTS.MAXAGE}'
          value: 7d
        - macro: '{$REGEXP_SERVICES}'
          value: '(.*Hyper-V.*)|(Cluster Service)|(Service de cluster)|(.*Veeam.*)'
      valuemaps:
        - uuid: c5e2e67d6d3749b5b1f77b791d74cd49
          name: 'Windows service state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Paused
            - value: '2'
              newvalue: 'Start pending'
            - value: '3'
              newvalue: 'Pause pending'
            - value: '4'
              newvalue: 'Continue pending'
            - value: '5'
              newvalue: 'Stop pending'
            - value: '6'
              newvalue: Stopped
            - value: '7'
              newvalue: Unknown
            - value: '255'
              newvalue: 'No such service'
  triggers:
    - uuid: e47dbc41e246477db8527e0ba42f5e19
      expression: 'last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor\Virtual Processors])/last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor\Logical Processors])>{$HYPERV.CPURATIO.HIGH}'
      name: 'Hyper-V Virtual to Logical CPU Ratio > {$HYPERV.CPURATIO.HIGH}:1'
      priority: AVERAGE
    - uuid: ee8471a49a814e689af82750c560ea9f
      expression: 'last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor\Virtual Processors])/last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor\Logical Processors])>{$HYPERV.CPURATIO.WARN}'
      name: 'Hyper-V Virtual to Logical CPU Ratio > {$HYPERV.CPURATIO.WARN}:1'
      priority: WARNING
      dependencies:
        - name: 'Hyper-V Virtual to Logical CPU Ratio > {$HYPERV.CPURATIO.HIGH}:1'
          expression: 'last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor\Virtual Processors])/last(/APP_Zbx_HyperV/perf_counter[\Hyper-V Hypervisor\Logical Processors])>{$HYPERV.CPURATIO.HIGH}'
