Ad Widget

Collapse

Trim not working for me

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • highway_fixer_man
    Member
    • Jun 2022
    • 35

    #1

    Trim not working for me

    Hi,

    I have an item that returns file info. (vfs.file.get[/home/user/file.txt]

    I get back a string that looks like this:

    {"basename":"antipase_tag.txt","pathname":"/home/user/file.txt","dirname":"/home/user/","type":"file","user":"appuser","group":"appgroup ","permissions":"0664","uid":1000,"gid":300,"size" :86,"time":{"access":"2023-05-23T13:19:10.989292448+02:00","modify":"2023-05-23T13:19:10.989292448+02:00","change":"2023-05-23T13:19:10.989292448+02:00"},"timestamp":{"access ":1684840750,"modify":1684840750,"change":16848407 50}}

    I want to clean this up so that everything after "size" is removed. Basically, I need to know if this files permissions have changed - and I think this is the best way.

    I thought a "Right Trim" was the answer here - but its not working for me.

    If I use a "Left Trim" it also doesn't trim!

    I have tried every variation of the "size" marker as possible - "size" "size" *size* *size. etc - I really just cant get this to work. Seems like something simple.

    Any help appreciated.

  • Answer selected by highway_fixer_man at 23-05-2023, 15:09.
    Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    You misunderstood how this function works - it removes a previously known set of characters. Without substitutions.
    Example: input - "000123" \ the right trim function with param "123" will return "000".
    You need another function - Regular expression​!
    https://www.zabbix.com/documentation.../preprocessing

    (
    for your case:
    pattern = ^(.*)size.*$
    output = \1
    )
    Last edited by Hamardaban; 23-05-2023, 14:36.

    Comment

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

      #2
      You misunderstood how this function works - it removes a previously known set of characters. Without substitutions.
      Example: input - "000123" \ the right trim function with param "123" will return "000".
      You need another function - Regular expression​!
      https://www.zabbix.com/documentation.../preprocessing

      (
      for your case:
      pattern = ^(.*)size.*$
      output = \1
      )
      Last edited by Hamardaban; 23-05-2023, 14:36.

      Comment

      • highway_fixer_man
        Member
        • Jun 2022
        • 35

        #3
        Originally posted by Hamardaban
        You misunderstood how this function works - it removes a previously known set of characters. Without substitutions.
        Example: input - "000123" \ the right trim function with param "123" will return "000".
        You need another function - Regular expression​!
        https://www.zabbix.com/documentation.../preprocessing

        (
        for your case:
        pattern = ^(.*)size.*$
        output = \1
        )

        Thank you so much, Hamardaban - exactly what I needed. Very much appreciated.

        Comment

        Working...