Server Monitoring Quick Reference
Server Monitoring Quick Reference
Section titled “Server Monitoring Quick Reference”Your comprehensive go-to reference for monitoring the iSu Technologies production server. Commands organized for quick access during daily operations and emergencies.
🎯 Quick Reference Card
Section titled “🎯 Quick Reference Card”The most frequently used commands for daily server monitoring:
| Task | Command | Use When |
|---|---|---|
| Memory overview | free -h | Checking available memory |
| Top processes | htop | Finding resource-hungry processes |
| Disk space | df -h | Checking storage usage |
| System load | uptime | Checking server health |
| Service status | systemctl status <service> | Verifying service is running |
| Service logs | journalctl -u <service> -n 50 | Troubleshooting errors |
| Restart service | systemctl restart <service> | After config changes |
| DB connections | sudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;" | Checking database load |
💾 Memory Monitoring
Section titled “💾 Memory Monitoring”Quick Memory Overview
Section titled “Quick Memory Overview”Check current memory usage:
free -hExample Output:
total used free shared buff/cache availableMem: 15Gi 8.2Gi 1.1Gi 234Mi 6.1Gi 6.5GiSwap: 2.0Gi 512Mi 1.5GiDetailed Memory Statistics
Section titled “Detailed Memory Statistics”Get comprehensive memory information:
cat /proc/meminfoShow memory in megabytes (easier to read):
free -mWatch memory usage in real-time (updates every 2 seconds):
watch -n 2 free -hVirtual Memory Statistics
Section titled “Virtual Memory Statistics”Monitor memory, swap, and I/O (5 samples, 1 second apart):
vmstat 1 5Example Output:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 524288 1048576 512000 6291456 0 0 1 5 1 2 5 2 93 0 0🔍 Process Monitoring
Section titled “🔍 Process Monitoring”Interactive Process Viewer
Section titled “Interactive Process Viewer”Launch interactive process monitor:
htopIf htop not installed:
sudo apt install htopTop Memory-Consuming Processes
Section titled “Top Memory-Consuming Processes”Show top 20 processes by memory usage:
ps aux --sort=-%mem | head -20Example Output:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDpostgres 1234 2.1 15.3 2456780 2401234 ? Ss Jan30 45:12 postgres: mainnode 5678 1.8 12.4 1834560 1945678 ? Ssl Jan30 32:45 node /var/www/sansa-frontendTop CPU-Consuming Processes
Section titled “Top CPU-Consuming Processes”Show top 20 processes by CPU usage:
ps aux --sort=-%cpu | head -20Filter for specific application type:
# Python processesps aux | grep python --sort=-%mem | head -10
# Node.js processesps aux | grep node --sort=-%cpu | head -10System Load Average
Section titled “System Load Average”Check server load and uptime:
uptimeExample Output:
11:45:23 up 45 days, 3:12, 2 users, load average: 0.52, 0.48, 0.45💿 Disk & Swap Monitoring
Section titled “💿 Disk & Swap Monitoring”Disk Usage Overview
Section titled “Disk Usage Overview”Check disk space across all mounted filesystems:
df -hExample Output:
Filesystem Size Used Avail Use% Mounted on/dev/sda1 80G 53G 24G 69% //dev/sdb1 200G 142G 48G 75% /varCheck specific directory sizes:
du -sh /var/www/*du -sh /var/log/*Swap Usage
Section titled “Swap Usage”Check swap usage:
swapon --showExample Output:
NAME TYPE SIZE USED PRIO/swapfile file 2G 512M -2Disk I/O Statistics
Section titled “Disk I/O Statistics”Monitor disk I/O (5 samples, 1 second apart):
iostat -x 1 5Example Output:
Device r/s w/s rkB/s wkB/s await %utilsda 12.3 45.6 234.5 1234.5 5.23 8.45🗄️ PostgreSQL Monitoring
Section titled “🗄️ PostgreSQL Monitoring”Active Queries
Section titled “Active Queries”Show all active queries (excluding idle connections):
sudo -u postgres psql -c "SELECT pid, state, query FROM pg_stat_activity WHERE state != 'idle';"Example Output:
pid | state | query-------+---------------------+---------------------------- 12345 | active | SELECT * FROM providers... 12346 | idle in transaction | BEGIN;Connection Statistics
Section titled “Connection Statistics”Count total active connections:
sudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;"Show connections per database:
sudo -u postgres psql -c "SELECT datname, count(*) FROM pg_stat_activity GROUP BY datname;"Example Output:
datname | count----------------+------- sansa_production | 12 sace_production | 8 tumi_production | 5Configuration Settings
Section titled “Configuration Settings”Check maximum connections allowed:
sudo -u postgres psql -c "SHOW max_connections;"Check shared buffers (memory for caching):
sudo -u postgres psql -c "SHOW shared_buffers;"Database Size
Section titled “Database Size”Check specific database size:
sudo -u postgres psql -c "SELECT pg_size_pretty(pg_database_size('sansa_production'));"Check all database sizes:
sudo -u postgres psql -c "SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database ORDER BY pg_database_size(datname) DESC;"Example Output:
datname | pg_size_pretty--------------------+---------------- sansa_production | 1247 MB sace_production | 856 MB tumi_production | 234 MBTable Sizes
Section titled “Table Sizes”Check table sizes in a database:
sudo -u postgres psql -d sansa_production -c "SELECT tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS size FROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;"⚙️ Service Management
Section titled “⚙️ Service Management”Check Service Status
Section titled “Check Service Status”Individual services:
systemctl status autoslipsystemctl status sansa-backendsystemctl status sace-backendsystemctl status tumi-backendsystemctl status prospectiq-apisystemctl status postgresqlsystemctl status redissystemctl status nginxCheck multiple services at once:
systemctl status sansa-backend tumi-backend sace-backend postgresql redis nginxCheck all failed services:
systemctl --failedView Service Logs
Section titled “View Service Logs”Last 50 lines:
journalctl -u autoslip -n 50 --no-pagerjournalctl -u sansa-backend -n 50 --no-pagerFollow logs in real-time:
journalctl -u <service> -fLogs from specific time period:
# Today's logsjournalctl -u sansa-backend --since today
# Last hourjournalctl -u sansa-backend --since "1 hour ago"
# Specific date rangejournalctl -u sansa-backend --since "2026-02-01" --until "2026-02-02"Filter by log level:
# Errors onlyjournalctl -u sansa-backend -p err
# Warnings and errorsjournalctl -u sansa-backend -p warningPM2 Process Management
Section titled “PM2 Process Management”Check all PM2 processes:
pm2 statusView specific application logs:
pm2 logs sansa-frontendpm2 logs thrivesendpm2 logs isutech-backendMonitor PM2 dashboard:
pm2 monit🌐 Network Monitoring
Section titled “🌐 Network Monitoring”Active Connections
Section titled “Active Connections”Show all listening ports and established connections:
ss -tulnExample Output:
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Porttcp LISTEN 0 128 0.0.0.0:80 0.0.0.0:*tcp LISTEN 0 128 0.0.0.0:443 0.0.0.0:*tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*tcp LISTEN 0 128 127.0.0.1:8001 0.0.0.0:*Connection Statistics Summary
Section titled “Connection Statistics Summary”Show connection count by state:
ss -sExample Output:
Total: 1234TCP: 567 (estab 234, closed 123, orphaned 0, timewait 45)Check Specific Port
Section titled “Check Specific Port”See what’s listening on a specific port:
sudo ss -tulpn | grep :8001sudo ss -tulpn | grep :5432 # PostgreSQLsudo ss -tulpn | grep :6379 # Redis🚨 Emergency Procedures
Section titled “🚨 Emergency Procedures”High Memory Usage Response
Section titled “High Memory Usage Response”Step 1: Identify memory hogs
ps aux --sort=-%mem | head -10Step 2: Check for memory leaks
# Monitor memory over timewatch -n 5 'ps aux --sort=-%mem | head -10'Step 3: Clear page cache (SAFE - won’t affect running processes)
sync && echo 3 | sudo tee /proc/sys/vm/drop_cachesStep 4: Check for zombie processes
ps aux | grep -w ZStep 5: Restart problematic service
# If a specific service is using too much memorysudo systemctl restart <service-name>High CPU Usage Response
Section titled “High CPU Usage Response”Step 1: Identify CPU hogs
ps aux --sort=-%cpu | head -10Step 2: Check system load
uptimeStep 3: Monitor in real-time
htop# Press F6 to sort by CPU%Step 4: Investigate specific process
# Get detailed info about a processps -p <PID> -o pid,cmd,%mem,%cpu,etime
# Check what files the process has opensudo lsof -p <PID>Disk Space Emergency
Section titled “Disk Space Emergency”Step 1: Find what’s using space
df -hdu -sh /var/www/* | sort -hdu -sh /var/log/* | sort -hStep 2: Clear old logs
# Clear systemd journal logs older than 7 dayssudo journalctl --vacuum-time=7d
# Clear old nginx logssudo find /var/log/nginx -name "*.log.*" -mtime +30 -deleteStep 3: Find large files
sudo find /var -type f -size +100M -exec ls -lh {} \; | sort -k5 -hStep 4: Check for deleted files still held open
sudo lsof | grep deleted | grep -v "/tmp"Database Connection Pool Exhausted
Section titled “Database Connection Pool Exhausted”Step 1: Check active connections
sudo -u postgres psql -c "SELECT count(*), state FROM pg_stat_activity GROUP BY state;"Step 2: Find long-running queries
sudo -u postgres psql -c "SELECT pid, now() - query_start AS duration, state, query FROM pg_stat_activity WHERE state != 'idle' ORDER BY duration DESC;"Step 3: Kill specific connection (if needed)
# Be VERY careful with this commandsudo -u postgres psql -c "SELECT pg_terminate_backend(<PID>);"Step 4: Restart application to release connections
sudo systemctl restart sansa-backend# orpm2 restart sansa-frontend📊 Health Check Commands
Section titled “📊 Health Check Commands”Full System Health Check
Section titled “Full System Health Check”Run this comprehensive check when investigating issues:
#!/bin/bash# Quick Health Check Script
echo "=== SYSTEM HEALTH CHECK ==="echo ""echo "--- Uptime & Load ---"uptimeecho ""echo "--- Memory ---"free -hecho ""echo "--- Disk Space ---"df -h | grep -E '(Filesystem|/dev/)'echo ""echo "--- Top 5 Memory Processes ---"ps aux --sort=-%mem | head -6echo ""echo "--- Top 5 CPU Processes ---"ps aux --sort=-%cpu | head -6echo ""echo "--- Service Status ---"systemctl status nginx --no-pager | grep Activesystemctl status postgresql --no-pager | grep Activesystemctl status redis --no-pager | grep Activeecho ""echo "--- PostgreSQL Connections ---"sudo -u postgres psql -c "SELECT count(*) as total_connections FROM pg_stat_activity;" 2>/dev/nullecho ""echo "--- Failed Services ---"systemctl --failed --no-pagerSave and run:
nano ~/health-check.shchmod +x ~/health-check.sh~/health-check.sh🔔 Alert Thresholds
Section titled “🔔 Alert Thresholds”Use these thresholds to determine when to take action:
Memory
Section titled “Memory”| Metric | Normal | Warning | Critical | Action |
|---|---|---|---|---|
| Available Memory | > 20% | 10-20% | < 10% | Restart services, investigate leaks |
| Swap Usage | < 25% | 25-75% | > 75% | Add RAM, optimize applications |
| Metric | Normal | Warning | Critical | Action |
|---|---|---|---|---|
| Load Average (4 cores) | < 4.0 | 4.0-8.0 | > 8.0 | Scale up, optimize code |
| CPU Wait (wa) | < 5% | 5-15% | > 15% | Check disk I/O, optimize queries |
| Metric | Normal | Warning | Critical | Action |
|---|---|---|---|---|
| Disk Usage | < 80% | 80-90% | > 90% | Clean logs, archive data |
| Disk I/O Await | < 10ms | 10-50ms | > 50ms | Check slow queries, optimize |
Database
Section titled “Database”| Metric | Normal | Warning | Critical | Action |
|---|---|---|---|---|
| Active Connections | < 50% max | 50-80% max | > 80% max | Scale connections, check leaks |
| Long Queries | < 5s | 5-30s | > 30s | Optimize queries, add indexes |
📚 Related Documentation
Section titled “📚 Related Documentation”- Hetzner Server Guide - Complete operations guide
- Development Workflow - Deployment procedures
- Hetzner Server Management - Infrastructure details
💡 Tips & Best Practices
Section titled “💡 Tips & Best Practices”Last Updated: 02/01/2026 | Document Owner: Operations Team | Version: 1.0