Skip to content

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.


The most frequently used commands for daily server monitoring:

TaskCommandUse When
Memory overviewfree -hChecking available memory
Top processeshtopFinding resource-hungry processes
Disk spacedf -hChecking storage usage
System loaduptimeChecking server health
Service statussystemctl status <service>Verifying service is running
Service logsjournalctl -u <service> -n 50Troubleshooting errors
Restart servicesystemctl restart <service>After config changes
DB connectionssudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;"Checking database load

Check current memory usage:

Terminal window
free -h

Example Output:

total used free shared buff/cache available
Mem: 15Gi 8.2Gi 1.1Gi 234Mi 6.1Gi 6.5Gi
Swap: 2.0Gi 512Mi 1.5Gi

Get comprehensive memory information:

Terminal window
cat /proc/meminfo

Show memory in megabytes (easier to read):

Terminal window
free -m

Watch memory usage in real-time (updates every 2 seconds):

Terminal window
watch -n 2 free -h

Monitor memory, swap, and I/O (5 samples, 1 second apart):

Terminal window
vmstat 1 5

Example 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

Launch interactive process monitor:

Terminal window
htop

If htop not installed:

Terminal window
sudo apt install htop

Show top 20 processes by memory usage:

Terminal window
ps aux --sort=-%mem | head -20

Example Output:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
postgres 1234 2.1 15.3 2456780 2401234 ? Ss Jan30 45:12 postgres: main
node 5678 1.8 12.4 1834560 1945678 ? Ssl Jan30 32:45 node /var/www/sansa-frontend

Show top 20 processes by CPU usage:

Terminal window
ps aux --sort=-%cpu | head -20

Filter for specific application type:

Terminal window
# Python processes
ps aux | grep python --sort=-%mem | head -10
# Node.js processes
ps aux | grep node --sort=-%cpu | head -10

Check server load and uptime:

Terminal window
uptime

Example Output:

11:45:23 up 45 days, 3:12, 2 users, load average: 0.52, 0.48, 0.45

Check disk space across all mounted filesystems:

Terminal window
df -h

Example Output:

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 80G 53G 24G 69% /
/dev/sdb1 200G 142G 48G 75% /var

Check specific directory sizes:

Terminal window
du -sh /var/www/*
du -sh /var/log/*

Check swap usage:

Terminal window
swapon --show

Example Output:

NAME TYPE SIZE USED PRIO
/swapfile file 2G 512M -2

Monitor disk I/O (5 samples, 1 second apart):

Terminal window
iostat -x 1 5

Example Output:

Device r/s w/s rkB/s wkB/s await %util
sda 12.3 45.6 234.5 1234.5 5.23 8.45

Show all active queries (excluding idle connections):

Terminal window
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;

Count total active connections:

Terminal window
sudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;"

Show connections per database:

Terminal window
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 | 5

Check maximum connections allowed:

Terminal window
sudo -u postgres psql -c "SHOW max_connections;"

Check shared buffers (memory for caching):

Terminal window
sudo -u postgres psql -c "SHOW shared_buffers;"

Check specific database size:

Terminal window
sudo -u postgres psql -c "SELECT pg_size_pretty(pg_database_size('sansa_production'));"

Check all database sizes:

Terminal window
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 MB

Check table sizes in a database:

Terminal window
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;"

Individual services:

Terminal window
systemctl status autoslip
systemctl status sansa-backend
systemctl status sace-backend
systemctl status tumi-backend
systemctl status prospectiq-api
systemctl status postgresql
systemctl status redis
systemctl status nginx

Check multiple services at once:

Terminal window
systemctl status sansa-backend tumi-backend sace-backend postgresql redis nginx

Check all failed services:

Terminal window
systemctl --failed

Last 50 lines:

Terminal window
journalctl -u autoslip -n 50 --no-pager
journalctl -u sansa-backend -n 50 --no-pager

Follow logs in real-time:

Terminal window
journalctl -u <service> -f

Logs from specific time period:

Terminal window
# Today's logs
journalctl -u sansa-backend --since today
# Last hour
journalctl -u sansa-backend --since "1 hour ago"
# Specific date range
journalctl -u sansa-backend --since "2026-02-01" --until "2026-02-02"

Filter by log level:

Terminal window
# Errors only
journalctl -u sansa-backend -p err
# Warnings and errors
journalctl -u sansa-backend -p warning

Check all PM2 processes:

Terminal window
pm2 status

View specific application logs:

Terminal window
pm2 logs sansa-frontend
pm2 logs thrivesend
pm2 logs isutech-backend

Monitor PM2 dashboard:

Terminal window
pm2 monit

Show all listening ports and established connections:

Terminal window
ss -tuln

Example Output:

Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp 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:*

Show connection count by state:

Terminal window
ss -s

Example Output:

Total: 1234
TCP: 567 (estab 234, closed 123, orphaned 0, timewait 45)

See what’s listening on a specific port:

Terminal window
sudo ss -tulpn | grep :8001
sudo ss -tulpn | grep :5432 # PostgreSQL
sudo ss -tulpn | grep :6379 # Redis

Step 1: Identify memory hogs

Terminal window
ps aux --sort=-%mem | head -10

Step 2: Check for memory leaks

Terminal window
# Monitor memory over time
watch -n 5 'ps aux --sort=-%mem | head -10'

Step 3: Clear page cache (SAFE - won’t affect running processes)

Terminal window
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

Step 4: Check for zombie processes

Terminal window
ps aux | grep -w Z

Step 5: Restart problematic service

Terminal window
# If a specific service is using too much memory
sudo systemctl restart <service-name>

Step 1: Identify CPU hogs

Terminal window
ps aux --sort=-%cpu | head -10

Step 2: Check system load

Terminal window
uptime

Step 3: Monitor in real-time

Terminal window
htop
# Press F6 to sort by CPU%

Step 4: Investigate specific process

Terminal window
# Get detailed info about a process
ps -p <PID> -o pid,cmd,%mem,%cpu,etime
# Check what files the process has open
sudo lsof -p <PID>

Step 1: Find what’s using space

Terminal window
df -h
du -sh /var/www/* | sort -h
du -sh /var/log/* | sort -h

Step 2: Clear old logs

Terminal window
# Clear systemd journal logs older than 7 days
sudo journalctl --vacuum-time=7d
# Clear old nginx logs
sudo find /var/log/nginx -name "*.log.*" -mtime +30 -delete

Step 3: Find large files

Terminal window
sudo find /var -type f -size +100M -exec ls -lh {} \; | sort -k5 -h

Step 4: Check for deleted files still held open

Terminal window
sudo lsof | grep deleted | grep -v "/tmp"

Step 1: Check active connections

Terminal window
sudo -u postgres psql -c "SELECT count(*), state FROM pg_stat_activity GROUP BY state;"

Step 2: Find long-running queries

Terminal window
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)

Terminal window
# Be VERY careful with this command
sudo -u postgres psql -c "SELECT pg_terminate_backend(<PID>);"

Step 4: Restart application to release connections

Terminal window
sudo systemctl restart sansa-backend
# or
pm2 restart sansa-frontend

Run this comprehensive check when investigating issues:

#!/bin/bash
# Quick Health Check Script
echo "=== SYSTEM HEALTH CHECK ==="
echo ""
echo "--- Uptime & Load ---"
uptime
echo ""
echo "--- Memory ---"
free -h
echo ""
echo "--- Disk Space ---"
df -h | grep -E '(Filesystem|/dev/)'
echo ""
echo "--- Top 5 Memory Processes ---"
ps aux --sort=-%mem | head -6
echo ""
echo "--- Top 5 CPU Processes ---"
ps aux --sort=-%cpu | head -6
echo ""
echo "--- Service Status ---"
systemctl status nginx --no-pager | grep Active
systemctl status postgresql --no-pager | grep Active
systemctl status redis --no-pager | grep Active
echo ""
echo "--- PostgreSQL Connections ---"
sudo -u postgres psql -c "SELECT count(*) as total_connections FROM pg_stat_activity;" 2>/dev/null
echo ""
echo "--- Failed Services ---"
systemctl --failed --no-pager

Save and run:

Terminal window
nano ~/health-check.sh
chmod +x ~/health-check.sh
~/health-check.sh

Use these thresholds to determine when to take action:

MetricNormalWarningCriticalAction
Available Memory> 20%10-20%< 10%Restart services, investigate leaks
Swap Usage< 25%25-75%> 75%Add RAM, optimize applications
MetricNormalWarningCriticalAction
Load Average (4 cores)< 4.04.0-8.0> 8.0Scale up, optimize code
CPU Wait (wa)< 5%5-15%> 15%Check disk I/O, optimize queries
MetricNormalWarningCriticalAction
Disk Usage< 80%80-90%> 90%Clean logs, archive data
Disk I/O Await< 10ms10-50ms> 50msCheck slow queries, optimize
MetricNormalWarningCriticalAction
Active Connections< 50% max50-80% max> 80% maxScale connections, check leaks
Long Queries< 5s5-30s> 30sOptimize queries, add indexes



Last Updated: 02/01/2026 | Document Owner: Operations Team | Version: 1.0