Shell script, for to get server uptime,OS version and additional partitions info get


#1

Hi All,
i have Jump server and that jump server having password less with all client machine.

I want to get server UPtime, OS version and additional partitions which is mapped via “under” /Prod-1" only single partitions info required.

the collected output will be stored in a single file.


#2

any one please help to get details through script.


#3

you can place all the server names into one text file, sample list

remove the " from the beginning of the and end of the script

collect_sysinfo.sh
"#!/bin/bash
for srv in cat list
do

srv_uptime=ssh -q $srv uptime
srv_os=ssh -q $srv cat /etc/redhat-release
srv_kernel=ssh -q $srv uname -r
srv_disk=`ssh -q $srv df -Ph |grep -i Prod-1"

printf "Server Name = $srv \n Server Uptime \n $srv_uptime \n OS = $srv_os \n Kernel=$srv_kernel \n Disk Usage \n $srv_disk \n --------------------------------------------------- \n " >> server_report.txt

done "


#4

tried but need to modify the script.

cat list
192.168.0.112
192.168.0.10

cat collect_sysinfo.sh
#!/bin/bash
for srv in cat /export/home/sunht/ritesh-script/list
do

srv_uptime=ssh $srv uptime
srv_os=ssh $srv cat /etc/redhat-release
srv_kernel=ssh $srv uname -r
srv_disk=ssh $srv df -Ph |grep -i “Prod-1”

printf "Server Name = $srv \n Server Uptime \n $srv_uptime \n OS = $srv_os \n Kernel=$srv_kernel \n Disk Usage \n $srv_disk \n --------------------------------------------------- \n " >> server_report.txt
done

#######
ritesh-script]$ ls
collect_sysinfo.sh list server_report.txt


#5

all srv_ = start and end with " ` " single code, which is below the esc button


#6

disk usage not working, trying to run below

#!/bin/bash

r_report.txt
for srv in cat list
do
srv_disk=ssh -q $srv df -h | grep -i " Prod-1"
#srv_disk=`ssh -q $srv df -h | grep -i “Prod-1” | awk ‘{print $5}’
printf " Disk Usage \n $srv_disk \n ---------------- \n " >> r_report.txt
done


#7

So what is better to do in this case? What if this won’t work at all ?