Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.4-stable] Enhance memory-monitor with improved logging, cleanup, and task handling #4365

Commits on Oct 16, 2024

  1. memory-monitor: Simplify cgroup task handling in the handler script.

    Simplify the process of extracting PIDs from a cgroup. Instead of using
    a temporary file and filtering tasks to find unique PIDs based on TIDs,
    the script now directly reads the `cgroup.procs` file to retrieve the
    PIDs. This approach reduces complexity, removes the need for
    intermediate processing, and improves the efficiency of PID retrieval.
    The redundant temporary task list creation has been removed to
    streamline the code.
    
    Signed-off-by: Nikolay Martyanov <[email protected]>
    (cherry picked from commit 0a6aedf)
    OhmSpectator committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    53d1656 View commit details
    Browse the repository at this point in the history
  2. memory-monitor: Move file cleanup to exit handler.

    This update moves the file cleanup process to an exit handler to ensure
    it runs even if the script encounters an error. By trapping the cleanup
    function, the script reliably archives old files, deletes temporary
    files, and maintains the total archive size below 100 MB. This change
    addresses a previous issue where errors could lead to leftover files not
    being removed, enhancing the overall reliability and resource
    management.
    
    Signed-off-by: Nikolay Martyanov <[email protected]>
    (cherry picked from commit e71af37)
    OhmSpectator committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    6cf74f9 View commit details
    Browse the repository at this point in the history
  3. memory-monitor: Log last lines of failed handler script to syslog.

    Add functionality to capture and log the last 10 lines of the handler
    script output when it exits with a non-zero status. This ensures that
    relevant log information is sent to syslog, making it accessible to log
    aggregation tools for better visibility.
    
    * Introduced `get_tail()` to extract the last n lines of a log file.
    * Updated the script handler logic to send the last 10 lines to syslog
      upon failure.
    
    This enhancement improves error diagnosis by ensuring failed handler
    output is readily available in centralized logging systems.
    
    Signed-off-by: Nikolay Martyanov <[email protected]>
    (cherry picked from commit d65d6a0)
    OhmSpectator committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    a12dfaa View commit details
    Browse the repository at this point in the history