How to Check Memory and Swap Usage Trends on Linux Server

Step-by-step guide to check memory and swap usage trends. Track memory consumption patterns, monitor swap usage, and plan capacity upgrades based on trends.

Last updated: 2026-01-11

Monitor memory and swap usage trends to track consumption patterns, identify growth trends, and plan capacity upgrades. This guide shows you how to check memory trends and set up automated monitoring.

For comprehensive memory monitoring, see RAM Monitoring. For troubleshooting memory issues, see High Memory Usage.

Memory usage trends help identify growth patterns, plan capacity upgrades, and detect memory leaks. Monitoring trends enables proactive capacity planning and prevents memory-related issues.

Method 1: Check Current Memory Usage

Monitor Memory Usage

# Check memory usage
free -h

# Get memory usage percentage
free | awk 'NR==2{printf "Memory Usage: %.2f%%\n", $3*100/$2}'

# Check swap usage
free -h | grep Swap

# Get swap usage percentage
free | awk 'NR==3{printf "Swap Usage: %.2f%%\n", $3*100/$2}'

Track Memory Usage Over Time

# Monitor memory usage continuously
while true; do
  MEM=$(free | awk 'NR==2{printf "%.2f", $3*100/$2}')
  SWAP=$(free | awk 'NR==3{printf "%.2f", $3*100/$2}')
  echo "$(date): Memory: $MEM%, Swap: $SWAP%"
  sleep 60
done

Track Memory Usage History

# Log memory usage to file
free | awk 'NR==2{print strftime("%Y-%m-%d %H:%M:%S"), $3*100/$2}' >> /var/log/memory_usage.log

# Analyze memory trends
tail -1000 /var/log/memory_usage.log | awk '{sum+=$3; count++} END {print "Average:", sum/count"%"}'

# Find peak memory usage
tail -1000 /var/log/memory_usage.log | awk '{if ($3 > max) max=$3} END {print "Peak:", max"%"}'

Method 3: Automated Memory Trend Monitoring with Zuzia.app

Set up automated monitoring to track memory and swap usage trends continuously and receive alerts when usage exceeds thresholds.

Step 1: Add Memory Trend Monitoring Command

  1. Log in to Zuzia.app Dashboard

    • Access your Zuzia.app account
    • Navigate to your server
    • Click "Add Scheduled Task"
  2. Configure Memory Usage Check Command

    free | awk 'NR==2{printf "%.2f", $3*100/$2}'
    
    • Set execution frequency (every 5-10 minutes)
    • Configure alerts when memory usage exceeds thresholds

Step 2: Configure Alert Thresholds

  • Warning: Memory usage > 80% or Swap usage > 20%
  • Critical: Memory usage > 90% or Swap usage > 50%
  • Emergency: Memory usage > 95% or Swap usage > 80%

Add commands to track memory trends:

# Track memory usage over time
free | awk 'NR==2{print strftime("%Y-%m-%d %H:%M:%S"), $3*100/$2}'

Best Practices for Memory Trend Monitoring

1. Monitor Memory Usage Continuously

  • Track memory usage regularly
  • Alert when usage exceeds thresholds
  • Monitor memory trends over time
  • Plan capacity upgrades based on data

2. Analyze Memory Growth Patterns

  • Identify memory growth trends
  • Detect memory leaks early
  • Plan capacity upgrades proactively
  • Optimize memory usage

3. Monitor Swap Usage

  • Track swap usage regularly
  • Alert when swap usage increases
  • Investigate high swap usage
  • Optimize memory allocation

4. Set Appropriate Thresholds

  • Set thresholds based on server capacity
  • Adjust thresholds for different workloads
  • Monitor memory during peak usage
  • Alert on memory spikes

Troubleshooting Memory Issues

Step 1: Identify Memory Problems

When memory usage is high:

# Check current memory usage
free -h

# Check memory usage by process
ps aux --sort=-%mem | head -10

# Check swap usage
swapon --show

# Check memory trends
tail -100 /var/log/memory_usage.log

Step 2: Resolve Memory Issues

Based on investigation:

  1. Optimize Memory Usage:

    • Optimize applications
    • Reduce memory consumption
    • Implement memory-efficient practices
  2. Scale Memory Capacity:

    • Add more RAM if needed
    • Optimize memory allocation
    • Scale infrastructure
  3. Fix Memory Leaks:

    • Identify memory leaks
    • Fix application bugs
    • Optimize memory management

For production servers, continuous automated monitoring is essential. Zuzia.app can check memory usage every few minutes, storing historical data and alerting you when usage exceeds thresholds.

What is considered high memory usage?

High memory usage depends on your server capacity and workload. Generally, usage above 80% indicates potential issues and should be investigated.

Analyze memory growth trends by tracking memory usage over time, identifying growth patterns, detecting memory leaks, and planning capacity upgrades based on trends. Zuzia.app can help automate this analysis.

Can memory monitoring impact server performance?

Memory monitoring commands have minimal impact on server performance when done correctly. Use appropriate monitoring frequency and avoid monitoring during peak usage periods.

Note: The content above is part of our brainstorming and planning process. Not all described features are yet available in the current version of Zuzia.

If you'd like to achieve what's described in this article, please contact us – we'd be happy to work on it and tailor the solution to your needs.

In the meantime, we invite you to try out Zuzia's current features – server monitoring, SSL checks, task management, and many more.

We use cookies to ensure the proper functioning of our website.