Ad Widget

Collapse

Trouble with preprocessing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • redteck85
    Junior Member
    • Dec 2021
    • 8

    #1

    Trouble with preprocessing

    I'm trying to take an item coming in as a text string and use preprocessing to change it to Numeric (float). The item is using SNMP to pull an octet string showing light level from a device, it comes out like -6.29 dBm. It seems that the string is coming into Zabbix with "" around it but there appears to be an extra line on it as the error I'm receiving looks like this.
    Click image for larger version

Name:	brave_KsBZnxTkH1.png
Views:	701
Size:	4.4 KB
ID:	436119
    I've tried several preprocessing rules but none can seem to take care of the additional line.

    Any help would be awesome.

  • ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    #2
    Hi mate.

    Lately I'm mostly dealing with regexp on this forum, so let me continue my stride and offer you solution based on it:

    Preprocessing Type: Regular Expression
    Parameters: (-[\d|\.]+)
    Output: \1

    Please advise if it works for you or not (Tested on Pre-processing Test via Zabbix 4.4 and worked fine)

    Comment

    • redteck85
      Junior Member
      • Dec 2021
      • 8

      #3
      That worked! Appreciate the help.

      Can you explain what the parameters are actually indicating. I haven't messed around with regexp before.

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        Code:
        (-[\d|\.]+)
        () - represent a match group. Regexp remembers what it matches by whatever conditions are inside and later matched data can be called back by \1 \2 \3 representing first, second, third etc. match groups.
        - literally matches minus symbol
        (so this regexp assumes values returned would always be negative. If it can return value that are above zero use below regex instead )
        Code:
        (-?[\d\.]+)
        [] - character class. matches a single symbol from list of symbols inside of it
        \d - any digit
        \. - actual dot symbol
        | - boolean OR.(should actually be dropped from expression. Put it out of habit)
        + - quantifier. Makes previous condition to be repeated as many times as possible but at least once.

        Comment

        Working...