We've recently upgraded from Zabbix 4.4 to 6.0. In the old release, I would use count.lines[<file>] to basically do just that: count the number of lines in a file. With the new release, that key is no longer available, and I'm trying to get the same result from log.count or logrt.count, but that doesn't work as expected. The number of lines is counted once, but on a new check it seems like the number of NEW lines is counted. If I have a file with say 2 lines, the counter now will show a value of 2 for one refresh cycle, after which it falls back to 0 and doesn't stay at 2. Maybe that's just how these log counters work, but is there a way to still get the old behaviour back?
Ad Widget
Collapse
Counting number of lines changed
Collapse
X
-
Tags: None
-
You are right, we have count.lines defined as "UserParameter=Count.Lines[*],wc -l < "$1"". This should return the number of lines in the file $1, an empty file resulting in 0. The strange thing is that the value will alternate between 0 and 1, eventhough the number of lines in the file is always 0. The file being read refreshed every 10 minutes, so might it be that Zabbix treats this as a new entry of 0, being 1? Does that make sense?Comment
-
log and logrt are actually intended to only read new data, and mark position up to which they read the file. Follow up checks is continued form place previously reached. So if your log file had no changes since last check - it's expected to return 0 for count. At least that is my understanding.
Case withis more interesting tho. I'd say create some dummy file and point Zabbix on it to see if it will exhibit same behavior on file that no one touches.Code:wc -l
Comment
-
I've created a new file that is never touched, and there the value remains a steady 0 (as expected in this file). The value in the real file to be monitored is also normally 0, but this file is recreated every 15 minutes. At that point the value is given as 1, even though the retuned value from the user parameter is 0.
As key I now have "Count.Lines[<FILE>]" where Count.Lines is defined as "Count.Lines[*],wc -l < "$1"". The type of information for the item in Zabbix is set to "Numeric (unsigned)".
Comment
-
Comment
-
Oh really... what exactly you checked in OP-s environment... Or, you are just spamming random threads with the same text... I assume those will be edited soon, to contain links to foreign sites? Eh? Spammer...Comment
Comment