[ZBX-8248] incorrect handling of carriage reload in vfs.file.regexp[] and web.page.regexp[] items Created: 2014 May 23  Updated: 2017 May 30  Resolved: 2014 Jun 12

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 2.2.3
Fix Version/s: 2.2.5rc1, 2.3.2

Type: Incident report Priority: Major
Reporter: Aleksandrs Saveljevs Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: crlf, regexps
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

This issue is composed of two recently encountered problems: one for vfs.file.regexp[] and another one for web.page.regexp[].

(A) If item vfs.file.regexp[] is applied on a file with Windows line endings, then \r symbol prevents the $ symbol from matching.

For instance, consider the example below:

$ echo ' C: 8195Mb 5879Mb 2316Mb 28.2' > file.txt

$ zabbix_agentd -t 'vfs.file.regexp[file.txt,"C.* ([0-9]+\.[0-9])$",,,,\1]'
vfs.file.regexp[file.txt,"C.* ([0-9]+\.[0-9])$",,,,\1] [s|28.2]

$ unix2dos file.txt
unix2dos: converting file file.txt to DOS format ...

$ zabbix_agentd -t 'vfs.file.regexp[file.txt,"C.* ([0-9]+\.[0-9])$",,,,\1]'
vfs.file.regexp[file.txt,"C.* ([0-9]+\.[0-9])$",,,,\1] [s|]

$ zabbix_agentd -t 'vfs.file.regexp[file.txt,"C.* ([0-9]+\.[0-9])",,,,\1]'
vfs.file.regexp[file.txt,"C.* ([0-9]+\.[0-9])",,,,\1] [s|28.2]

(B) For web.page.regexp[], the \r character is included into the output by default:

$ zabbix_agentd -t 'web.page.regexp[localhost,,,.*]'
]eb.page.regexp[localhost,,,.*] [s|HTTP/1.1 200 OK

Note how "w" in "web.page.regexp" was replaced by "]". This shows that \r was included into the output.



 Comments   
Comment by Aleksandrs Saveljevs [ 2014 May 23 ]

The following discussion on Stack Exchange motivated this bug report: http://serverfault.com/questions/597010/zabbix-doesnt-update-value-from-file-neither-with-log-nor-with-vfs-file-regex .

Comment by Juris Miščenko (Inactive) [ 2014 Jun 11 ]

Fix implemented in svn://svn.zabbix.com/branches/dev/ZBX-8248

Comment by Andris Zeila [ 2014 Jun 12 ]

(1) The WEB_PAGE_REGEXP matching relies on web pages following standards and using CRLF as line separator, which might not always be the case.

jurism Adjusted code to handle cases when delivered data doesn't follow standards. RESOLVED.

wiper Slightly simplified the line parsing code, please review r46450

Comment by Andris Zeila [ 2014 Jun 12 ]

(2) VFS_FILE_REGMATCH should also strip the CR from lines before trying to match with regular expression (like VFS_FILE_REGEXP)

jurism Added character stripping from strings before matching for a regular expression. RESOLVED.

wiper CLOSED

Comment by Andris Zeila [ 2014 Jun 12 ]

wiper The result trimming in vfs.file.regexp was redundant after adding line trimming before regexp matching. Removed in r46451, please review.

jurism Changes reviewed. Slipped by me. Thanks. RESOLVED.

Comment by Juris Miščenko (Inactive) [ 2014 Jun 30 ]

Fixed merged in 2.2.5rc1 r46920, 2.3.2 (trunk) r46921

Comment by richlv [ 2014 Jul 29 ]

this might have caused problems for some users : ZBX-8512

Generated at Wed May 08 02:48:21 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.