sensu / sensu-check-log

The Sensu Go log file monitoring check plugin and asset.
MIT License
2 stars 3 forks source link

Customer report indicating file offset state not working. #23

Closed jspaleta closed 2 years ago

jspaleta commented 2 years ago

Confirmed reproducible

Step to attempt to reproduce:

  1. Create log file with multiple lines with the word error in it

    touch /tmp/test.log
    echo "First error line">> /tmp/test.log
    echo "Second error line">> /tmp/test.log
    echo "Third error line">> /tmp/test.log
  2. Run handler command in dry-run mode with search pattern matching the word error ...should have report indicating new matches were found

    
    ./sensu-check-log -n -f /tmp/test.log --disable-event-generation --state-directory /tmp/test-state-dir
    LogFileExpr:  StateDir: /tmp/test-state-dir
    Log file array to process: [/tmp/test.log]
    Now Processing: /tmp/test.log
    stateFile: /tmp/test-state-dir/_tmp_test.log
    Resetting offset to zero, because cached offset is beyond end of file and modtime is newer than last time processed
    File /tmp/test.log Match Count: 3
    File /tmp/test.log Match Status 0 BytesRead: 52 New Offset: 52
    {"path":"/tmp/test.log","match":"First error line"}
    {"path":"/tmp/test.log","match":"Second error line"}
    {"path":"/tmp/test.log","match":"Third error line"}

3. Run handler again and confirm report is is the same