Archive for the ‘Server Performance’ Category


Script

Run script in Local Machine save as “Server Performance.sh”

#!/bin/bash
clear

##variable Decalation Part
ip=$1
#SCRIPT STARTED

echo -e “\n\t\t\t $ip Server Performance\n\n ”
echo -e “\tNetwork Status\n”

# SERVER REACHABLE STATUS

COUNT=`ping -c2 $ip | grep received |awk ‘{print $4}’`

#check whether server is reachable Status
if [ $COUNT -eq 2 ]
then
echo -e “Reachable : Server is up”
else
echo -e “Reachable : Server is down”
fi

#Server Firwall Status

IT=`iptables -L | wc -l`

if [ $IT -eq 8 ]
then
echo -e “Firewall : Disabled \n”
else
echo -e “FIRWALL¬†¬† : Enabled \n”
fi

echo -e “\tPhysical Status\n ”

#Server CPU Usage calculations

CU=`mpstat | awk ‘$12 ~ /[0-9.]+/ { print 100 – $12″%” }’`

echo -e “CPU Usage (%) : $CU”

# Server Memory Usage calculations
MU=`free -m | grep Mem | awk ‘{print $3/$2*100.0}’|cut -d”.” -f1`
U=`free -m | grep Mem | awk ‘{print $3}’`
F=`free -m | grep Mem | awk ‘{print $4}’`
C=`free -m | grep Mem | awk ‘{print $7}’`
echo -e “Memory Used (MB) : $U ”
R=`df -h | grep -w / | awk ‘{print $4}’|cut -d % -f1`
echo -e “Memory Free (MB) : $F ”
echo -e “Memory Clear (MB) : $C ”
echo -e “Disk Usage / (%) : $R ”

echo -e “\n\tProcess Status”
echo -e “\nTop 3 Memory Eating Process\n ”
ps axo rss,comm,pid | awk ‘{ proc_list[$2]++; proc_list[$2 “,”1] += $1; } END { for (proc in proc_list) { printf(“%d\t%s\n”, proc_list[proc “,” 1],proc); }}’ | sort -n | tail -n 3 | sort -rn | awk ‘{$1/=1024;printf “%.0fMB\t”,$1}{print $2}’

 

Output

Screenshot_4

Screenshot_8

Get Server Performance report from Remote Server run below script and save as “SPRM.sh”

#!/bin/bash
ip=$1
port=$2
user=$3
pass=$4

sshpass -p “$pass” scp -P $port /root/ServerPerformence.sh $user@$ip:/root/

clear

sshpass -p “$pass” ssh -p $port -o StrictHostKeyChecking=no $user@$ip “bash /root/ServerPerformence.sh $ip”

 

Output

Screenshot_7

Screenshot_9