zabbix_export:
  version: '7.0'
  host_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Applications
  hosts:
    - host: PLCRBG01
      name: PLCRBG01
      templates:
        - name: PLCYYXX
      groups:
        - name: Applications
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'OPCUAServer/PLCRBG01/#'
      inventory_mode: DISABLED
    - host: PLCSTAT
      name: PLCSTAT
      templates:
        - name: PLCYYXX
      groups:
        - name: Applications
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'OPCUAServer/PLCSTAT/#'
      inventory_mode: DISABLED
    - host: RBG01
      name: RBG01
      templates:
        - name: RBGXX
      groups:
        - name: Applications
      inventory_mode: DISABLED
    - host: RBG01_Alarm
      name: RBG01_Alarm
      groups:
        - name: Applications
      items:
        - name: Alarm.Active
          type: DEPENDENT
          key: Alarm.Active
          delay: '0'
          value_type: FLOAT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
        - name: Alarm.ActiveTime
          type: DEPENDENT
          key: Alarm.ActiveTime
          delay: '0'
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.activetime
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
        - name: Alarm.ReceiveTime
          type: DEPENDENT
          key: Alarm.ReceiveTime
          delay: '0'
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.receivetime
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
        - name: Alarm.Text
          type: DEPENDENT
          key: Alarm.Text
          delay: '0'
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.text
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
        - name: Alarm.Time
          type: DEPENDENT
          key: Alarm.Time
          delay: '0'
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.time
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
        - name: DEVICE_MQTT
          type: ZABBIX_ACTIVE
          key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
      macros:
        - macro: '{$MQTTTOPIC}'
          value: Alarm/RBG01
        - macro: '{$MQTT_BROKER}'
          value: 10.83.170.106
        - macro: '{$MQTT_PASS}'
          value: cti123
        - macro: '{$MQTT_USER}'
          value: cti
      inventory_mode: DISABLED
    - host: TestMqtt
      name: TestMqtt
      templates:
        - name: 'Zabbix agent active'
      groups:
        - name: Applications
      interfaces:
        - port: '10052'
          interface_ref: if1
      items:
        - name: SQL01
          type: ODBC
          key: 'db.odbc.get[MSSQL01,CTIMSSQL01]'
          history: 90d
          value_type: TEXT
          trends: '0'
          status: DISABLED
          params: |
            SELECT TOP(1) * 
            FROM DeviceOrderHistoryNEW
            WHERE ReadState IS NULL
            ORDER BY StartDate DESC
            
            UPDATE DeviceOrderHistoryNEW 
            SET ReadState = 1
            WHERE DeviceOrderHistoryId = (SELECT TOP 1 DeviceOrderHistoryId 
            FROM DeviceOrderHistoryNEW
            WHERE ReadState IS NULL
            ORDER BY StartDate DESC)
          username: sa
          password: '@Tramrail1962@'
        - name: RBG12
          type: ZABBIX_ACTIVE
          key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const myArray = value.split("/");
                  const myWord = myArray[0] + "/";
                  const padded = myWord.slice(-myWord.length+2);
                  const out = value.replace(padded,"");
                  return out;
                  
        - name: RBG01
          type: ZABBIX_ACTIVE
          key: 'mqtt.get[{$MQTT_BROKER},{$RBG01},{$MQTT_USER},{$MQTT_PASS}]'
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
        - name: RBG11
          type: ZABBIX_ACTIVE
          key: 'mqtt.get[{$MQTT_BROKER},{$RBG11},{$MQTT_USER},{$MQTT_PASS}]'
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
        - name: Ocupation
          type: DEPENDENT
          key: Ocupation
          delay: '0'
          history: 90d
          valuemap:
            name: ToBoolean
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.*'
            - type: STR_REPLACE
              parameters:
                - \
                - ''
            - type: STR_REPLACE
              parameters:
                - '["'
                - ''
            - type: STR_REPLACE
              parameters:
                - ']"'
                - ''
            - type: JSONPATH
              parameters:
                - $.Ocupation
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
            - type: DISCARD_UNCHANGED
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01},{$MQTT_USER},{$MQTT_PASS}]'
          triggers:
            - expression: last(/TestMqtt/Ocupation)=1
              name: 'Ocupation is true'
              status: DISABLED
              priority: INFO
        - name: Position_Drive
          type: DEPENDENT
          key: Position_Drive
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.*'
            - type: STR_REPLACE
              parameters:
                - \
                - ''
            - type: STR_REPLACE
              parameters:
                - '["'
                - ''
            - type: STR_REPLACE
              parameters:
                - ']"'
                - ''
            - type: JSONPATH
              parameters:
                - $.Position_Drive
            - type: DISCARD_UNCHANGED
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01},{$MQTT_USER},{$MQTT_PASS}]'
        - name: Position_Lift
          type: DEPENDENT
          key: Position_Lift
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.*'
            - type: STR_REPLACE
              parameters:
                - \
                - ''
            - type: STR_REPLACE
              parameters:
                - '["'
                - ''
            - type: STR_REPLACE
              parameters:
                - ']"'
                - ''
            - type: JSONPATH
              parameters:
                - $.Position_Lift
            - type: DISCARD_UNCHANGED
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01},{$MQTT_USER},{$MQTT_PASS}]'
        - name: Position_Table
          type: DEPENDENT
          key: Position_Table
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.*'
            - type: STR_REPLACE
              parameters:
                - \
                - ''
            - type: STR_REPLACE
              parameters:
                - '["'
                - ''
            - type: STR_REPLACE
              parameters:
                - ']"'
                - ''
            - type: JSONPATH
              parameters:
                - $.Position_Lift
            - type: DISCARD_UNCHANGED
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG11.Ocupation
          type: DEPENDENT
          key: RBG11.Ocupation
          delay: '0'
          history: 90d
          valuemap:
            name: ToBoolean
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["SPSRBG/RBG11/Ocupation"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG11},{$MQTT_USER},{$MQTT_PASS}]'
          triggers:
            - expression: last(/TestMqtt/RBG11.Ocupation)=1
              name: 'Ocupation is true 11'
              status: DISABLED
              priority: INFO
        - name: RBG11.Position_Drive
          type: DEPENDENT
          key: RBG11.Position_Drive
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["SPSRBG/RBG11/Position_Drive"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG11},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG11.Position_Lift
          type: DEPENDENT
          key: RBG11.Position_Lift
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["SPSRBG/RBG11/Position_Lift"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG11},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG11.Position_Table
          type: DEPENDENT
          key: RBG11.Position_Table
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["SPSRBG/RBG11/Position_Table"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG11},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Energy.Consumtion.LastMove
          type: CALCULATED
          key: RBG12.Energy.Consumtion.LastMove
          params: '1925'
          description: 'No real value'
        - name: RBG12.Energy.Consumtion.LastYear
          type: CALCULATED
          key: RBG12.Energy.Consumtion.LastYear
          params: '19478245'
          description: 'No real value'
        - name: RBG12.Movements
          type: CALCULATED
          key: RBG12.Movements
          history: 90d
          params: '1 + rand() / 10000 / 10000'
        - name: RBG12.OEE.Availability
          type: CALCULATED
          key: RBG12.OEE.Availability
          value_type: FLOAT
          params: '94.89'
          description: 'No real value'
        - name: RBG12.OEE.OEE
          type: CALCULATED
          key: RBG12.OEE.OEE
          value_type: FLOAT
          params: '65.19'
          description: 'No real value'
        - name: RBG12.OEE.Performance
          type: CALCULATED
          key: RBG12.OEE.Performance
          value_type: FLOAT
          params: '84.91'
          description: 'No real value'
        - name: RBG12.OEE.Quality
          type: CALCULATED
          key: RBG12.OEE.Quality
          value_type: FLOAT
          params: '80.91'
          description: 'No real value'
        - name: RBG12.Order-Base.Cancel
          type: DEPENDENT
          key: RBG12.Order-Base.Cancel
          delay: '0'
          history: 90d
          valuemap:
            name: ToBoolean
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Cancel"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Handshake
          type: DEPENDENT
          key: RBG12.Order-Base.Handshake
          delay: '0'
          history: 90d
          valuemap:
            name: ToBoolean
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Handshake"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.IN.Coordinate_N
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.IN.Coordinate_N
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.IN.Coordinate_N"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.IN.Coordinate_T
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.IN.Coordinate_T
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.IN.Coordinate_T"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.IN.Coordinate_X
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.IN.Coordinate_X
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.IN.Coordinate_X"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.IN.Coordinate_Y
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.IN.Coordinate_Y
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.IN.Coordinate_Y"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.IN.Coordinate_Z
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.IN.Coordinate_Z
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.IN.Coordinate_Z"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.OUT.Acknowledgement_Code
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.OUT.Acknowledgement_Code
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.OUT.Acknowledgement_Code"]'
              error_handler: DISCARD_VALUE
            - type: JAVASCRIPT
              parameters:
                - |
                  const invalue = value.trim();
                  if (typeof invalue === "string" && invalue.length !== 5) {
                    return "--";
                  }
                  if (invalue === null) {
                    return "--";
                  }
                  if (isNaN(invalue)) {
                    return "--";
                  }
                  const firstCharCode = (invalue & 0x0000FF00) >> 8;
                  const firstChar = String.fromCharCode(firstCharCode);
                  const secondCharCode = invalue & 0x000000FF;
                  const secondChar = String.fromCharCode(secondCharCode);
                  const result = firstChar + secondChar;
                  return result;
                  
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
          triggers:
            - expression: 'last(/TestMqtt/RBG12.Order-Base.Order_DataSet.OUT.Acknowledgement_Code)="--"'
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: 'last(/TestMqtt/RBG12.Order-Base.Order_DataSet.OUT.Acknowledgement_Code)<>"--"'
              name: AckCodeChanged
              priority: INFO
        - name: RBG12.Order-Base.Order_DataSet.OUT.HeightType
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.OUT.HeightType
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.OUT.HeightType"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Base.Order_DataSet.OUT.PalletType
          type: DEPENDENT
          key: RBG12.Order-Base.Order_DataSet.OUT.PalletType
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Base.Order_DataSet.OUT.PalletType"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Ext.In.DepthCorrection
          type: DEPENDENT
          key: RBG12.Order-Ext.In.DepthCorrection
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Ext.In.DepthCorrection"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.Order-Ext.In.PositionType
          type: DEPENDENT
          key: RBG12.Order-Ext.In.PositionType
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Order-Ext.In.PositionType"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Engine_Working_Drive
          type: DEPENDENT
          key: RBG12.State.Engine_Working_Drive
          delay: '0'
          history: 90d
          valuemap:
            name: WorkingStateToYES
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Engine_Working_Drive"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Engine_Working_Lift
          type: DEPENDENT
          key: RBG12.State.Engine_Working_Lift
          delay: '0'
          history: 90d
          valuemap:
            name: WorkingStateToYES
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Engine_Working_Lift"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Engine_Working_Table
          type: DEPENDENT
          key: RBG12.State.Engine_Working_Table
          delay: '0'
          history: 90d
          valuemap:
            name: WorkingStateToYES
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Engine_Working_Table"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Error_Drive
          type: DEPENDENT
          key: RBG12.State.Error_Drive
          delay: '0'
          history: 90d
          valuemap:
            name: ErrorStateToOK
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Error_Drive"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Error_Lift
          type: DEPENDENT
          key: RBG12.State.Error_Lift
          delay: '0'
          history: 90d
          valuemap:
            name: ErrorStateToOK
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Error_Lift"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Error_Table
          type: DEPENDENT
          key: RBG12.State.Error_Table
          delay: '0'
          history: 90d
          valuemap:
            name: ErrorStateToOK
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Error_Table"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Fault
          type: DEPENDENT
          key: RBG12.State.Fault
          delay: '0'
          history: 90d
          valuemap:
            name: ErrorStateToOK
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Fault"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Initial_Position
          type: DEPENDENT
          key: RBG12.State.Initial_Position
          delay: '0'
          history: 90d
          valuemap:
            name: ToBoolean
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Initial_Position"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Ocupation
          type: DEPENDENT
          key: RBG12.State.Ocupation
          delay: '0'
          history: 90d
          valuemap:
            name: OccupationStateToYES
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Ocupation"]'
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
              parameters:
                - ''
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
          triggers:
            - expression: last(/TestMqtt/RBG12.State.Ocupation)=1
              name: 'Ocupation is true 12'
              priority: INFO
        - name: RBG12.State.Operating_Mode
          type: CALCULATED
          key: RBG12.State.Operating_Mode
          history: 90d
          params: '1'
          valuemap:
            name: OperatingMode
        - name: RBG12.State.Operating_Mode_Drive
          type: CALCULATED
          key: RBG12.State.Operating_Mode_Drive
          history: 90d
          params: '4'
          valuemap:
            name: OperatingModeDrive
        - name: RBG12.State.Position_Drive
          type: DEPENDENT
          key: RBG12.State.Position_Drive
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Position_Drive"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Position_Lift
          type: DEPENDENT
          key: RBG12.State.Position_Lift
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Position_Lift"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.State.Position_Table
          type: DEPENDENT
          key: RBG12.State.Position_Table
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["State.Position_Table"]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$RBG01SHORT},{$MQTT_USER},{$MQTT_PASS}]'
        - name: RBG12.TestPush
          type: TRAP
          key: RBG12.TestPush
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
        - name: RBG12.TotalDistanceX
          type: CALCULATED
          key: RBG12.TotalDistanceDrive
          units: m
          params: '1 + rand() / 20000'
          description: 'Not a real calculation!'
        - name: SimulatorRand
          type: CALCULATED
          key: SimulatorRand
          params: '1 + rand() / 100000'
        - name: SimulatorRand2
          type: CALCULATED
          key: SimulatorRand2
          params: '2 + rand() / 200000'
        - name: SimulatorRand3
          type: CALCULATED
          key: SimulatorRand3
          params: '3 + rand() / 300000'
        - name: SQL01.ACKValue
          type: DEPENDENT
          key: SQL01.ACKValue
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].ACKValue'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.AvgOrderDuration3y
          type: CALCULATED
          key: SQL01.AvgOrderDuration3y
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          params: 'avg(/TestMqtt/SQL01.Duration,1095d)'
        - name: SQL01.DepoCount
          type: CALCULATED
          key: SQL01.DepoCount
          params: 'count(/TestMqtt/SQL01.TuOrderTypeName,1200d,"like","Depo")'
        - name: SQL01.DeviceId
          type: DEPENDENT
          key: SQL01.DeviceId
          delay: '0'
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DeviceId'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DeviceName
          type: DEPENDENT
          key: SQL01.DeviceName
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DeviceName'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DstCoordN
          type: DEPENDENT
          key: SQL01.DstCoordN
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DstCoordN'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DstCoordT
          type: DEPENDENT
          key: SQL01.DstCoordT
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DstCoordT'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DstCoordX
          type: DEPENDENT
          key: SQL01.DstCoordX
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DstCoordX'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DstCoordY
          type: DEPENDENT
          key: SQL01.DstCoordY
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DstCoordY'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DstCoordZ
          type: DEPENDENT
          key: SQL01.DstCoordZ
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DstCoordZ'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.DstName
          type: DEPENDENT
          key: SQL01.DstName
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].DstName'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.Duration
          type: DEPENDENT
          key: SQL01.Duration
          delay: '0'
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].Duration'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.EndDate
          type: DEPENDENT
          key: SQL01.EndDate
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].EndDate'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.PickCount
          type: CALCULATED
          key: SQL01.PickCount
          params: 'count(/TestMqtt/SQL01.TuOrderTypeName,1200d,"like","Pick")'
        - name: SQL01.SrcCoordN
          type: DEPENDENT
          key: SQL01.SrcCoordN
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].SrcCoordN'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.SrcCoordT
          type: DEPENDENT
          key: SQL01.SrcCoordT
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].SrcCoordT'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.SrcCoordX
          type: DEPENDENT
          key: SQL01.SrcCoordX
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].SrcCoordX'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.SrcCoordY
          type: DEPENDENT
          key: SQL01.SrcCoordY
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].SrcCoordY'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.SrcCoordZ
          type: DEPENDENT
          key: SQL01.SrcCoordZ
          delay: '0'
          history: 1095d
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].SrcCoordZ'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.SrcName
          type: DEPENDENT
          key: SQL01.SrcName
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].SrcName'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.StartDate
          type: DEPENDENT
          key: SQL01.StartDate
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].StartDate'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.TuOrderId
          type: DEPENDENT
          key: SQL01.TuOrderId
          delay: '0'
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].TuOrderId'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.TuOrderTypeId
          type: DEPENDENT
          key: SQL01.TuOrderTypeId
          delay: '0'
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].TuOrderTypeId'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.TuOrderTypeName
          type: DEPENDENT
          key: SQL01.TuOrderTypeName
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].TuOrderTypeName'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.WmsOrderId
          type: DEPENDENT
          key: SQL01.WmsOrderId
          delay: '0'
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].WmsOrderId'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.WmsOrderTypeId
          type: DEPENDENT
          key: SQL01.WmsOrderTypeId
          delay: '0'
          history: 1095d
          value_type: FLOAT
          trends: 1095d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].WmsOrderTypeId'
          master_item:
            key: RBG12.TestPush
        - name: SQL01.WmsOrderTypename
          type: DEPENDENT
          key: SQL01.WmsOrderTypename
          delay: '0'
          history: 1095d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[0].WmsOrderTypename'
          master_item:
            key: RBG12.TestPush
        - name: 'Total Memory'
          key: 'vm.memory.size[total]'
          history: 90d
          units: B
          interface_ref: if1
      macros:
        - macro: '{$DEVICE1}'
          value: RBG12
        - macro: '{$MQTT_BROKER}'
          value: 10.83.170.10
        - macro: '{$MQTT_PASS}'
          value: cti123
        - macro: '{$MQTT_SERVER_TCP}'
          value: 10.83.170.10
        - macro: '{$MQTT_TOPIC}'
          value: '#'
        - macro: '{$MQTT_USER}'
          value: cti
        - macro: '{$MSSQL.DSN}'
          value: CTIMSSQL01
        - macro: '{$MSSQL.PASSWORD}'
          value: sa
        - macro: '{$MSSQL.USER}'
          value: '@Tramrail1962@'
        - macro: '{$RBG01}'
          value: 'SPSRBG/RBG01/#'
        - macro: '{$RBG01SHORT}'
          value: 'RBG01/#'
        - macro: '{$RBG11}'
          value: 'SPSRBG/RBG11/#'
      inventory_mode: DISABLED
      valuemaps:
        - name: ErrorStateToOK
          mappings:
            - value: '1'
              newvalue: ERROR
            - value: '0'
              newvalue: OK
        - name: OccupationStateToYES
          mappings:
            - value: '1'
              newvalue: 'YES'
            - value: '0'
              newvalue: 'NO'
        - name: OperatingMode
          mappings:
            - value: '1'
              newvalue: AUTO
            - value: '0'
              newvalue: UNDEF
            - value: '2'
              newvalue: MANU
        - name: OperatingModeDrive
          mappings:
            - value: '4'
              newvalue: AUTO
            - value: '0'
              newvalue: UNDEF
            - value: '3'
              newvalue: MANU
        - name: ToBoolean
          mappings:
            - value: '1'
              newvalue: 'TRUE'
            - value: '0'
              newvalue: 'FALSE'
        - name: WorkingStateToYES
          mappings:
            - value: '1'
              newvalue: 'YES'
            - value: '0'
              newvalue: 'NO'
    - host: TestMqtt2
      name: TestMqtt2
      templates:
        - name: 'Zabbix agent active'
      groups:
        - name: Applications
      interfaces:
        - port: '10052'
          interface_ref: if1
      items:
        - name: Counter
          type: DEPENDENT
          key: Counter
          delay: '0'
          history: 90d
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.["Counter"]'
              error_handler: DISCARD_VALUE
            - type: JSONPATH
              parameters:
                - $.value
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
          tags:
            - tag: Group
              value: Index
            - tag: Group
              value: Interface
        - name: DEVICE_MQTT
          type: ZABBIX_ACTIVE
          key: 'mqtt.get[{$MQTT_BROKER},{$MQTTTOPIC},{$MQTT_USER},{$MQTT_PASS}]'
          delay: '0'
          history: 90d
          value_type: TEXT
          trends: '0'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const myArray = value.split("/");
                  const myWord = myArray[0] + "/";
                  const padded = myWord.slice(-myWord.length+2);
                  const out = value.replace(padded,"");
                  return out;
                  
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'RockwellTest/#'
        - macro: '{$MQTT_BROKER}'
          value: 10.83.170.106
        - macro: '{$MQTT_PASS}'
          value: cti123
        - macro: '{$MQTT_USER}'
          value: cti
      inventory_mode: DISABLED
    - host: VSW01
      name: VSW01
      templates:
        - name: VSWXX
      groups:
        - name: Applications
      interfaces:
        - port: '10052'
          interface_ref: if1
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'VSW01/#'
        - macro: '{$MQTT_BROKER}'
          value: 10.83.170.106
        - macro: '{$MQTT_PASS}'
          value: cti123
        - macro: '{$MQTT_USER}'
          value: cti
      inventory_mode: DISABLED
      valuemaps:
        - name: ErrorState
          mappings:
            - value: '1'
              newvalue: ERROR
            - value: '0'
              newvalue: OK
        - name: OccupationState
          mappings:
            - value: '1'
              newvalue: 'YES'
            - value: '0'
              newvalue: 'NO'
        - name: OperatingMode
          mappings:
            - value: '0'
              newvalue: UNDEF
            - value: '1'
              newvalue: AUTO
            - value: '2'
              newvalue: MANU
            - value: '3'
              newvalue: MAIN
            - value: '5'
              newvalue: NOP
            - value: '6'
              newvalue: SEMI
        - name: OperatingModeDrive
          mappings:
            - value: '0'
              newvalue: UNDEF
            - value: '3'
              newvalue: MANU
            - value: '4'
              newvalue: AUTO
        - name: ToBooleanGeneral
          mappings:
            - value: '0'
              newvalue: 'FALSE'
            - value: '1'
              newvalue: 'TRUE'
        - name: ToYESNOGeneral
          mappings:
            - value: '0'
              newvalue: 'NO'
            - value: '1'
              newvalue: 'YES'
    - host: VSW02
      name: VSW02
      templates:
        - name: VSWXX
      groups:
        - name: Applications
      interfaces:
        - port: '10052'
          interface_ref: if1
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'VSW02/#'
      inventory_mode: DISABLED
    - host: VSW03
      name: VSW03
      templates:
        - name: VSWXX
      groups:
        - name: Applications
      interfaces:
        - port: '10052'
          interface_ref: if1
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'VSW03/#'
      inventory_mode: DISABLED
    - host: VSW04
      name: VSW04
      templates:
        - name: VSWXX
      groups:
        - name: Applications
      interfaces:
        - port: '10052'
          interface_ref: if1
      macros:
        - macro: '{$MQTTTOPIC}'
          value: 'VSW04/#'
      inventory_mode: DISABLED
  triggers:
    - expression: 'last(/RBG01_Alarm/Alarm.Text)="PLC : Device 2 : My array alarm element 22" and last(/RBG01_Alarm/Alarm.Active)=1'
      recovery_mode: RECOVERY_EXPRESSION
      recovery_expression: 'last(/RBG01_Alarm/Alarm.Text)="PLC : Device 2 : My array alarm element 22" and last(/RBG01_Alarm/Alarm.Active)=0'
      name: 'PLC : Device 2 : My array alarm element 22'
      priority: AVERAGE
  graphs:
    - name: AllItems
      graph_items:
        - color: 199C0D
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: Ocupation
        - sortorder: '1'
          color: F63100
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: Position_Drive
        - sortorder: '2'
          color: 2774A4
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: Position_Lift
        - sortorder: '3'
          color: F7941D
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: Position_Table
    - name: AllItems11
      graph_items:
        - color: 199C0D
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG11.Ocupation
        - sortorder: '1'
          color: F63100
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG11.Position_Drive
        - sortorder: '2'
          color: 2774A4
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG11.Position_Lift
        - sortorder: '3'
          color: F7941D
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG11.Position_Table
    - name: AllItems12
      graph_items:
        - color: 199C0D
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG12.State.Ocupation
        - sortorder: '1'
          color: 2774A4
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG12.State.Position_Lift
        - sortorder: '2'
          color: FFBF00
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG12.State.Position_Table
        - sortorder: '3'
          color: FF4000
          calc_fnc: ALL
          item:
            host: TestMqtt
            key: RBG12.State.Position_Drive
