Thursday, 11 January 2018

Multiple server monitoring script

Get the details from many servers at Desktop (Script for Multiple Servers Monitoring at Desktop)
This script logic is useful when you want to extract the data (from database or from OS) from different servers.
For example I have to extract data from 4 servers.

Pre-requisites :- Below are the pre-requisites
1) Connectivity should be there from your desktop to all servers from where you want to extract the data. 
2) "sshpass" package should be installed on your desktop machine (Desktop machine should be Linux machine)
3) You should have Credentials (User/Password and IP) for all servers

Note :- 1) To check the connectivity you can use below command from terminal
           ssh -oPort=922 user@IP1
        2) To install the "sshpass" package you can use below command
           sudo yum -y install sshpass*
Step1:- Make a separate directory for same by below command
        mkdir monitoring
Step2:- Move to that directory by below command
        cd monitoring
Step3:- Make a script with below code
sshpass -p "password" ssh -q -oPort=922 user@IP1 <>FINAL.txt
sshpass -p "password" ssh -q -oPort=922 user@IP2 <>>FINAL.txt
sshpass -p "password" ssh -q -oPort=922 user@IP3 <>>FINAL.txt
sshpass -p "password" ssh -q -oPort=922 user@IP4 <>>FINAL.txt

Ctr+d (For Save and Exit)

Step4:-Now make,, and

Sample code for

export ORACLE_HOME=<value for ORACLE_HOME>
export ORACLE_SID=<value for ORACLE_SID>
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch:/usr/bin:/etc:$ORACLE_HOME/lib:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/pacs:.

sqlplus -s db_user/db_pass<<STMT
set feedback off;
set heading off;

!echo "Employee Data"

select * fro emp;

!echo "Department Details"

select * from dept;


Same way you can create other host script .

Step5:- Give the executable permission to all scripts by below command

chmod a+x *.sh

Step6:- Now execute the and you will get the all data in FINAL.txt


No comments:

Post a Comment

Cloning database with RMAN

Below are the steps to clone production database(primedb) to UAT database(clonedb)   STEP1 :- Check the both servers are able to connect ...