Shell-script - How do I find filesystem usage on multiple server, Find disk usage on multiple servers

How do I find filesystem usage on multiple server

How do I find filesystem usage on multiple server?

Find disk usage on multiple servers

 # awk '{print $2,$3}' monitoring_alerts | tr -d '}' > dfinput
Using output field separator OFS
 # awk 'BEGIN{OFS=":";} {print $2,$3;}' monitoring_alerts | tr -d '}' > dfinput
In the above you can see we have used ":" as field seperator. When we pass monitoring dfinput file as input for shell script, bash parse the file as space seperated. So here we create a file with a delimiter as we wish and parse it after reading the line in shell script.

 for line in `cat input`
 do
  echo $line >> diskcheck
  word=$(echo "$line" | tr ":" "  ")
  arr=($word)
  len="${#arr[@]}"
  echo "$len"
  dfoutput=$(ssh root@${arr[0]} "df -hP ${arr[1]}")
  echo "$dfoutput" >> diskcheck
  echo "=============================" >> diskcheck
done
In the above example you can see we send dfinput as input file for shell script and parse the output into a variable and use the array value one as input for server name and other variable as input to find disk usage. This bash or shell script can be used to find usage of specific filesystem on multiple servers. This script was my requirement to automate the script, you can customize it as per ur requirement.

The topic on Shell-script - How do I find filesystem usage on multiple server is posted by - Guru

Hope you have enjoyed, Shell-script - How do I find filesystem usage on multiple serverThanks for your time

Tech Bluff