In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
PYTHON test script how to write, in response to this problem, this article details the corresponding analysis and solution, hoping to help more want to solve this problem of small partners to find a simpler and easier way.
#!/ usr/bin/python
# -*- coding: UTF-8 -*-
#CHECK ORACLE
SID="tcbjeas"
CHECK_LOG_FILE="tcbjeas.out"
FLAG=0
import os
my_file='/tmp/out.txt'
if os.path.exists(my_file):
#Delete files in two ways.
os.remove(my_file)
#Check whether the database process is running normally. If it is not running normally, the relevant process failure information will be output, and the following check information will be stopped.
#If it works correctly, the database is available, continue to check the following information.
#check pmon process
import os
run=os.popen("ps -ef |grep ora_pmon_$SID |grep -v grep|wc -l").read()
if "0" in run:
FLAG=1
f=open("out.txt","w")
try:
f.write('WARNING!!! ora_pmon_$SID! process is not running! '+'\n')
finally:
f.close()
#check smon process
import os
run=os.popen("ps -ef |grep ora_smon_$SID |grep -v grep|wc -l").read()
if "0" in run:
FLAG=1
f=open("out.txt","a")
try:
f.write('WARNING!!! ora_smon_$SID! process is not running! '+'\n')
finally:
f.close()
#check dbwr process
import os
dbwr=os.popen("ps -ef |grep ora_dbw0_$SID |grep -v grep|wc -l").read()
if "0" in dbwr:
FLAG=1
f=open("out.txt","a")
try:
f.write('WARNING!!! ora_dbw0_$SID! process is not running! '+'\n')
finally:
f.close()
#check lgwr process
import os
lgwr=os.popen('ps -ef |grep ora_lgwr_$SID |grep -v grep|wc -l').read()
if "0" in lgwr:
print "lgwr"
FLAG=1
f=open("out.txt","a")
try:
f.write('WARNING!!! ora_lgwr_$SID! process is not running! '+'\n')
finally:
f.close()
if FLAG==1:
f=open("out.txt","a")
try:
f.write('Warning!!! Oracle Instance $SID Is Down! '+'\n')
finally:
f.close()
else:
f=open("out.txt","a")
try:
f.write('OK,Oracle Process Are Running Normal! '+'\n')
finally:
f.close()
#Check whether database monitoring is running normally. If it is not running normally, a warning message will be issued. If there is no warning message, the monitoring is running normally.
#check listener
import os
listen=os.popen("$ORACLE_HOME/bin/lsnrctl status|grep -i 'Instance'|grep -v grep|wc -l").read()
if "0" in listen:
f=open("out.txt","a")
try:
f.write('Warning!!! Listener is not running normal! '+'\n')
finally:
f.close()
else:
f=open("out.txt","a")
try:
f.write('OK,Listener is running normal! '+'\n')
finally:
f.close()
#Check whether the database can be connected, if it cannot be connected, a warning message will be issued (not open or not connected)
#If there is no warning message, the monitor is working properly.
import os
os.popen('sh sql.sh')
import os
connect=os.popen("grep -i 'OPEN' /tmp/sql.txt|grep -v grep|wc -l").read()
if "1" in connect:
f=open("out.txt","a")
try:
f.write('OK,Oracle Connect Normal! '+'\n')
finally:
f.close()
else:
f=open("out.txt","a")
try:
f.write('Warning!! Database Is Not Open'+'\n')
finally:
f.close()
cat sql.sh
#!/ bin/bash
sqlplus user/passwd@orcl
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.