Ad Widget

Collapse

Userparameter Only Returns a string

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rosspoch
    Junior Member
    • Oct 2024
    • 2

    #1

    Userparameter Only Returns a string

    I have been having an issue where no matter what I put into a userparameter it will only return as a string when using zabbix_agent2 -t some.key. I have tried forcing my output into an integer in many different ways.
    The userparameter I am using boils down to:
    Code:
    UserParameter=some.key[*],command --flags | grep -cw "$1"
    and this parameter returns [s|1] and I have observed it as many other numbers, not exclusively 1.
    On the web side of this my item is declared as a numeric unsigned.
    Any reason why it wants to be a string and how I can make it into an integer so it can be used?
  • Answer selected by rosspoch at 29-04-2025, 22:11.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    Originally posted by bbonno
    If the returned 'value' is [s|1], then a simple preprocessing step like this will fix your issue. This will remove those characters from your data, and only leave the number.

    []s|
    well, it is not exactly that easy.. "[s|1] " you can see, when testing the item (zabbix_agent2 -t item).

    I think you can ignore it and just set your item typ as you need...
    I tested with some random items, it is either "s" there, or "-" if there was no data .. "[-|ZBX_NODATA]". Everything else produced "s".
    It seems to be agent2 related thing.. if you test with classic agent, you will get some other options also... u,t,d etc...

    Comment

    • bbonno
      Junior Member
      • Apr 2025
      • 22

      #2
      If the returned 'value' is [s|1], then a simple preprocessing step like this will fix your issue. This will remove those characters from your data, and only leave the number.

      []s|
      Click image for larger version

Name:	image.png
Views:	86
Size:	11.3 KB
ID:	502502

      Comment

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

        #3
        Originally posted by bbonno
        If the returned 'value' is [s|1], then a simple preprocessing step like this will fix your issue. This will remove those characters from your data, and only leave the number.

        []s|
        well, it is not exactly that easy.. "[s|1] " you can see, when testing the item (zabbix_agent2 -t item).

        I think you can ignore it and just set your item typ as you need...
        I tested with some random items, it is either "s" there, or "-" if there was no data .. "[-|ZBX_NODATA]". Everything else produced "s".
        It seems to be agent2 related thing.. if you test with classic agent, you will get some other options also... u,t,d etc...

        Comment

        • bbonno
          Junior Member
          • Apr 2025
          • 22

          #4
          Originally posted by cyber
          testing the item (zabbix_agent2 -t item).
          It's been a while since I set up a Userparameter, and I don't think I've ever tested one from the command line like that. Running the agent like that, mine return [s|"actual Data"], but I have zero accommodations in my items for this, so I don't think any of these extra characters are sent to the Zabbix server/poxy.

          Comment

          • rosspoch
            Junior Member
            • Oct 2024
            • 2

            #5
            Originally posted by cyber
            well, it is not exactly that easy.. "[s|1] " you can see, when testing the item (zabbix_agent2 -t item).

            I think you can ignore it and just set your item typ as you need...
            I tested with some random items, it is either "s" there, or "-" if there was no data .. "[-|ZBX_NODATA]". Everything else produced "s".
            It seems to be agent2 related thing.. if you test with classic agent, you will get some other options also... u,t,d etc...
            Hmm, weird that Zabbix would 'devolve'. Assuming I don't have classic agent is there any preprocessing that can fix this so I can still use it. Even with it being a string it has always shown up as 0 on the server so something is getting thru.

            Comment

            • Hamardaban
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • May 2019
              • 2713

              #6
              In order to test what data you will receive in item, you need to use zabbix_get , not zabbix_agent* -t !
              and as Cyber wrote - you can ignore “string type” and just set your item typ as you need
              Last edited by Hamardaban; 29-04-2025, 19:55.

              Comment

              Working...