Skip to content

Instantly share code, notes, and snippets.

@robert-moses
Created August 9, 2018 12:37
Show Gist options
  • Save robert-moses/4ff4d3dacaf6b8da3d30c512a5a1e1ef to your computer and use it in GitHub Desktop.
Save robert-moses/4ff4d3dacaf6b8da3d30c512a5a1e1ef to your computer and use it in GitHub Desktop.
linux website quick system check
#!/bin/bash
# Quick System Check Script
# Author: Robert Moses
## Logging setup
> quick_system_check.log
exec > >(tee -a quick_system_check.log)
exec 2> >(tee -a quick_system_check.log >&2)
#Set Date
MYDAY=`date +%d`
#Set Hour
MYHOUR=`date +%k`
#
# START TESTS
#
echo Starting Quick System Check
echo --------------------
# Check for disk usage
echo Checking disk usage
df -h
echo --------------------
# Check for httpd PID
echo Checking for httpd/Apache PID
pidof httpd
echo Checking for NginX PID
pidof nginx
echo --------------------
# Current top proccesses
echo Current Top 20 Memory Consuming Processes
ps auxf | sort -nr -k 4 | head -20
echo --------------------
echo Current Top 20 CPU Consuming Processes
ps auxf | sort -nr -k 3 | head -20
echo --------------------
##SAR reports
# Check load averages
echo Checking current load avearges at 5sec 5times
sar -q 5 5
echo --------------------
# Historical load - last hour
echo Checking historical load averages last hour
sar -q -f /var/log/sa/sa$MYDAY -s $MYHOUR:00:00
echo --------------------
## Apache Checks
# Check Apache MaxClients
echo Checking httpd Errors for MaxClient
grep MaxClien /var/www/vhosts/*/statistics/logs/error_log | tail
grep MaxClien /var/www/vhosts/*/logs/*/error_log | tail
grep MaxClien /usr/local/apache/logs/error_log | tail
grep MaxClien /var/log/httpd/*error_log | tail
grep MaxClien /var/log/httpd/*error_log | tail
echo --------------------
# Check Apache Premature end of script headers
echo Checking httpd Errors for Premature end of script headers
grep Premature /var/www/vhosts/*/statistics/logs/error_log | tail
grep Premature /var/www/vhosts/*/logs/*/error_log | tail
grep Premature /usr/local/apache/logs/error_log | tail
grep Premature /var/log/httpd/*error_log | tail
grep Premature /var/log/httpd/*error_log | tail
echo --------------------
# Check Checking PHP Out of Memory Errors
echo Checking PHP Out of Memory Errors
grep '(allocated' /var/www/vhosts/*/statistics/logs/error_log | tail
grep '(allocated' /var/www/vhosts/*/logs/*/error_log | tail
grep '(allocated' /usr/local/apache/logs/error_log | tail
grep '(allocated' /var/log/httpd/*error_log | tail
grep '(allocated' /var/log/httpd/*error_log | tail
echo --------------------
#
#
# Check current connections on port 80
echo Checking current connections on port 80
netstat -plane | grep :80 | wc -l
echo --------------------
## Check last SSH login failures
echo Check last SSH login failures
less /var/log/secure | grep failure | tail -n 20
echo --------------------
#
echo End of Quick System Check Script: see quick_system_check.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment