We have a centralized UNIX/Solaris server from where we can actually ssh to all other UNIX/Solaris servers...I need to write a script that reside on this centerlized server and do FileSystem monitoring (basically run df -h or -k) of other remote servers and then send an email to me something like below (just an example)......we have got plenty of these server running many databases
for host in `cat /path/to/hostlist`; do echo $host; echo "========"; ssh $host df -h | awk '{print $1"\t"$5}'; echo; done >> output_file [/code
Too fast, you forgot the quote's for remote command ... and try to win the UUOC award in the same time :rolleyes:
while read H; do ssh $H "df -h" | awk 'BEGIN{printf "%s\n%s\n","'"$H"'","========"}NR>1{printf "%s\t%s\n",$1,$5}END{printf "\n"}';done < /path/to/hostlist > output_file
Thanks...few things to clear; we do need password to connect to remote hosts from this centralized server.....
I have changed things a bit; I have managed to ssh <sever1> and run the script located on the remote server (i.e. server1); but output of the script is needed to send back to the centralized server; the script is below that I am planing to run on each server.....
how can I send output of below script back to centralized server in a file; and i need that file mailed to me?
--Script to connect to remote servers from centeralized host
while read H; do ssh $H /ora/rman/scripts/bk1.sh 'BEGIN{printf "%s\n%s\n","'"$H"'","========"}NR>1{printf "%s\t%s\n",$1,$5}END{printf "\n"}';done < /export/h
ome/oracle/servers.lst > out.txt
File servers.lst contains
server1
server2
But I think its only working for server1
--The script will go to the archivelog directory and check for successful and failed archivelog backups (each server hosts many databases)
chkbck ()
{
for i in `ls /ora/rman/logs/`;
do
find /ora/rman/logs/$i/backup_a*.log -mtime -1 2>/dev/null
done
}
for i in `chkbck`;
do
print $i | cut -d"_" -f3
print $i
grep Exit $i