In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to use paramiko to monitor Oracle alert logs, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Environment settin
Linux system is Centos 6.8,
Python environment is Python 3.6
Connect to Unix class server module: paramiko
Commands used
We use the grep command to determine whether there are ORA Error and Checkpoint alarms in the alert log
Monitor alert logger
The following program uses paramiko to connect to the linux/Unix server, view the alert log and view the alarm keywords, and enter the result when an error is found
We can for loop batch monitoring and send the results to the designated mailbox, this part is up to you to write, you can refer to my previous article
In this way, automatic monitoring can be achieved, which can greatly reduce the daily work of DBA.
Automatic monitoring of multiple Oracle tablespaces
Use Python to send mail
The program name is: checkoraclelog.py
#! / usr/bin/python#coding=utf8import paramikodef oraclelog (ssh,path): alert_log= [] command='grep-E\ 'ORA- | Checkpoint | Error\' + path stdin,stdout Stderr=ssh.exec_command (command) err=stderr.readlines () if len (err)! = 0: print (err) return False else: stdout_content=stdout.readlines () if len (stdout_content)! = 0: result='\ n'.join (stdout_content) result=' Oralce log on'+ hostname+ 'have errors\ nresume' The log path is'+ path+'\ n'+result alert_log.append (result) return alert_log else: return 'noerror'if _ _ name__ =' _ _ main__': hostname='10.60.14.60' username='root' password='password' try: # define the ssh variable ssh = paramiko.SSHClient () using the SSHClient method Ssh.set_missing_host_key_policy (paramiko.AutoAddPolicy ()) # Connect to the target server ssh.connect (hostname=hostname Port=22,username=username,password=password) path='/oracle/NP1/saptrace/background/alert_NP1.log' alert_log=oraclelog (ssh Path) ssh.close () if alert_log: if alert_log! = 'noerror': for i in alert_log: print (I) else: print (' There is no ORA- error on'+ hostname) except Exception as e: print (hostname+''+ str (e)) verification result
Normally, if there are errors such as ORA, the result will be output.
The above is all the contents of the article "how to use paramiko to monitor Oracle alert logs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.