DEVOPS-PRACTICAL-PROBLEM-2

Practical Problem: Suppose you are working in a company where your manager share the list of servers and ask you to share the disk usage details of all the servers.How will you overcome with this problem ?

Solution:

#!/bin/bash
for i in $(cat hostname.txt)
do
ssh $i df -h
done

Output:

Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G  4.0K  3.9G   1% /dev
tmpfs           789M  1.4M  788M   1% /run
/dev/sda1       451G  148G  281G  35% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            3.9G  280M  3.6G   8% /run/shm
none            100M   68K  100M   1% /run/user


Here we are using a i variable in which we insert value from hostname.txt.After that will get the disk usage of the server.


For more practical problems please support us by purchasing the below books:


2. PYTHON & SHELL SCRIPTING:https://www.amazon.com/dp/B07L1SQFBM


Comments

Popular posts from this blog

Python & Shell Scripting Real Time Course Book & Videos

Top Five Devops Technical Interview QA Books

Linux-Command Hands-On (DF)