0

I am using Zabbix 2.2.
I have a very specific environment, where I have to generate desired data to file via script, then upload that file to ftp from host and download it to Zabbix server from ftp.
After file is downloaded, I check it with log[] and vfs.file.regexp[] items.

I use these items as below:

log[/path/to/file.txt,"C.*\s([0-9]+\.[0-9])$",Windows-1250,,"all",\1]
vfs.file.regexp[/path/to/file.txt,"C.*\s([0-9]+\.[0-9])$",Windows-1250,,,\1]

The line I am parsing looks like below:

                C:      8195Mb  5879Mb  2316Mb  28.2

The value I want to extract is 28.2 at the end of file.

The problem I am currently trying to solve is that when I update the file (upload from host to ftp, then download from ftp to Zabbix server), the value does not update.

I was trying only log[] at start, but I suspect, that log[] treat the file as real log file and doesn't check the same lines (althought, following the documentation, it should with "all" value), so I added vfs.file.regexp[] item too.

The log[] has received a value in past, but it doesn't update.
The vfs.file.regexp[] hasn't received any value so far.
file.txt has got reuploaded and redownloaded several times and situation doesn't change.
It seems that log[] reads only new lines in the file, it doesn't check lines already caught if there are any changes.

The zabbix_agentd.log file doesn't report any problem with access to file, nor with regexp construction (it did report "unsupported" for log[] key, when I had something set up wrong).

I use debug logging level for agent - I haven't found any interesting info about that problem.

I have no idea what I might be doing wrong or what I do not know about how Zabbix is performing these checks. I see 2 solutions for that: adding more lines to the file instead of making new one or making new files and check them with logrt[], but those doesn't satisfy my desires.
Any help is greatly appreciated.
Of course I will provide additional information, if requested - for now I don't know what else might be useful.

12
  • 1
    Regarding "C.*([0-9]+\.[0-9])$" regexp and the fact that it matches only "8.2", rather than "28.2". The reason is that ".*" after "C" is greedy, so it eats up everything up to "8". You can fix it by including a space before "(", like this: "C.* ([0-9]+\.[0-9])$".
    – asaveljevs
    May 20, 2014 at 14:31
  • I've tried regexp with .*?, which should be lazy, but Zabbix doesn't seem to understand ? modifier. Anyways, finally not regexp was the problem, as I've fixed it and problem still persist.
    – tymik
    May 21, 2014 at 10:03
  • 1
    Since log[] is meant for log file monitoring (i.e., files that grow in size line by line), the correct approach in your case would be to use vfs.file.regexp[], so let's stick to that key only. I have tried the following item and it works perfectly: vfs.file.regexp[/tmp/file.txt,"C.*\s([0-9]+\.[0-9])$",,,,\1]. Could you please provide more information on the problem? Is the item in "not supported" state? How small is its update interval? Does it work if you save the file in UTF-8 encoding and omit "Windows-1250" from the key?
    – asaveljevs
    May 21, 2014 at 11:24
  • update interval is 30s by default. I haven't found it being in "not supported" state. I have no idea how to adapt script for dumping data in utf-8, but I wouldn't consider it as being problemmaker, because in log[] it works that way. And trying to dump in utf8 would probably require much more effort than trying to solve problem with logrt[]. vfs.file.regexp[] is configured to return value as float. And value is supposed to be float if I want to use triggers with the value, without making triggers statements heavily complicated to perform comparison on extracted value. Can I provide more info?
    – tymik
    May 21, 2014 at 15:12
  • What happens when you execute the following command on the agent's host: $ zabbix_agentd -t 'vfs.file.regexp[/tmp/file.txt,"C.*\s([0-9]+\.[0-9])$",Windows-1250,,,\1]'? Here, replace path to the file with the correct one.
    – asaveljevs
    May 22, 2014 at 8:26

2 Answers 2

1

Item log[] is meant for files that grow in size line by line, so the correct approach in your case would be to stick to vfs.file.regexp[].

With vfs.file.regexp[], you are doing everything correctly, except that there is a bug in Zabbix (reported as ZBX-8248) that prevents "$" symbol in regular expressions from matching Windows line endings.

So in order to make it work in the meanwhile you should omit "$" from the regular expression.

0

I have not tried the log functionality of Zabbix, but my guess is that the log file is opened once during the Zabbix agent startup and then held open. This means that even if you overwrite your file, the old file handle is still kept open and Zabbix reads the data from there.

If this is the case, I propose you two solutions:

1) Somehow send HUP signal to Zabbix agent (so it would reopen the files for reading)

or

2) Use the External script functionality in Zabbix and create a shell script which parses your file.

1
  • 1
    @Janne: The log file is opened every N seconds, where N is the item update interval. It is never held open for a long period of time.
    – asaveljevs
    May 20, 2014 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.