Ad Widget

Collapse

Custom on failure → Set value: 0 not working (wrong value type error)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GChmurka
    Junior Member
    • Jun 2024
    • 21

    #1

    Custom on failure → Set value: 0 not working (wrong value type error)

    I have a simple item with type Numeric (unsigned) and the following key:
    Code:
    vfs.file.contents[/sys/block/md0/md/sync_speed]
    The content of this file can be either a number or "none".

    Despite setting preprocessing:
    Click image for larger version

Name:	Zrzut ekranu z 2025-02-04 22-01-50.png
Views:	272
Size:	32.7 KB
ID:	498500

    I still get the error:
    Code:
    Value of type "string" is not suitable for value type "Numeric (unsigned)". Value "none"

    ​Is this the expected behavior in Zabbix?
    I'm using version 7.0.8.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    #2
    You are trying to save string value to numeric field... you are getting "none". It is not a error.
    "Check for not supported value" would work, for example, if that file is not found any more.

    Use "Replace" preprocessing to replace "none" with 0 and you should be fine. If there is a number, it will be passed on as "none" is not found, nothing is replaced.

    Comment

    • GChmurka
      Junior Member
      • Jun 2024
      • 21

      #3
      Alright, I’ve learned that a 'not supported value' is a value that, for example, does not have a key in userprefs.
      I found that the best way to ensure a value is always a number or gets discarded in Zabbix preprocessing is to use:
      1. Multiply by 1 – this forces the value to be numeric (if it's not, it will cause an error).
      2. Custom on fail → Discard value – if the operation fails (e.g., the value is text), Zabbix will discard it.

      Comment

      Working...