-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresmon.sh
More file actions
27 lines (23 loc) · 719 Bytes
/
resmon.sh
File metadata and controls
27 lines (23 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
#Script to collect resource usage from diff machines
for i in `cat /root/servers.txt`
do
echo -e "\nChecking Network connectivity for $i"
ping -c3 $i &>/dev/null
if [ $? -eq 0 ];then
echo "$i is pinging, continuing to next step"
else
echo "$i is not pinging,Skipping to next server"
continue
fi
echo -e "\e[4;31mResource details of $i server\e[0m"
echo -e "\e[4m MEMORY DETAILS\e[0m"
ssh $i free -m |awk '/Mem/ {print "TOTAL MEM = " $2}'
ssh $i free -m |awk '/Mem/ {print "USED MEM = " $3}'
ssh $i free -m |awk '/Mem/ {print "FREE MEM = " $4}'
echo -e "\e[4m CPU LOAD\e[0m"
ssh $i uptime | awk -F, '{print $3}'
echo -e "\e[4m ROOT FS DETAILS\e[0m"
ssh $i df -h /
done
echo "Script completed"