Last active
September 20, 2020 10:39
-
-
Save C00kiie/b26d958d6141034b4909c2ccec5eecf2 to your computer and use it in GitHub Desktop.
Quick Server diagnostics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# script: sas3/sas4 quick diagnoistics | |
## Author: Tyr4n7 | |
###### To Valahala! | |
separator_bar="----------------------------------------------------------------------------------------------"; | |
## check max_users ## | |
users_count=$(mysql -u sas -psas123 -s -N sas4 -e "select count(*) as c from sas_users" 2>/dev/null); # default passwords for sas4 | |
echo "SAS4 Current users: $users_count"; | |
## get license and expiration and max users ## | |
php -r '$sas=new \SAS4; $license = $sas->getLicense();echo "expiration: ".$license["exp"] . "\n"; echo "max_users: ". $license["mu"]." \n";' | |
echo $separator_bar; | |
#### print dmesg at the level of errors and warnings #### | |
echo "DMESG AT LEVEL ERROR/WARNING" | |
echo $separator_bar; | |
sudo dmesg --level warn,err | |
echo $separator_bar; | |
#### checking hardware capacity issues #### | |
echo "[*] Available memory:"; | |
free -h | |
echo $separator_bar; | |
echo "[*] Storage unit diganoists:"; | |
echo "[*] drivers:"; | |
lsblk; | |
echo "[*] Left space in drives:"; | |
df -kh; | |
echo $separator_bar; | |
#### Check if SAS processes are running ##### | |
echo "[*] Which SAS processes are running?"; | |
echo -ne "Process_FILE = > PID\n"; | |
ps aux | grep "sas_" | uniq | awk '{print $11 " => "$2}'; | |
echo $separator_bar; | |
############ mysqld & apache2 | |
echo "[*] Checking other services .. " | |
echo $separator_bar; | |
echo "[*] Is mysql running?" | |
mysqld_path="/run/mysqld/mysqld.pid" | |
mysqld_=$(cat $mysqld_path &> /dev/null) | |
if [ $? -eq 0 ]; | |
then | |
mysqld_=$(cat $mysqld_path); | |
echo "[*] Yes /var/mysqld/mysqld.pid => $mysqld_" | |
else | |
echo "[*] No" | |
fi | |
echo $separator_bar; | |
echo "[*] Is Apache2 running?" | |
apache2_path="/run/mysqld/mysqld.pid" | |
apache2d=$(cat $apache2_path &> /dev/null) | |
if [ $? -eq 0 ]; | |
then | |
apache2d=$(cat $mysqld_path); | |
echo "[*] Yes /var/run/apache2/apache2.pid => $apache2d" | |
else | |
echo "[*] No" | |
fi | |
echo $separator_bar; | |
output=$(tail /var/log/mysql/error.log &> /dev/null); | |
if [ $? -eq 0 ]; | |
then | |
echo "[*] Checking Mysql latest error logs (/var/log/mysql/error.log)" | |
tail /var/log/mysql/error.log; | |
echo $separator_bar; | |
fi | |
output=$(tail /var/log/apache2/access.log &> /dev/null); | |
if [ $? -eq 0 ]; | |
then | |
echo "[*] Checking Mysql latest error logs (/var/log/apache2/access.log" | |
tail /var/log/apache2/access.log; | |
echo $separator_bar; | |
fi | |
output=$(tail /var/log/apache2/error.log &> /dev/null); | |
if [ $? -eq 0 ]; | |
then | |
echo "[*] Checking apache2 latest error logs (/var/log/apache2/error.log" | |
tail /var/log/apache2/error.log; | |
echo $separator_bar; | |
fi | |
echo "[*] Done!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment