Small Bash script to Extract Server Info
Small Bash script to Extract Server Info
#!/bin/bash
#Manas Tripathy- manas.tri@gmail.com
for i in `cat /home/manas/server_list.txt`
do
echo "Server Name : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i hostname -s)"
echo "Processor Count : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i /bin/grep processor -c /proc/cpuinfo)"
echo "Total Memory : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i free -m | awk '{print $2}' | head -2 | tail -1)"
echo "Total Used : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i free -m | awk '{print $3}' | head -2 | tail -1)"
echo "Total Free : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i free -m | awk '{print $4}' | head -2 | tail -1)"
echo "Load Avarage : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i w | head -1 | awk '{print $12}')"
echo "FileSystem Size : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i df -h | awk '{print $1" "$5}')"
done
#Manas Tripathy- manas.tri@gmail.com
for i in `cat /home/manas/server_list.txt`
do
echo "Server Name : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i hostname -s)"
echo "Processor Count : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i /bin/grep processor -c /proc/cpuinfo)"
echo "Total Memory : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i free -m | awk '{print $2}' | head -2 | tail -1)"
echo "Total Used : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i free -m | awk '{print $3}' | head -2 | tail -1)"
echo "Total Free : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i free -m | awk '{print $4}' | head -2 | tail -1)"
echo "Load Avarage : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i w | head -1 | awk '{print $12}')"
echo "FileSystem Size : $(sshpass -p 'password' /usr/bin/ssh -oStrictHostKeyChecking=no $i df -h | awk '{print $1" "$5}')"
done
No comments