Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-12662

Preprocessing with regex issue

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • None
    • 3.4.1
    • Frontend (F)

      Hello, i'm trying to parse the following 'table' with regex:

      smartctl 6.4 2015-06-04 r4109 [i686-w64-mingw32-win7(64)-sp1] (sf-6.4-1)
      
      Copyright (C) 2002-15, Bruce Allen, Christian Franke, www.smartmontools.org
      
      === START OF READ SMART DATA SECTION ===
      
      SMART Attributes Data Structure revision number: 1
      
      Vendor Specific SMART Attributes with Thresholds:
      
      ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
      
      5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
      
      9 Power_On_Hours          0x0032   098   098   000    Old_age   Always       -       6357
      
      12 Power_Cycle_Count       0x0032   097   097   000    Old_age   Always       -       2337
      
      177 Wear_Leveling_Count     0x0013   096   096   000    Pre-fail  Always       -       69
      
      179 Used_Rsvd_Blk_Cnt_Tot   0x0013   100   100   010    Pre-fail  Always       -       0
      
      181 Program_Fail_Cnt_Total  0x0032   100   100   010    Old_age   Always       -       0
      
      182 Erase_Fail_Count_Total  0x0032   100   100   010    Old_age   Always       -       0
      
      183 Runtime_Bad_Block       0x0013   100   100   010    Pre-fail  Always       -       0
      
      187 Uncorrectable_Error_Cnt 0x0032   100   100   000    Old_age   Always       -       0
      
      190 Airflow_Temperature_Cel 0x0032   065   051   000    Old_age   Always       -       35
      
      195 ECC_Error_Rate          0x001a   200   200   000    Old_age   Always       -       0
      
      199 CRC_Error_Count         0x003e   099   099   000    Old_age   Always       -       11
      
      235 POR_Recovery_Count      0x0012   099   099   000    Old_age   Always       -       86
      
      241 Total_LBAs_Written      0x0032   099   099   000    Old_age   Always       -       28271920601
      

      I need to grab raw value of Reallocated sectors count:

      5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0

      In dependent item I tried to use the following regex:

      5 Reallocated.+\s([0-9]+), \1
      

      But that returned the following string(the first value on the NEXT line actually):

      9
      

      I then switched to

      5 Reallocated.+ ([0-9]+), \1
      

      And that worked and returned me '0'

      Could it be that it is because \s doesn't match space and only newline chars?
      and according to http://www.pcre.org/original/doc/html/pcrepattern.html
      it should match space as well.

      For example, online tool https://regex101.com/ returns 0 for both regexes.

      Correct if I'm wrong

            Unassigned Unassigned
            vzhuravlev Vitaly Zhuravlev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: