forked from jkstill/vktm-time-drift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvt.pl
executable file
·139 lines (98 loc) · 4.35 KB
/
vt.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Long;
use Pod::Usage;
=head1 SYNOPSIS
Parse the timestamps and time adjustments from the trace file created by Oracle Database process VKTM
https://docs.oracle.com/cd/E18283_01/server.112/e17110/bgprocesses.htm
This script currently considers only highres forward time drifts
See this Oracle Support Note:
Time Drift Detected. Please Check VKTM Trace File for More Details (Doc ID 1347586.1)
Time drifts of 1 sec forward are acceptable.
Time drifts of 5 sec backward are acceptable.
Drifts outside of these parameters should be investigated
See this Oracle Support Note for a patch to reduce VKTM messages in 11.2 ASM alert logs
ASM Instance Is Reporting "Warning: VKTM detected a time drift" (Doc ID 1678120.1)
=cut
=head1 OPTIONS
-h | --help
show options
--man
show all documentation
--csv-output
output CSV format - default is RPT
--forward-drift-threshold
for the standard report, display an arrow next to values exceeding this threshold
default is 1 (second)
=cut
=head1 VKTM Trace file Format
*** 2016-12-17 17:46:58.856
*** SESSION ID:(1.1) 2016-12-17 17:46:58.856
*** CLIENT ID:() 2016-12-17 17:46:58.856
*** SERVICE NAME:() 2016-12-17 17:46:58.856
*** MODULE NAME:() 2016-12-17 17:46:58.856
*** ACTION NAME:() 2016-12-17 17:46:58.856
kstmmainvktm: succeeded in setting elevated priority
highres_enabled
*** 2016-12-17 17:46:58.866
VKTM running at (1)millisec precision with DBRM quantum (100)ms
[Start] HighResTick = 1482014818866063
kstmrmtickcnt = 0 : ksudbrmseccnt[0] = 1482014818
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1542116)usec at (1482017000433105) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1457497)usec at (1482025556154868) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1741601)usec at (1482028279593226) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1465148)usec at (1482030458886280) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1198164)usec at (1482031301932289) whereas (1000000) is allowed
*** 2016-12-17 22:21:42.949
kstmchkdrift (kstmhighrestimecntkeeper:lowres): Time stalled at 1482031302
kstmchkdrift (kstmhighrestimecntkeeper:lowres): Stall, backward drift ended at 1482031303 drift: 1
*** 2016-12-17 22:22:03.505
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (4939246)usec at (1482031323505006) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (2850778)usec at (1482037600018932) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1853895)usec at (1482046620148715) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1183737)usec at (1482048031506463) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (2284330)usec at (1482056954557624) whereas (1000000) is allowed
kstmchkdrift (kstmhighrestimecntkeeper:highres): Time jumped forward by (1800835)usec at (1482058839861395) whereas (1000000) is allowed
=cut
my $outputType = 'RPT';
my $csvOutput=0;
my $forwardDriftThreshold=1;
GetOptions (
"h|help!" => sub { pod2usage( -verbose => 1 ) },
"man!" => sub { pod2usage( -verbose => 2 ) },
"csv-output!" => \$csvOutput,
"forward-drift-threshold=i" => \$forwardDriftThreshold,
);
$outputType = 'CSV' if $csvOutput;
# by date
my %timeDrift=();
my $currDate;
while (<>) {
chomp;
if (/(^\*{3})\s+([0-9-]+)\s+([0-9:.]+)$/) {
$currDate = "$2 $3";
next;
} elsif ( /Time jumped forward by/ ) {
my @a = split(/\s+/);
my $adjTime = $a[6];
$adjTime =~ s/[a-z()]//g;
push @{$timeDrift{$currDate}}, $adjTime;
}
}
#print Dumper(\%timeDrift);
foreach my $date ( sort { $a cmp $b } keys %timeDrift ) {
my @a = @{$timeDrift{$date}};
if ( $outputType eq 'CSV' ) {
foreach my $driftTime ( @a ) {
printf "%s,%2.3f\n", $date,$driftTime / 1e6,
}
} else {
print "== $date\n";
foreach my $driftTime ( @a ) {
my $tooBig = $driftTime > $forwardDriftThreshold * 1e6 ? '<==' : '';
printf " %2.3f %s\n", $driftTime / 1e6, $tooBig ;
}
}
}