Ad Widget

Collapse

log.count Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MRN345
    Junior Member
    • Nov 2022
    • 6

    #1

    log.count Question

    I have added the log.count item to read the total number of lines in a log file to provide us with a count of conditions that meet a certain criteria. When the item runs the first time it is returning the correct row value, but subsequent times it returns a 0 as from what I understand it is looking for new items only. Looking at the parameters is there a way to return the total value each time to see the change over time.

    Here is the syntax we are using for the item:

    log.count[C:\Scripts\Password Project\PWOlder90.csv,,,,,,,]

    The file changes once a day after a script is run and the current file contains 403 entries. Here is the value output to illustrate the issue:
    2022-12-01 16:57:41 0
    2022-12-01 16:56:41 0
    2022-12-01 16:55:41 0
    2022-12-01 16:47:41 0
    2022-12-01 16:46:41 0
    2022-12-01 16:45:41 0
    2022-12-01 16:44:41 0
    2022-12-01 16:43:41 403

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

    #2
    log.count and logrt.count are by design waiting for new lines to appear, not reading from beginning each time... https://www.zabbix.com/documentation...ypes/log_items There are just some cases, when reading is done from beginning again.

    TBH there is no good item to do exactly what you want ... vfs.file.regexp​ will return just first match. If that file is not too big, you ma be able to use vfs.file.get​ and then run it through some preprocessing, csv to json and then jsonpath to count matching lines..? Or you create a UserParameter, what does its magic locally and returns just a number...

    Comment

    • MRN345
      Junior Member
      • Nov 2022
      • 6

      #3
      Thanks for the reply. I did come across another method from a member of a Zabbix telegram group and will post the method here in case others are looking for a similar solution.

      We have this running using a new configuration item that returns the value from a powershell script that runs on the host (Windows Host)

      Here are the steps that were taken:

      1. Created a file in the agent host folder
      Code:
      zabbix_agent.d
      named
      Code:
      log-count.conf
      2. In the log-count.conf file it contains the following
      Code:
      UserParameter=pwolder.length[*],  powershell -NoProfile -ExecutionPolicy Bypass -File pathtoscript.ps1
      3. From the host create a new item as active agent and reference the item
      Code:
      pwolder.length
      as a Numeric value and it will begin returning the value generated by the PowerShell script running on the host.

      Comment

      Working...