-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
$ sudo systemctl start swap-optimizer
Job for swap-optimizer.service failed.# Check service status
sudo systemctl status swap-optimizer
# View detailed logs
sudo journalctl -u swap-optimizer -n 501. Missing Python Dependencies
Error: ModuleNotFoundError: No module named 'psutil'
Solution:
sudo pip3 install psutil2. Permission Issues
Error: Permission denied when writing to /proc/sys
Solution:
# Ensure running as root
sudo systemctl start swap-optimizer
# Check file permissions
ls -la /opt/swap-optimizer/
sudo chmod +x /opt/swap-optimizer/swap_optimizer.py3. Invalid Configuration
Error: JSON decode error in config file
Solution:
# Validate JSON
python3 -m json.tool /etc/swap-optimizer/config.json
# Restore default config
sudo cp config.json /etc/swap-optimizer/config.json4. Missing Config File
Error: Config file not found
Solution:
sudo mkdir -p /etc/swap-optimizer
sudo cp config.json /etc/swap-optimizer/Running --optimize but sysctl values don't change
# Check current values
sudo sysctl vm.swappiness
sudo sysctl vm.vfs_cache_pressure
# Try manual set
sudo sysctl -w vm.swappiness=101. Sysctl Not Available
# Install procps
sudo apt-get install procps # Debian/Ubuntu
sudo yum install procps-ng # RHEL/CentOS2. SELinux Blocking
# Check SELinux status
sestatus
# Temporarily disable for testing
sudo setenforce 0
# Create proper SELinux policy
# (Advanced - see SELinux documentation)3. Read-Only Filesystem
# Check filesystem mount
mount | grep "proc/sys"
# Remount if necessary
sudo mount -o remount,rw /proc/sysSystem CPU usage increases after starting swap-optimizer
# Check process CPU
top -p $(pgrep -f swap_optimizer)
# Monitor over time
sudo journalctl -u swap-optimizer -f1. Check Interval Too Low
// In /etc/swap-optimizer/config.json
{
"check_interval": 1 // Too frequent
}Fix: Increase to 5-10 seconds
{
"check_interval": 5
}2. Process List Too Large
{
"ai_processes": ["very", "long", "list", "..."]
}Fix: Reduce to essential processes only
3. Infinite Loop Bug
# Check for rapid log entries
sudo journalctl -u swap-optimizer --since "1 minute ago"Fix: Report bug and restart service
System freezes or becomes very slow after optimization
# Restore original settings immediately
sudo python3 /opt/swap-optimizer/swap_optimizer.py --restore
# Or reboot if unresponsive
sudo reboot1. Aggressive Mode on Low RAM
{
"aggressive_mode": true // Dangerous on low RAM
}Fix: Set to false
{
"aggressive_mode": false
}2. Swappiness Too Low
{
"swappiness": 0 // Can cause OOM
}Fix: Set to at least 5
{
"swappiness": 10
}3. min_free_kbytes Too High
{
"min_free_kbytes": 1048576 // 1GB - too high
}Fix: Reduce to appropriate value
{
"min_free_kbytes": 65536
}AI processes still have default priorities
# Check process priority
ps -eo pid,ni,comm | grep python
# Check ionice availability
which ionice1. ionice Not Installed
# Install ionice
sudo apt-get install util-linux # Debian/Ubuntu
sudo yum install util-linux # RHEL/CentOS
sudo pacman -S util-linux # Arch2. Permission Denied
# Check if running as root
sudo systemctl status swap-optimizer
# Test manually
sudo ionice -c 1 -n 4 -p $(pgrep python)3. Process Not Detected
# Check process name
ps aux | grep python
# Add to config
sudo nano /etc/swap-optimizer/config.json
# Add "python" to ai_processes arrayaggressive_mode: true but swap remains enabled
# Check memory usage
free -h
# Check swap status
swapon --show1. Memory Threshold Not Met
# Aggressive mode only disables swap when memory < 70%
# Check current usage
free -h | grep MemFix: Either free memory or disable aggressive mode
2. swapoff Command Failing
# Test manually
sudo swapoff -a
# Check for errors
# Common issue: swap cannot be disabled if in use3. Permission Issues
# Ensure service runs as root
sudo systemctl cat swap-optimizer
# Look for "User=root"Modified config but behavior unchanged
# Check if service restarted
sudo systemctl status swap-optimizer
# Verify config location
sudo systemctl cat swap-optimizer | grep config1. Service Not Restarted
sudo systemctl restart swap-optimizer2. Wrong Config File
# Check which config is being used
sudo systemctl cat swap-optimizer
# Edit correct config
sudo nano /etc/swap-optimizer/config.json3. Config Syntax Error
# Validate JSON
python3 -m json.tool /etc/swap-optimizer/config.jsonDisk space filling with log files
# Check log size
sudo journalctl --disk-usage
# Check swap-optimizer log size
sudo journalctl -u swap-optimizer --since "1 week ago" | wc -l1. Reduce Log Level
{
"log_level": "WARNING" // Instead of "DEBUG"
}2. Configure Journal Rotation
# Edit journald config
sudo nano /etc/systemd/journald.conf
# Add/modify:
SystemMaxUse=50M
SystemMaxFiles=53. Manual Log Cleanup
# Rotate logs
sudo journalctl --rotate
# Vacuum old logs
sudo journalctl --vacuum-time=7d# Check swap usage before/after
swapon --show
free -h
# Check I/O wait
iostat -x 11. Swap Thrashing
# Increase swappiness slightly
# In config.json:
"swappiness": 15 // Was 102. Cache Pressure Too Low
# Increase vfs_cache_pressure
"vfs_cache_pressure": 90 // Was 753. Page Cluster Disabled
# Enable page clustering for better throughput
"page_cluster": 2 // Was 0# Check I/O statistics
iostat -x 5
# Check swap activity
vmstat 11. Reduce Swap Activity
# Lower swappiness
"swappiness": 52. Enable Page Clustering
"page_cluster": 33. Check Disk Health
sudo smartctl -a /dev/sda$ sudo bash install.sh
Error: ...1. Python Not Found
# Install Python 3
sudo apt-get install python3 # Debian/Ubuntu
sudo yum install python3 # RHEL/CentOS2. pip Not Available
# Install pip
sudo apt-get install python3-pip # Debian/Ubuntu
sudo yum install python3-pip # RHEL/CentOS3. Directory Permissions
# Create directories manually
sudo mkdir -p /opt/swap-optimizer
sudo mkdir -p /etc/swap-optimizerFiles or service remain after uninstall
1. Service Still Running
sudo systemctl stop swap-optimizer
sudo systemctl disable swap-optimizer2. Files Remain
sudo rm -rf /opt/swap-optimizer
sudo rm -rf /etc/swap-optimizer3. systemd Cache
sudo systemctl daemon-reload
sudo systemctl reset-failed# System info
uname -a
free -h
swapon --show
# Service status
sudo systemctl status swap-optimizer
# Recent logs
sudo journalctl -u swap-optimizer -n 100
# Current config
sudo cat /etc/swap-optimizer/config.json
# Current sysctl values
sudo sysctl -a | grep -E "swappiness|vfs_cache|page-cluster|min_free|watermark"# Enable debug logging
# In config.json:
{
"log_level": "DEBUG"
}
# Restart service
sudo systemctl restart swap-optimizer
# Watch logs
sudo journalctl -u swap-optimizer -f# Test optimization manually
sudo python3 /opt/swap-optimizer/swap_optimizer.py --optimize
# Check status
sudo python3 /opt/swap-optimizer/swap_optimizer.py --status
# Test restore
sudo python3 /opt/swap-optimizer/swap_optimizer.py --restore- Cannot modify swap device size - Only manages swap behavior
- Requires root access - Cannot run in user space
- Linux only - Not compatible with other OSes
- Process name matching only - Cannot identify processes by behavior
- No GPU memory management - Only handles system RAM
Report a bug if:
- The service crashes repeatedly
- Settings don't apply despite correct configuration
- System becomes unstable after optimization
- Unexpected error messages in logs
- Performance degrades significantly
Include in bug report:
- OS distribution and version
- Kernel version (
uname -r) - Python version (
python3 --version) - Configuration file
- Relevant log excerpts
- Steps to reproduce