1.本地alert log
# ora_err.rb
# usage: ruby ora_err.rb < alert.log > ora_err.txt
require 'parsedate'
delimiter = "\t"
date_mask = '%Y-%m-%d %H:%M:%S'
months = { 'Jan'=>1, 'Feb'=>2, 'Mar'=>3, 'Apr'=>4, 'May'=>5, 'Jun'=>6,
'Jul'=>7, 'Aug'=>8, 'Sep'=>9, 'Oct'=>10, 'Nov'=>11, 'Dec'=>12 }
class OraErr
attr_reader :sqlcode, :begin_time, :sqlerrm
def initialize(sqlcode,begin_time,sqlerrm)
@sqlcode = sqlcode
@begin_time = begin_time
@sqlerrm = sqlerrm
end
end
this_log = nil
last_log = nil
this_time = nil
thisTime = nil
$stdin.each() { |line|
next if $stdin.eof
line.chomp!
if line =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)/ then
thisTime = Time.local(*ParseDate.parsedate(line))
elsif line =~ /^ORA-([0-9]+)/
sqlcode = $1
sqlerrm = line
this_log = OraErr.new(sqlcode,thisTime,sqlerrm)
if (last_log!=nil)
# print the last log
print \
last_log.begin_time.strftime(date_mask),delimiter,
last_log.sqlerrm,"\n"
end
last_log = this_log
this_log = nil
end
}
2.遠端alert log
#scan_remote.rb
#usage:ruby scan_remote.rb > scan.txt
require 'rubygems'
require 'net/ssh'
require 'parsedate'
delimiter = "\t"
date_mask = '%Y-%m-%d %H:%M:%S'
months = { 'Jan'=>1, 'Feb'=>2, 'Mar'=>3, 'Apr'=>4, 'May'=>5, 'Jun'=>6,
'Jul'=>7, 'Aug'=>8, 'Sep'=>9, 'Oct'=>10, 'Nov'=>11, 'Dec'=>12 }
class OraErr
attr_reader :sqlcode, :begin_time, :sqlerrm
def initialize(sqlcode,begin_time,sqlerrm)
@sqlcode = sqlcode
@begin_time = begin_time
@sqlerrm = sqlerrm
end
end
this_log = nil
last_log = nil
this_time = nil
thisTime = nil
Net::SSH.start('192.168.0.1', 'oracle',
:password=>'oraclepass') do |session|
cmd = 'cat /orasys/admin/sid/bdump/alert_sid.log'
#session.exec(cmd).each()
session.open_channel do |channel|
channel.on_data do |ch, data|
data.each_line do |line|
line.chomp!
if line =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)/ then
begin
thisTime = Time.local(*ParseDate.parsedate(line))
rescue # 忽略無效日期
next
end
#print \
#ParseDate.parsedate(line) ,line,"\n"
elsif line =~ /^ORA-([0-9]+)/
sqlcode = $1
sqlerrm = line
this_log = OraErr.new(sqlcode,thisTime,sqlerrm)
if (last_log!=nil)
# print the last log
print \
last_log.begin_time.strftime(date_mask),delimiter,
last_log.sqlerrm,"\n"
end
last_log = this_log
this_log = nil
end # line
end # data
end # channel
channel.exec cmd
end # session
session.loop
end #NET
分享到:
相关推荐
1234 SolutionRecommendations for protecting against this vulnerability can be found at:My Oracle Support Note 1340831.1 for Oracle Database deployments that use Oracle Real Application Clusters (RAC)....
Oracle Database 21c 是最新的版本; 21.3 - 企业版(也包括标准版 2) 适用于Linux x86-64位系统。oracle-database-ee-21c-1.0-1.ol8文件分割成 三个 压缩包,必须集齐 三个 文件后才能一起解压一起使用: Oracle ...
Welcome to “Beginning SQL for Oracle Database 18C”! Thanks for picking up this book. It’s safe to say you’re interested in learning about Oracle database, as that’s what this book is about. Why ...
Oracle Database 19c 是最新的长期版本,支持期限最长; 19.3 - 企业版(也包括标准版 2) 适用于Linux x86-64系统。oracle-database-ee-19c文件分割成 三个 压缩包,必须集齐 三个 文件后才能一起解压一起使用: ...
查看oracle数据库alert日志文件位置
Expert Oracle Database 11g Administration Expert Oracle Database 11g Administration
Oracle Database 21c 是最新的版本; 21.3 - 企业版(也包括标准版 2) 适用于Linux x86-64位系统。oracle-database-ee-21c-1.0-1.ol8文件分割成 三个 压缩包,必须集齐 三个 文件后才能一起解压一起使用: Oracle ...
ORACLE ALERT日志备份shell.自动获取alert日志路径。实现按月分类 加上crontab,可以实现每天备份
Oracle Database 10g for Windows安装
Master Oracle Database 12c Release 2 Real Application Clusters with this comprehensive, fully updated guide Now you can maintain a dynamic enterprise computing infrastructure with expert instruction ...
Practical Oracle Database Appliance Description: Practical Oracle Database Appliance is a hands-on book taking you through the components and implementation of the Oracle Database Appliance. Learn ...
第1章 Oracle Database 10g体系结构 第2章 安装Oracle Database 10g和创建数据库 第3章 升级到Oracle Database 10g 第4章 规划Oracle应用程序——方法、风险和标准 第Ⅱ部分 SQL和SQL*Plus 第5章 SQL中的基本语法 第...
Beginning Oracle Database 12c Administration, 2nd Edition
Oracle Database 19c 是最新的长期版本,支持期限最长; 19.3 - 企业版(也包括标准版 2) 适用于WINDOWS X64位系统。 WINDOWS.X64_193000_db_home文件分割成 三个 压缩包,必须集齐 三个 文件后才能一起解压一起...
Oracle Database 21c 是最新的版本; 21.3 - 企业版(也包括标准版 2) 适用于Linux x86-64位系统。oracle-database-ee-21c-1.0-1.ol8文件分割成 三个 压缩包,必须集齐 三个 文件后才能一起解压一起使用: Oracle ...
Oracle Database 12C 多租户,Amazon 5星,好书。 Master the Powerful Multitenant Features of Oracle Database 12c Govern a scalable, extensible, and highly available enterprise database environment ...
applications based on the Oracle database. The book is basically a reflection of what I do every day and of the issues I see people encountering each and every day. I covered what I felt was most ...
Oracle Database 11gR2性能调整与优化 Oracle Database 12cR2性能调整与优化(前78页,第一章内容完整)
《Expert Oracle Database Architecture Oracle Database Programming 9i, 10g, and 11g Techniques and Solutions, Second Edition》的源代码,跟着书做实验用。