line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PBS::Logs::Event; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
PBS::Logs::Event - parses the PBS event log files |
6
|
|
|
|
|
|
|
and inherits from PBS::Logs. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
See the sections below: |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use PBS::Logs::Event; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
The only non-inheritable function is the class level debug() |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
PBS::Logs::Event::debug() |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
You must use |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
PBS::Logs::debug() |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
to read or set global debugging. |
23
|
|
|
|
|
|
|
However, the instance version works just fine: |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$pl->debug() |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Other than that |
28
|
|
|
|
|
|
|
PBS::Logs::Event inherits all the methods that are available from |
29
|
|
|
|
|
|
|
PBS::Logs, plus adds the methods listed below. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 EXPORT |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
None by default. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SEE ALSO |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item PBS::Logs |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item PBS::Logs::Acct |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item The PBS Pro 5.4 Administrator Guide |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Dr R K Owen, Erkowen@nersc.govE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright (C) 2005 The Regents of the University of California |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This library is free software; you can redistribute it |
58
|
|
|
|
|
|
|
and/or modify it under the terms of the GNU Lesser General |
59
|
|
|
|
|
|
|
Public License as published by the Free Software Foundation; |
60
|
|
|
|
|
|
|
either version 2.1 of the License, or (at your option) any |
61
|
|
|
|
|
|
|
later version. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful, |
64
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty |
65
|
|
|
|
|
|
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
66
|
|
|
|
|
|
|
the GNU Lesser General Public License for more details, |
67
|
|
|
|
|
|
|
which can be found at: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
http://www.gnu.org/copyleft/lesser.html |
70
|
|
|
|
|
|
|
or http://www.opensource.org/licenses/lgpl-license.php |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
11
|
|
|
11
|
|
264473
|
use 5.006; |
|
11
|
|
|
|
|
44
|
|
|
11
|
|
|
|
|
553
|
|
75
|
11
|
|
|
11
|
|
63
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
376
|
|
76
|
11
|
|
|
11
|
|
58
|
use warnings; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
296
|
|
77
|
11
|
|
|
11
|
|
50
|
use Carp; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
1075
|
|
78
|
11
|
|
|
11
|
|
5967
|
use PBS::Logs; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
4049
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
our @ISA = qw(PBS::Logs); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
our $VERSION = $PBS::Logs::VERSION; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Preloaded methods go here. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 new |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Create a PBS::Logs::Event object. |
89
|
|
|
|
|
|
|
It takes only one argument which is either a filename, array reference, |
90
|
|
|
|
|
|
|
or a FILE glob reference. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
See PBS::Logs::new for examples and specifics. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
our %num2keys = ( |
97
|
|
|
|
|
|
|
0 => 'datetime', |
98
|
|
|
|
|
|
|
1 => 'event_code', |
99
|
|
|
|
|
|
|
2 => 'server_name', |
100
|
|
|
|
|
|
|
3 => 'object_type', |
101
|
|
|
|
|
|
|
4 => 'object_name', |
102
|
|
|
|
|
|
|
5 => 'message' |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
our %keys; |
106
|
|
|
|
|
|
|
$keys{$num2keys{$_}}=$_ for (keys %num2keys); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub new { |
109
|
13
|
|
|
13
|
0
|
6464
|
my $proto = shift; |
110
|
13
|
|
33
|
|
|
109
|
my $class = ref($proto) || $proto; |
111
|
13
|
|
|
|
|
136
|
my $self = $class->SUPER::new(@_); |
112
|
10
|
50
|
33
|
|
|
260
|
carp __PACKAGE__.": creating $self\n" |
113
|
|
|
|
|
|
|
if ($SUPER::debug || $self->{'-debug'}); |
114
|
10
|
|
|
|
|
31
|
bless ($self, $class); |
115
|
10
|
|
|
|
|
31
|
return $self; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 get_hash() |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Like the PBS::Logs::Event::get() method; however, instead of returning an |
121
|
|
|
|
|
|
|
array reference, it (obviously) returns a hash |
122
|
|
|
|
|
|
|
where the keys are the same keys as given by %PBS::Logs::Event::keys . |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The event log entry looks like this with respect to the keys: |
125
|
|
|
|
|
|
|
datetime;event_code;server_name;object_type;object_name;message |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
If in a scalar mode it will return a hash reference else it |
128
|
|
|
|
|
|
|
returns a hash. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 Special Arrays |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The following special associative arrays (hashes) |
133
|
|
|
|
|
|
|
are provided by this package, which may be useful for |
134
|
|
|
|
|
|
|
translating between arrays returned by the get() method |
135
|
|
|
|
|
|
|
to/from hashes returned by the get_hash() method, or for |
136
|
|
|
|
|
|
|
selecting a subset of the log entry. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 %PBS::Logs::Event::num2keys |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Relates array position (number) to the keys (or field |
141
|
|
|
|
|
|
|
descriptions) of a get_hash() generated hash. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
%num2keys = ( |
144
|
|
|
|
|
|
|
0 => 'datetime', |
145
|
|
|
|
|
|
|
1 => 'event_code', |
146
|
|
|
|
|
|
|
2 => 'server_name', |
147
|
|
|
|
|
|
|
3 => 'object_type', |
148
|
|
|
|
|
|
|
4 => 'object_name', |
149
|
|
|
|
|
|
|
5 => 'message' |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 %PBS::Logs::Event::keys |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Relates keys (field descriptions) as used by the get_hash() method |
155
|
|
|
|
|
|
|
to array positions (number) as returned from the get() method. |
156
|
|
|
|
|
|
|
Essentially, just the inverse of %PBS::Logs::Event::num2keys above. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub get_hash { |
161
|
50
|
|
|
50
|
0
|
67
|
my $self = shift; |
162
|
50
|
50
|
33
|
|
|
247
|
carp __PACKAGE__.": get_hashref $self(".join(',',@_).")\n" |
163
|
|
|
|
|
|
|
if ($SUPER::debug || $self->{'-debug'}); |
164
|
|
|
|
|
|
|
|
165
|
50
|
|
|
|
|
151
|
my $a = $self->get(); |
166
|
|
|
|
|
|
|
|
167
|
50
|
100
|
|
|
|
93
|
if (! defined $a) { |
168
|
5
|
50
|
|
|
|
12
|
return () if (wantarray); |
169
|
5
|
|
|
|
|
10
|
return undef; |
170
|
|
|
|
|
|
|
} |
171
|
45
|
|
|
|
|
89
|
my $h = {}; |
172
|
|
|
|
|
|
|
|
173
|
45
|
|
|
|
|
424
|
$h->{$_} = $a->[$keys{$_}] for (keys %keys); |
174
|
|
|
|
|
|
|
|
175
|
45
|
50
|
|
|
|
114
|
return if ! defined wantarray; # just read log line |
176
|
45
|
0
|
|
|
|
74
|
return (defined $h ? %$h : ()) if (wantarray); # return hash |
|
|
50
|
|
|
|
|
|
177
|
45
|
|
|
|
|
125
|
$h; # return hash ref |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
__END__ |