Ad Widget

Collapse

Counting number of lines changed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bertus_Brutalis
    Junior Member
    • Jul 2018
    • 9

    #1

    Counting number of lines changed

    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?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    count.lines[<file>] is possibly some UserParameter in your old config,

    Comment

    • Bertus_Brutalis
      Junior Member
      • Jul 2018
      • 9

      #3
      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

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        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 with
        Code:
        wc -l
        is 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.

        Comment

        • Bertus_Brutalis
          Junior Member
          • Jul 2018
          • 9

          #5
          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

          • josephedison0
            Junior Member
            • May 2022
            • 2

            #6
            Originally posted by cyber
            count.lines[<file>] is possibly some UserParameter in your old config,
            It's Working As I Have Checked Right Now I Am Using Zabbix 6.0

            Comment

            • cyber
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Dec 2006
              • 4807

              #7
              Originally posted by josephedison0

              It's Working As I Have Checked Right Now I Am Using Zabbix 6.0
              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

              Working...