Skip to content

asrul10/simple-memory-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Memory Monitor

A lightweight Python utility that monitors system memory usage and alerts when memory thresholds are exceeded.

Features

  • Monitors system memory usage in real-time
  • Alerts when memory usage exceeds configurable thresholds for extended periods
  • Detects and reports swap memory usage
  • Monitors for OOM (Out Of Memory) kill events
  • Logs all events to a log file for later analysis

Requirements

  • Python 3.6+
  • psutil library

Installation

  1. Clone this repository or download the script:
git clone https://github.com/asrul10/simple-memory-monitor.git
cd simple-memory-monitor
  1. Install the required dependencies:
pip install psutil

Usage

Run the script with Python:

python main.py

The script will start monitoring your system memory and provide alerts when:

  • Memory usage exceeds 80% for 2 minutes or more
  • Any swap memory is being used
  • OOM kill events are detected

All alerts are displayed in the console and also logged to memory_monitor.log.

Configuration

You can modify the following variables in the main() function to adjust monitoring thresholds:

  • high_memory_threshold: Percentage of memory usage that triggers an alert (default: 80%)
  • high_memory_min_duration: Minimum duration in seconds that memory must remain high to trigger an alert (default: 120 seconds)

Log File

The script creates a log file named memory_monitor.log in the same directory. This file contains all monitoring events with timestamps.

About

A simple Python tool to monitor memory usage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages