Hostxpeed
Login Get Started →
Server Management

How to Set Up Server Health Monitoring

5 min read
22 views
Jun 10, 2026

Prerequisites

Before setting up health monitoring, make sure you have:

  • SSH access to your VPS
  • Root or sudo privileges

Step 1: Create Health Check Script

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22
sudo nano /usr/local/bin/health-check.sh
#!/bin/bash
# CPU Check
CPU_LOAD=$(uptime | awk -F 'load average:' '{print $2}' | cut -d, -f1 | sed 's/ //g')
THRESHOLD_CPU=2.0
if (( $(echo "$CPU_LOAD > $THRESHOLD_CPU" | bc -l) )); then
    echo "High CPU load: $CPU_LOAD" | mail -s "Health Alert: CPU" admin@example.com
fi

# Disk Check
DISK_USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
THRESHOLD_DISK=85
if [ $DISK_USAGE -gt $THRESHOLD_DISK ]; then
    echo "Low disk space: $DISK_USAGE%" | mail -s "Health Alert: Disk" admin@example.com
fi

# Memory Check
MEM_AVAIL=$(free | grep Mem | awk '{print $7/$2 * 100.0}')
if (( $(echo "$MEM_AVAIL < 10" | bc -l) )); then
    echo "Low memory available: $MEM_AVAIL%" | mail -s "Health Alert: Memory" admin@example.com
fi

# Service Check
SERVICES="nginx mysql postfix"
for svc in $SERVICES; do
    if ! systemctl is-active --quiet $svc; then
        echo "$svc is not running" | mail -s "Health Alert: Service Down" admin@example.com
    fi
done
sudo chmod +x /usr/local/bin/health-check.sh

Step 2: Schedule via Cron (Every 15 Minutes)

sudo crontab -e
*/15 * * * * /usr/local/bin/health-check.sh

Step 3: Use Alternative: HetrixTools or UptimeRobot (External)

Sign up for free monitoring services that ping your server and alert via email/Slack.

Step 4: Set Up Monitoring via Hostxpeed Portal

Your Hostxpeed service detail page already shows real-time stats; you can use third-party tools to get alerts.

✅ Server health monitoring active. Alerts will be sent for high resource usage or service failures.

Was this article helpful?