Monday, January 20, 2014

Check the logfiles of all servers from one server using ssh

Some time we need to check backups logs or any other logs from all servers daily  . For this we need to login to each server and verify logfiles . This script automatically log into each server and check logfiles .

1)
ssh 10.168.1.10  "VAR1=\"/\`crontab -l|grep -v \"#\"|grep rman_full|cut -d\"/\" -f2-\`\";cd \$(dirname \`grep LOG_FILE= \$VAR1|cut -d\"=\" -f2-\`);head \`ls -tr full_*|tail -n1\`;tail \`ls -tr full_*|tail -n1\`;grep \"RMAN-00569\" \`ls -tr full_*|tail -n1\`;echo \"   \"; echo \"Logfile Name Is -----> \`ls -tr full_*|tail -n1\`\" "

2)
ssh 10.168.1.50  "VAR1=\"/\`crontab -l|grep -v \"#\"|grep rman_full|cut -d\"/\" -f2-\`\";VAR2=\"/\`grep saas5 \$VAR1|cut -d\"/\" -f2-\`\";cd \$(dirname \`grep LOG_FILE= \$VAR2|cut -d\"=\" -f2-\`);head \`ls -tr full_saas5*|tail -n1\`;tail \`ls -tr full_orcl5*|tail -n1\`;grep \"RMAN-00569\" \`ls -tr full_saas5*|tail -n1\`;echo \"   \"; echo \"Logfile Name Is -----> \`ls -tr full_orcl5*|tail -n1\`\""