Ad Widget

Collapse

Probleme with RegEXP and vfs.file.regexp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Arnaud_35
    Junior Member
    • Sep 2014
    • 1

    #1

    Probleme with RegEXP and vfs.file.regexp

    Hello fellow Zabbix users,
    first of all i'd like to mention i'm not a Zabbix specialist at all, i have been using it for only one week and please forgive my english as i'm french.
    I'm using Zabbix 2.2.2 version on a Ubuntu 14.04 system

    I have been trying to use the vfs.file.regexp function to parse a .txt file which contain a number of values following the patern:
    nameofvalue1 {value1}
    nameofvalue2 {value2}
    I'm using an online regexp tester and the zabbixagentd -t command line to verify my regexp.
    My values are float type (execution time in microsecond).

    My problem is that i can't get the item to properly return the value matching the regexp.

    I have tried a lot of regular expressions syntax but most of the time i get a ZBX-NOTSUPPORTED when i test my item with zabbixagentd -t.

    For example when i type this very global regexp just to see if i get a result(i'm escaping {} because command line doesn't use extended posix):

    zabbix_agentd -t vfs.file.regexp[path/to/file,"test1 \{(.*)\}$",,,,]

    i get the following result:

    [s|nameofvalue1 {value1}] which is the whole line containing the float number i want to parse (value1).
    So i read about the output mode of the vfs.file.regexp function and changed the command to:

    zabbix_agentd -t vfs.file.regexp[path/to/file,"test1 \{(.*)\}$",,,,\1]

    But now i get:

    [s|1]

    ...And if i change the output mode to \2 i get [s|2] etc. I'm confused.
    I tried a lot of syntax but the only results i get are either [s|ZBX-NOTSUPPORTED] or [s| ] or [s|thevalueofoutputmode]...

    All i want to get is the value1 (22,2222222 for example) to be able to make a graph with it.
    As i said i'm new to all of this(even ubuntu and regexp) and i'm probably doing something wrong so i apologize if the mistake seems obvious to you...

    Thx in advance
  • mma
    Member
    • Apr 2010
    • 39

    #2
    I have the same issue (https://support.zabbix.com/browse/ZBX-9551).

    Someone to help us ?

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #3
      I tested these file and item key.

      /tmp/testfile :
      -----
      test1 nameofvalue1 {22.22}
      -----

      item key :
      -----
      vfs.file.regexp[/tmp/testfile,"test1 .*\{([0-9]+|[0-9]+\.[0-9]*)\}",,,,\1]
      -----

      I got value 22.22 by add item for host.

      Please try add that item.
      not use zabbix_agentd -t command.

      Comment

      • mma
        Member
        • Apr 2010
        • 39

        #4
        Funny :

        root@zabbix2-4-FE:~# zabbix_get -s 172.31.1.118 -k vfs.file.regexp[/tmp/testfile,"test1 .*\{([0-9]+|[0-9]+\.[0-9]*)\}",,,,\1]
        1

        root@zabbix2-4-FE:~# zabbix_agentd -t vfs.file.regexp[/tmp/testfile,"test1 .*\{([0-9]+|[0-9]+\.[0-9]*)\}",,,,\1]
        vfs.file.regexp[/tmp/testfile,test1 .*\{([0-9]+|[0-9]+\.[0-9]*)\},,,,1] [s|1]

        BUT
        test file
        vfs.file.regexp[/tmp/testfile,"test1 .*\{([0-9]+|[0-9]+\.[0-9]*)\}",,,,\1]
        30 365 - Zabbix agent 2015-05-12 09:48:41 22.22

        If it's not a bug, (it's a feature ?) I don't understand.

        Thank you. I try with my items and I go back.

        Comment

        • Atsushi
          Senior Member
          • Aug 2013
          • 2028

          #5
          I think that double quotes are interpreted by shell.
          Please try execute this command line.

          -----
          zabbix_agentd -t "vfs.file.regexp[/tmp/testfile,\"test1 .*\{([0-9]+|[0-9]+\.[0-9]*)\}\",,,,\1]"
          -----

          Comment

          • gerencialinfo
            Junior Member
            • Aug 2023
            • 1

            #6
            ola galera,
            ao monitorar um arquivo de log com vfs.file.regexp[/var/log/messages,"Backup do Banco",,,,]
            esta trazendo a ocorrencia mais antiga, como faço pra trazer a ocorrencia mais recente ?

            Comment

            Working...