- 论坛徽章:
- 0
|
本帖最后由 jjqing 于 2011-04-23 20:22 编辑
各位好!
我想用perl来分析Oracle的日志,大致想法是,先读出日志到一个数组,然后对这个数组做foreach,取出指定时间点以后的所有日志。
这时,取出的日志就是所需要分析的日志。
但是,我在做“取出指定时间点以后的所有日志”这个操作时,却总是只能取到两行数据,实际上应该取到的是15行,不知道是哪里出了错,请各位帮忙看看,谢谢!
附件是我所使用的oracle日志样本以及测试脚本的压缩包:
alert_pl.zip
(1.04 KB, 下载次数: 35)
谢谢各位!
下面是我的测试脚本:
- #!/bin/env perl
- use strict;
- use warnings;
- use diagnostics;
- use Smart::Comments;
- #检查ORACLE告警日志
- my $file = "alert_PROD.log";
- open my $fh, '<', $file or return;
- my @lines = <$fh>;
- foreach (@lines) {
- chomp;
- }
- ### @lines
- my @checkAlert;
- my @errorAlert;
- #从指定的时间点开始检查日志
- #例如,从Fri Apr 22 12:20:52 2011开始检查
- foreach (@lines) {
- if ( /Sun Feb 27 10:33:50/ ... eof ) {
- push @checkAlert , $_;
- }
- }
- #如果检查范围内有ORA-开头的文本,则放到错误日志组里面
- foreach (@checkAlert) {
- if ( /^ORA-/ ) {
- push @errorAlert , $_;
- }
- }
- ### @checkAlert
- ### @errorAlert
复制代码
以下是所分析的oracle日志的样本:
- Fri Aug 28 10:14:50 2009
- Thread 1 advanced to log sequence 147566
- Current log# 3 seq# 147566 mem# 0: /oradata/PROD/redoPROD03.log
- Sun Feb 27 10:32:33 2011
- Thread 1 advanced to log sequence 204661
- Current log# 3 seq# 204662 mem# 0: /oradata/PROD/redoPROD03.log
- Sun Feb 27 10:33:50 2011
- Thread 1 cannot allocate new log, sequence 204663
- Checkpoint not complete
- Current log# 3 seq# 204662 mem# 0: /oradata/PROD/redoPROD03.log
- Thread 1 advanced to log sequence 204663
- Current log# 4 seq# 204663 mem# 0: /oradata/PROD/redoPROD04.log
- Wed Mar 9 03:01:59 2011
- Errors in file /u03/oracle/app/oracle/admin/PROD/bdump/prod_snp0_12949.trc:
- ORA-12012: error on auto execute of job 14874
- ORA-00376: file 11 cannot be read at this time
- ORA-01110: data file 11: '/oradata/PROD/mrpx01.dbf'
- ORA-06512: at "APPS.CUST_CMP_DATA_HQPO", line 133
- ORA-06512: at line 1
- Sat Apr 23 14:08:30 2011
- Completed: alter database open
- Sat Apr 23 14:09:44 2011
- Thread 1 advanced to log sequence 211717
- Current log# 2 seq# 211717 mem# 0: /oradata/PROD/redoPROD02.log
复制代码
以下是运行结果:
### @checkAlert: [
### 'Sun Feb 27 10:33:50 2011',
### 'Thread 1 cannot allocate new log, sequence 204663'
### ]
### @errorAlert: [] |
|