Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linux script to check oracle agent's status 1

Status
Not open for further replies.

yorge

Programmer
Aug 2, 2011
39
0
0
PH
Hi Guys,

Can anybody tell me if it's possible via linux script to check oracle agent's status? If it's stopped/down, then do a emctl start agent. Can anybody please show me some code lines.

Thanks in advance,
yorge
 
Something like this?
Code:
#!/bin/bash
if ! emctl status agent >/dev/null
then
   emctl start agent
fi
 
hi stefanhei,

Can I add here?
How about for checking of database and listener status? To check if down or inactive, then start these 2 if ever. Can you please show me how?

thanks,
yorge
 
One method of checking if the database instance is up is to look for its pmon-process.
To check for the listener the returncode of lsnrctl can be used like that of emctl.
Code:
#!/bin/bash

[ -z "$ORACLE_SID" ] && echo "\$ORACLE_SID not set" && exit 1

if ! lsnrctl status >/dev/null
then
   lsnrctl start
fi

if ! ps -eaf |grep -v grep |grep pmon_$ORACLE_SID >/dev/null
then
   sqlplus / as sysdba <<EOF
startup;
EOF
fi

if ! emctl status agent >/dev/null
then
   emctl start agent
fi
The script only checks if $ORACLE_SID is set. It assumes that the environment is set up correctly and the user invoking it can connect as sysdba.
 

How about using Enterprise Manager DB console (or Grid control) to send you an email if something is down...
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top