Hey everyone,
Hope you’re doing good.
Sometime ago, an old client called saying that they have migrated their Linux servers from RHEL6 to RHEL7. They have done a new installation instead upgrading OS.
Because of this movement, OEM Agent was not starting automatically. This happened because as the agent was not reinstalled (and in fact there is no need for this), the new server didn’t have the agent initialization files and also the agent configuration file behind /etc.
The files are:
Os arquivos são:
- /etc/oragchomelist
- /etc/rc.d/init.d/gcstartup
- /etc/rc.d/init.d/lockgcstartup
- /etc/rc.d/init.d/unlockgcstartup
There are also symbolic links that points to the scripts mentioned above:
- /etc/rc.d/rc0.d/K19lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc0.d/K19unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc0.d/K19gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc1.d/K19lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc1.d/K19unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc1.d/K19gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc2.d/S98gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc2.d/S98lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc2.d/K19unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc2.d/K19gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc3.d/S98gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc3.d/S98lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc3.d/K19unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc3.d/K19gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc4.d/S98lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc4.d/S98unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc4.d/S98gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc5.d/S98lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc5.d/K19unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc5.d/K19gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc5.d/S98gcstartup -> ../init.d/gcstartup
- /etc/rc.d/rc6.d/K19lockgcstartup -> ../init.d/lockgcstartup
- /etc/rc.d/rc6.d/K19unlockgcstartup -> ../init.d/unlockgcstartup
- /etc/rc.d/rc6.d/K19gcstartup -> ../init.d/gcstartup
I’ll create another blog post soon showing how to fix this issue, as the main goal of this blog post is to create a shell script to monitor if agent is running in health state, and, if agent is not running or if agent is not in health state, an e-mail message will be sent (your server must have the capability to send e-mails).
Also, after every execution of the script, a new line will be added to a log file (for control purpose).
Basically, script will do some checks:
- How many (count) agent processes are running.
- What is the agent status.
After this, we’ll have an IF that will check two conditions:
- If count is greater than zero (here we are expecting to have 1 as value).
- If agent status is Agent is Running and Ready.
If both conditions are true, the script will simply add a new line in the log file as the example below describes, in the format:
YYYYMDD-HH24MI:OK
If one of the conditions (or all) are not true, this means that:
- Count of processes is zero.
- Even that count is 1, agent can be running with some issue and is not being listed as Running and Ready.
If this happens, an e-mail message will be sent saying that agent is down, and also a new line will be added in the log file, using the following format:
YYYYMMDD-HH24MI:NOK
Please,replace the value of variable EMAIL_ID from your_email@your_domain.com to your e-mail address or the distribution list used by your team.
OK, let’s go to the script!
#!/bin/bash ################################################### # # Script to check if OEM agent is running # ################################################### export ORACLE_HOME=/oracle/PE1/OEM_13c_Agent/agent_13.4.0.0.0 export AGENT_INSTANCE_HOME=/oracle/PE1/OEM_13c_Agent/agent_inst export AGENT_BASE_DIR=/oracle/PE1/OEM_13c_Agent export PATH=${AGENT_INSTANCE_HOME}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/oracle/PE1:.:/opt/VRTSvcs/bin export NAME_PATTERN=OEM_Agent_Check export WORK_DIR=/oracle/PE1/SCRIPT/${NAME_PATTERN} export TZ=America/Chicago export DATE_EXEC=$(date +"%Y%m%d-%H%M") export EMAIL_ID=your_email@your_domain.com AGENT_PROCESS_COUNT=$(ps -ef |grep ${AGENT_INSTANCE_HOME} |grep -v grep | wc -l) AGENT_STATUS=$(${AGENT_INSTANCE_HOME}/bin/emctl status agent |grep -i running) if [ ${AGENT_PROCESS_COUNT} -gt 0 ] && [ "${AGENT_STATUS}" == "Agent is Running and Ready" ]; then echo ${DATE_EXEC}:"OK" >> ${WORK_DIR}/.execution_history.log exit else mail -s "PE1 OEM Agent is down - ${DATE_EXEC} CST" ${EMAIL_ID} < /dev/null echo ${DATE_EXEC}:"NOK" >> ${WORK_DIR}/.execution_history.log fi
Hope this helps.
Peace,
Vinicius
Related posts
About
Disclaimer
My postings reflect my own views and do not necessarily represent the views of my employer, Accenture.