| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::MonM::Report; |
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
15
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
App::MonM::Report - The MonM report manager |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 1.00 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use App::MonM::Report; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $report = App::MonM::Report->new( |
|
21
|
|
|
|
|
|
|
name => "my report", |
|
22
|
|
|
|
|
|
|
configfile => $ctk->configfile |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$report->title("My title"); |
|
26
|
|
|
|
|
|
|
$report->abstract("My lead"); |
|
27
|
|
|
|
|
|
|
$report->common( |
|
28
|
|
|
|
|
|
|
["Field 1", "Foo"], |
|
29
|
|
|
|
|
|
|
["Field 2", "Bar"], |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
$report->summary("All right!"); |
|
32
|
|
|
|
|
|
|
$report->errors("My error #1", "My error #2"); |
|
33
|
|
|
|
|
|
|
$report->footer($ctk->tms()); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
print $report->as_string; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This is an extension for working with the monm reports |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 new |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $report = App::MonM::Report->new( |
|
44
|
|
|
|
|
|
|
name => "my report", |
|
45
|
|
|
|
|
|
|
configfile => $ctk->configfile |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Create new report |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 abstract |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$report->abstract("Paragraph 1", "Paragraph 2"); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Sets the abstract part of report |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 as_string |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
print $report->as_string; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns report as string |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 clean |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$report->clean; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Cleans the report |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 common |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$report->common( |
|
71
|
|
|
|
|
|
|
["Field 1", "Foo"], |
|
72
|
|
|
|
|
|
|
["Field 2", "Bar"], |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Sets the common part of report |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 errors |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$report->errors("My error #1", "My error #2"); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Sets the errors part of report |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 footer |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$report->footer(); |
|
86
|
|
|
|
|
|
|
$report->footer($ctk->tms()); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Sets the footer of report |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 report_build |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Internal method for building report |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 summary |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$report->summary("Hi!", "All right!"); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Sets the summary part of report |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 title |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$report->title("My title"); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Sets the title of report |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 HISTORY |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See C file |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 TO DO |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
See C file |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 LICENSE |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
|
125
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
See C file and L |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
1
|
|
|
1
|
|
31
|
use vars qw/$VERSION/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
57
|
|
|
132
|
|
|
|
|
|
|
$VERSION = '1.00'; |
|
133
|
|
|
|
|
|
|
|
|
134
|
1
|
|
|
1
|
|
5
|
use App::MonM::Const qw/HOSTNAME PROJECTNAME DATETIME_FORMAT/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
49
|
|
|
135
|
1
|
|
|
1
|
|
5
|
use CTK::ConfGenUtil qw/is_array array/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
136
|
1
|
|
|
1
|
|
11
|
use CTK::Util qw/dtf tz_diff/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
814
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub new { |
|
139
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
140
|
0
|
|
|
|
|
|
my %args = @_; |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
0
|
|
|
|
my ($caller_pkg) = caller || __PACKAGE__; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
my $self = bless { |
|
145
|
|
|
|
|
|
|
report => [], # Report array |
|
146
|
|
|
|
|
|
|
title => [], |
|
147
|
|
|
|
|
|
|
abstract=> [], |
|
148
|
|
|
|
|
|
|
common => [], |
|
149
|
|
|
|
|
|
|
summary => [], |
|
150
|
|
|
|
|
|
|
errors => [], |
|
151
|
|
|
|
|
|
|
footer => [], |
|
152
|
|
|
|
|
|
|
sign => sprintf("%s/%s", $caller_pkg, $caller_pkg->VERSION), |
|
153
|
|
|
|
|
|
|
name => $args{name} || "virtual", |
|
154
|
0
|
|
0
|
|
|
|
configfile => $args{configfile} || "", |
|
|
|
|
0
|
|
|
|
|
|
155
|
|
|
|
|
|
|
}, $class; |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
return $self; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
sub clean { |
|
160
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
161
|
0
|
|
|
|
|
|
for (qw/report title abstract common summary errors footer/) { |
|
162
|
0
|
|
|
|
|
|
$self->{$_} = [] |
|
163
|
|
|
|
|
|
|
} |
|
164
|
0
|
|
|
|
|
|
return $self; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
sub report_build { |
|
167
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
168
|
0
|
|
|
|
|
|
my @report = (); |
|
169
|
0
|
|
|
|
|
|
push @report, @{(array($self->{title}))}; |
|
|
0
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
push @report, @{(array($self->{abstract}))}; |
|
|
0
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
push @report, @{(array($self->{common}))}; |
|
|
0
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
push @report, @{(array($self->{summary}))}; |
|
|
0
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
push @report, @{(array($self->{errors}))}; |
|
|
0
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
push @report, @{(array($self->{footer}))}; |
|
|
0
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$self->{report} = [@report]; |
|
176
|
0
|
|
|
|
|
|
return $self; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
sub as_string { |
|
179
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
180
|
0
|
|
|
|
|
|
$self->report_build; |
|
181
|
0
|
|
0
|
|
|
|
my $report = $self->{report} || []; |
|
182
|
0
|
0
|
|
|
|
|
return '' unless is_array($report); |
|
183
|
0
|
|
|
|
|
|
return join "\n", @$report; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub title { # title [, name] |
|
187
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
188
|
0
|
|
0
|
|
|
|
my $title = shift || "report"; |
|
189
|
0
|
|
|
|
|
|
my $name = shift; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
$self->{title} = [( |
|
192
|
|
|
|
|
|
|
sprintf("Dear %s user,", PROJECTNAME), "", |
|
193
|
|
|
|
|
|
|
sprintf("This is a automatic-generated %s for %s\non %s, created by %s", |
|
194
|
0
|
|
0
|
|
|
|
$title, $name // $self->{name}, HOSTNAME, $self->{sign}), "", |
|
195
|
|
|
|
|
|
|
)]; |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
return $self; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
sub abstract { # foo, bar, ... |
|
200
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
201
|
0
|
|
|
|
|
|
my @rep = @_; |
|
202
|
0
|
|
|
|
|
|
$self->{abstract} = [(@rep, "")]; |
|
203
|
0
|
|
|
|
|
|
return $self; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
sub common { # [foo, bar], [baz, quux] |
|
206
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
207
|
0
|
|
|
|
|
|
my @hdr = @_; |
|
208
|
0
|
|
|
|
|
|
my @rep = ( |
|
209
|
|
|
|
|
|
|
"-"x32, |
|
210
|
|
|
|
|
|
|
"COMMON INFORMATION", |
|
211
|
|
|
|
|
|
|
"-"x32,"", |
|
212
|
|
|
|
|
|
|
); |
|
213
|
0
|
|
|
|
|
|
my $maxlen = 0; |
|
214
|
0
|
|
|
|
|
|
foreach my $r (@hdr) { |
|
215
|
0
|
0
|
|
|
|
|
$maxlen = length($r->[0]) if $maxlen < length($r->[0]) |
|
216
|
|
|
|
|
|
|
} |
|
217
|
0
|
|
|
|
|
|
foreach my $r (@hdr) { |
|
218
|
0
|
|
|
|
|
|
push @rep, sprintf("%s %s: %s", $r->[0], " "x($maxlen-length($r->[0])), $r->[1]); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
0
|
|
|
|
|
|
$self->{common} = [(@rep, "")]; |
|
221
|
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
return $self; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
sub summary { # string1, string2, ... |
|
225
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
226
|
0
|
|
|
|
|
|
my @summary = @_; |
|
227
|
0
|
0
|
|
|
|
|
unless (scalar(@summary)) { |
|
228
|
0
|
|
|
|
|
|
$self->{summary} = []; |
|
229
|
0
|
|
|
|
|
|
return $self; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
0
|
|
|
|
|
|
my @rep = ( |
|
232
|
|
|
|
|
|
|
"-"x32, |
|
233
|
|
|
|
|
|
|
"SUMMARY", |
|
234
|
|
|
|
|
|
|
"-"x32,"", |
|
235
|
|
|
|
|
|
|
); |
|
236
|
0
|
|
|
|
|
|
push @rep, @summary; |
|
237
|
0
|
|
|
|
|
|
$self->{summary} = [(@rep, "")]; |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return $self; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
sub errors { # error1, error2 |
|
242
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
243
|
0
|
|
|
|
|
|
my @errs = @_; |
|
244
|
0
|
|
|
|
|
|
my @rep = ( |
|
245
|
|
|
|
|
|
|
"-"x32, |
|
246
|
|
|
|
|
|
|
"LIST OF OCCURRED ERRORS", |
|
247
|
|
|
|
|
|
|
"-"x32,"", |
|
248
|
|
|
|
|
|
|
); |
|
249
|
0
|
0
|
|
|
|
|
if (@errs) { |
|
250
|
0
|
|
|
|
|
|
push @rep, @errs; |
|
251
|
|
|
|
|
|
|
} else { |
|
252
|
0
|
|
|
|
|
|
push @rep, "No errors found"; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
0
|
|
|
|
|
|
$self->{errors} = [(@rep, "")]; |
|
255
|
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
return $self; |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
sub footer { # tms |
|
259
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
260
|
0
|
|
|
|
|
|
my $tms = shift; |
|
261
|
0
|
|
|
|
|
|
my @rep = ("---"); |
|
262
|
0
|
|
|
|
|
|
push @rep, sprintf("Hostname : %s", HOSTNAME); |
|
263
|
0
|
|
|
|
|
|
push @rep, sprintf("Program : %s (%s, Perl %s)", $0, $^O, $^V); |
|
264
|
0
|
|
|
|
|
|
push @rep, sprintf("Version : %s", $self->{sign}); |
|
265
|
0
|
0
|
|
|
|
|
push @rep, sprintf("Config file : %s", $self->{configfile}) if $self->{configfile}; |
|
266
|
0
|
|
|
|
|
|
push @rep, sprintf("PID : %d", $$); |
|
267
|
0
|
0
|
|
|
|
|
push @rep, sprintf("Work time : %s", $tms) if $tms; |
|
268
|
0
|
|
|
|
|
|
push @rep, sprintf("Generated : %s", dtf(DATETIME_FORMAT . " " . tz_diff())); |
|
269
|
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
|
$self->{footer} = [(@rep)]; |
|
271
|
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
|
return $self; |
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
1; |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
__END__ |