Ad Widget

Collapse

Template import failed for zbx-smartctl on Zabbix 6.4

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Uruno187
    Junior Member
    • Oct 2023
    • 5

    #1

    Template import failed for zbx-smartctl on Zabbix 6.4

    I am trying to set up SMART disk monitoring on a FreeBSD host with Zabbix 6.4.
    Since Zabbix Agent 2 with built-in SMART monitoring features isn't available on FreeBSD, I decided to use this solution: https://github.com/v-zhuravlev/zbx-smartctl
    But when I try to import the template (Template_3.4_HDD_SMARTMONTOOLS_2_WITH_LLD.xml), it fails with the following error:
    Code:
    Import failed
    Invalid parameter "/9/preprocessing/1/params/1": invalid regular expression.
    It doesn't say which line causes the error and provides no additional details, so I don't know where to look.
    How can I get it to work?​
  • Answer selected by Uruno187 at 28-10-2023, 11:55.
    Uruno187
    Junior Member
    • Oct 2023
    • 5

    Originally posted by cyber
    But if you change that regex now back to original after you managed to import it? Will it throw an error or will it be OK?
    Yes, it throws the same error for both of them.
    But if i change the original regex
    Code:
    (?:194 Temperature[^(\n]+|Airflow_Temperature[^(\n]+|Drive Temperature:|Temperature:) +([0-9]+)
    to
    Code:
    (?:194 Temperature[^\n]+|Airflow_Temperature[^\n]+|Drive Temperature:|Temperature:) +([0-9]+)
    (removed the bracket in [^(\n] block)
    it doesn't throw any error, but doesn't work either.
    So, I decided to escape the brackets in the original regex like this:
    Code:
    <params>(?:194 Temperature[^\(\n]+|Airflow_Temperature[^\(\n]+|Drive Temperature:|Temperature:) +([0-9]+)
    \1</params>​
    And imported the template again. It worked. And it reads the temperatures just fine.
    So, for a conclusion: Zabbix 6.4 requires to escape the brackets in regular expressions. That was the cause of the problem.



    Last edited by Uruno187; 27-10-2023, 14:59.

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #2
      With 6.0 imported nicely without any errors...
      I re-exported it in yaml... maybe it will work better for you ?
      Attached Files

      Comment

      • Uruno187
        Junior Member
        • Oct 2023
        • 5

        #3
        Originally posted by cyber
        With 6.0 imported nicely without any errors...
        I re-exported it in yaml... maybe it will work better for you ?
        No, same error. Is there a way to know where exactly is the cause of the error?
        I tried to import the template on another Zabbix server running version 5.4. It worked there. I then tried to export from there in various formats then import on 6.4, no luck, still the same error. I think there's some changes in how 6.4 handles reqular expressions.
        Last edited by Uruno187; 26-10-2023, 14:51.

        Comment

        • Uruno187
          Junior Member
          • Oct 2023
          • 5

          #4
          I was able to figure out what Zabbix 6.4 doesn't like in the template. It's this block that causes the error.
          Code:
          <preprocessing>
             <step>
                 <type>5</type>
                 <params>(?:194 Temperature[^(\n]+|Airflow_Temperature[^(\n]+|Drive Temperature:|Temperature:) +([0-9]+)
              \1</params>
             </step>
          </preprocessing>​

          Can someone point out what can be wrong there?

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4807

            #5
            I was about to suggest the same place... Just by going with gut feeling that "/9/preprocessing/1/params/1" means 9th occurrence of preprocessing
            Code:
                          preprocessing:
                            - type: REGEX
                              parameters:
                                - '(?:194 Temperature[^(\n]+|Airflow_Temperature[^(\n]+|Drive Temperature:|Temperature:) +([0-9]+)'
                                - \1​

            This one... does not look like anything is bad here..
            But I got hold of one 7.0 instance.. it fails to import there also..

            Comment

            • Uruno187
              Junior Member
              • Oct 2023
              • 5

              #6
              Since all my drives have the same attribute "194 Temperature_Celsius", I decided to alter the regex just to this:
              Code:
              <params>194 Temperature_Celsius.+ ([0-9]+)
              \1</params>​
              And then the template imported successfully, but I've faced another problem: various HDDs report their temperature in various ways:
              Code:
              WD: 194 Temperature_Celsius     0x0022   105   100   000    Old_age   Always       -       42
              Seagate: 194 Temperature_Celsius     0x0022   034   053   000    Old_age   Always       -       34 (0 16 0 0 0)
              Toshiba: 194 Temperature_Celsius     0x0002   122   122   000    Old_age   Always       -      49 (Min/Max 15/57)​
              So, that regex works well only with WD which RAW_VALUE is only the current temperature and nothing else.
              But with other drives it fails because of the extra info in RAW_VALUE.
              I.e. for Seagate it outputs 0, and for Toshiba it outputs 15.
              So, I decided to look for a parameter which would make smartctl to show only the current temperature in RAW_VALUE.
              And I came up with this: -v 194,raw16
              So the line in UserParameter would look like this:
              Code:
              UserParameter=uHDD.get[*],sudo smartctl -i -H -A -l error -l background $1 -v 194,raw16 || true
              instead of
              Code:
              UserParameter=uHDD.get[*],sudo smartctl -i -H -A -l error -l background $1 || true
              This way it outputs like this:
              Code:
              194 Temperature_Celsius     0x0002   122   122   000    Old_age   Always       -       57 15 49
              It outputs three numbers where the last number is the current temperature, and the regex catches it just fine.
              And it works the same for all my drives.
              So my problem is solved now.
              Last edited by Uruno187; 27-10-2023, 14:09.

              Comment

              • cyber
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Dec 2006
                • 4807

                #7
                But if you change that regex now back to original after you managed to import it? Will it throw an error or will it be OK?
                Original will work as expected with all of them..
                Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.


                You just removed a bit too much .. "(?:194 Temperature[^(\n]+) ([0-9]+)" should work https://regex101.com/r/uZH5zY/1

                Comment

                • Uruno187
                  Junior Member
                  • Oct 2023
                  • 5

                  #8
                  Originally posted by cyber
                  But if you change that regex now back to original after you managed to import it? Will it throw an error or will it be OK?
                  Yes, it throws the same error for both of them.
                  But if i change the original regex
                  Code:
                  (?:194 Temperature[^(\n]+|Airflow_Temperature[^(\n]+|Drive Temperature:|Temperature:) +([0-9]+)
                  to
                  Code:
                  (?:194 Temperature[^\n]+|Airflow_Temperature[^\n]+|Drive Temperature:|Temperature:) +([0-9]+)
                  (removed the bracket in [^(\n] block)
                  it doesn't throw any error, but doesn't work either.
                  So, I decided to escape the brackets in the original regex like this:
                  Code:
                  <params>(?:194 Temperature[^\(\n]+|Airflow_Temperature[^\(\n]+|Drive Temperature:|Temperature:) +([0-9]+)
                  \1</params>​
                  And imported the template again. It worked. And it reads the temperatures just fine.
                  So, for a conclusion: Zabbix 6.4 requires to escape the brackets in regular expressions. That was the cause of the problem.



                  Last edited by Uruno187; 27-10-2023, 14:59.

                  Comment

                  Working...