Ad Widget

Collapse

Hikvision Template Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • highpeak
    Member
    • Nov 2019
    • 30

    #1

    Hikvision Template Error

    We're trying to use the official Hikvision camera template: https://git.zabbix.com/projects/ZBX/...at=release/5.4

    This template fills the proxy logs with

    Code:
    noname.xml:1: noname.xml:1: parser parser error : Start tag expected, '<' not found
    {"html":{"head":{"title":"Connection error"}}}
    This is clearly something to do with the preprocessing of the item hikvision_cam.get_info

    Preprocessing:

    - CHECK_NOT_SUPPORTED: </p><p>⛔️ON_FAIL: `CUSTOM_VALUE -> {"html":{"head":{"title":"Connection error"}}}`</p><p>-
    XML_TO_JSON: ⛔️ON_FAIL: CUSTOM_VALUE -> {"html":{"head":{"title":"Connection error"}}}

    From what I can see, "on fail" is setting the custom value as JSON, but the proxy is still trying to process the output as XML and failing.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    #2
    Maybe you are getting back "Connection error" and no result to parse by preprocessing? Verify, that you are getting correct result back.

    Comment

    • highpeak
      Member
      • Nov 2019
      • 30

      #3
      Click image for larger version

Name:	2022-01-24_15-19-33.png
Views:	1658
Size:	85.6 KB
ID:	438575
      What would constitute an "unsupported value:" in this case? It's an HTTP agent check.

      When I run the check in Postman I get the following response:
      Code:
      <!DOCTYPE html>
      <html>
      <head>
      <title>Document Error: Unauthorized</title>
      </head>
      <body>
      <h2>Access Error: 401 -- Unauthorized</h2>
      <p>Authentication Error</p>
      </body>
      </html>


      Also, why is the proxy log not showing a timestamp or any other data on the parser error, just this dump of text into the log? There's no data on which host or which item is causing the error.

      Attached Files

      Comment

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

        #4
        Check for not supported value Check if there was an error in retrieving item value. Normally that would lead to the item turning unsupported, but you may modify that behavior by specifying the Custom on fail error-handling options: to discard the value, to set a specified value (in this case the item will stay supported and the value can be used in triggers) or set a specified error message. Note that for this preprocessing step, the Custom on fail checkbox is grayed out and always marked.
        This step is always executed as the first preprocessing step and is placed above all others after saving changes to the item. It can be used only once.
        Supported since 5.2.0.
        As you get "Unathorized" as answer. that would normally turn your item to "not supported", but now it has "set value to" ... I guess you should fix your connection error at first..

        Comment

        • highpeak
          Member
          • Nov 2019
          • 30

          #5
          I don't need to fix my connection error, it's deliberately "unauthorised" to test the failure condition. The problem I have is:

          1. The proxy trying to parse the "set value to" when it should not be.
          2. The fact that the error message contains no log level, timestamp host id, item id/key or any other usual logging info
          3. This template comes directly from the official Zabbix repo

          Comment

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

            #6
            The problem I have is: 1. The proxy trying to parse the "set value to" when it should not be.
            Whoever created that template clearly did not consider, that if "custom on fail" is set, then preprocessing continues.

            An item will become unsupported if any of the preprocessing steps fails, unless custom error handling has been specified using a Custom on fail option for supported transformations.
            So, in this case it is natural, that if first step fails and sets some kind of json as error message, then preprocessing continues with step 2 and, if that is "XML to JSON", it will fail again ("Start tag expected, '<' not found") as now the data is replaced with that error message and is clearly not XML. And then it is setting error message again. I think, if you edit it and set that first "custom on fail" to somekind of XML, second one will not fail, but converts that xml to json as expected.

            The problem I have is: ... 3. This template comes directly from the official Zabbix repo
            Well you can always create your own..

            Comment

            • highpeak
              Member
              • Nov 2019
              • 30

              #7
              Originally posted by cyber
              Whoever created that template clearly did not consider, that if "custom on fail" is set, then preprocessing continues.
              Yup - looks like the Zabbix team don't know how their own software works at times

              So, in this case it is natural, that if first step fails and sets some kind of json as error message, then preprocessing continues with step 2 and, if that is "XML to JSON", it will fail again ("Start tag expected, '<' not found") as now the data is replaced with that error message and is clearly not XML. And then it is setting error message again. I think, if you edit it and set that first "custom on fail" to somekind of XML, second one will not fail, but converts that xml to json as expected.
              This explains the behaviour I'm seeing, thank you. It does not explain why the logging is so poorly implemented and does not follow the rest of the Zabbix logging format

              Well you can always create your own..
              Guess I'm going to have to do just that. It's a shame as it looks like a lot of effort went into creating this template and it's going to confuse a lot of beginner users (like me).

              Comment

              Working...