1 |
slords |
1.1 |
diff -Nur -x '*.orig' -x '*.rej' smeserver-qpsmtpd-1.2.1/local/bin/qplogsumm.pl mezzanine_patched_smeserver-qpsmtpd-1.2.1/local/bin/qplogsumm.pl |
2 |
|
|
--- smeserver-qpsmtpd-1.2.1/local/bin/qplogsumm.pl 2007-06-08 07:51:51.000000000 -0600 |
3 |
|
|
+++ mezzanine_patched_smeserver-qpsmtpd-1.2.1/local/bin/qplogsumm.pl 1969-12-31 17:00:00.000000000 -0700 |
4 |
|
|
@@ -1,272 +0,0 @@ |
5 |
|
|
-#!/usr/bin/perl |
6 |
|
|
-# |
7 |
|
|
- |
8 |
|
|
-=pod |
9 |
|
|
- |
10 |
|
|
-=head1 SUMMARY |
11 |
|
|
- |
12 |
|
|
-Works with multilog to analyse and summarise log entries generated by the logterse plugin. It is designed |
13 |
|
|
-to be invoked by multilog at log-rotation time. This is specified by an argument to multilog similar to: |
14 |
|
|
- |
15 |
|
|
-=over 4 |
16 |
|
|
- |
17 |
|
|
-multilog t !/path/to/qplogsumm ./main |
18 |
|
|
- |
19 |
|
|
-=back |
20 |
|
|
- |
21 |
|
|
-When qplogsumm is invoked, each line will be echoed, meaning the stored log is unchanged, but summary |
22 |
|
|
-information will be written to fd 5 and so stored in the 'state' file by multilog. |
23 |
|
|
- |
24 |
|
|
-This file is fed in on fd 4 at the beginning of the next log rotation, so running totals, etc can be maintained. |
25 |
|
|
- |
26 |
|
|
-=head1 State file format: |
27 |
|
|
- |
28 |
|
|
-One entry per line containing three fields separated by whitespace: |
29 |
|
|
- |
30 |
|
|
-=over 4 |
31 |
|
|
- |
32 |
|
|
-=item 1. Disposition (plugin) name. |
33 |
|
|
- |
34 |
|
|
-=item 2. tai64n timestamp recording the first time it was seen in a log. |
35 |
|
|
- |
36 |
|
|
-=item 3. long-term running total. |
37 |
|
|
- |
38 |
|
|
-=back |
39 |
|
|
- |
40 |
|
|
-A disposition is effectively the plugin name that called DENY or the string 'queued' for |
41 |
|
|
-messages that made it through. |
42 |
|
|
- |
43 |
|
|
-A line containing a disposition name of LOGFILE_EPOCH and a timestamp for the earliest known log entry. |
44 |
|
|
- |
45 |
|
|
-Other derived data, such as percentages etc. can also appear in the file, commented |
46 |
|
|
-by a # character. This will be ignored on the next intake. |
47 |
|
|
- |
48 |
|
|
-=head1 AUTHOR |
49 |
|
|
- |
50 |
|
|
-Charles Butcher |
51 |
|
|
- |
52 |
|
|
-=head1 VERSION |
53 |
|
|
- |
54 |
|
|
-This is release 1.0 |
55 |
|
|
- |
56 |
|
|
-=cut |
57 |
|
|
- |
58 |
|
|
-use strict; |
59 |
|
|
-use POSIX qw(strftime); |
60 |
|
|
- |
61 |
|
|
- |
62 |
|
|
-my $FS = "\t"; # field separator used by logterse plugin |
63 |
|
|
-my %disp; # hash of dispositions |
64 |
|
|
- |
65 |
|
|
-if (open PREVIOUS, "<&4") |
66 |
|
|
-{ |
67 |
|
|
- while (<PREVIOUS>) |
68 |
|
|
- { |
69 |
|
|
- chomp(); |
70 |
|
|
- next if m/^#/; |
71 |
|
|
- next if m/^\s*$/; |
72 |
|
|
- my ($plug_name, $plug_epoch, $plug_cumulative) = split /\s/; |
73 |
|
|
- my $c = { epoch => $plug_epoch, cum => $plug_cumulative, curr => 0 }; |
74 |
|
|
- $disp{$plug_name} = $c; |
75 |
|
|
- } |
76 |
|
|
- |
77 |
|
|
- close PREVIOUS; |
78 |
|
|
-} |
79 |
|
|
- |
80 |
|
|
-my $first_timestamp = 0; |
81 |
|
|
-my $last_timestamp = 0; |
82 |
|
|
- |
83 |
|
|
- |
84 |
|
|
-while (<>) |
85 |
|
|
-{ |
86 |
|
|
- print; |
87 |
|
|
- chomp; |
88 |
|
|
- next unless m/terse plugin/; |
89 |
|
|
- |
90 |
|
|
- my ($timestamp_part, $log_part) = split '`'; |
91 |
|
|
- my ($current_timestamp) = split /\s/, $timestamp_part; |
92 |
|
|
- $first_timestamp = $current_timestamp unless $first_timestamp; |
93 |
|
|
- $last_timestamp = $current_timestamp; |
94 |
|
|
- |
95 |
|
|
- my (@log_items) = split $FS, $log_part; |
96 |
|
|
- my $disposition = $log_items[5]; |
97 |
|
|
- next unless defined $disposition; |
98 |
|
|
- |
99 |
|
|
- if ($disp{$disposition}) |
100 |
|
|
- { |
101 |
|
|
- $disp{$disposition}->{curr} = 1; |
102 |
|
|
- } |
103 |
|
|
- else # a new plugin -- make a note of when it first appeared |
104 |
|
|
- { |
105 |
|
|
- my $c = { epoch => $current_timestamp, cum => 0, curr => 1 }; |
106 |
|
|
- $disp{$disposition} = $c; |
107 |
|
|
- } |
108 |
|
|
-} |
109 |
|
|
- |
110 |
|
|
- |
111 |
|
|
-# |
112 |
|
|
-# Set overall epoch |
113 |
|
|
-# |
114 |
|
|
-if (!exists $disp{'LOGFILE_EPOCH'}) |
115 |
|
|
-{ |
116 |
|
|
- my $c = { epoch => $first_timestamp, cum => 0, curr => 0}; |
117 |
|
|
- $disp{'LOGFILE_EPOCH'} = $c; |
118 |
|
|
-} |
119 |
|
|
- |
120 |
|
|
-my $current_total = 0; |
121 |
|
|
-my $cumulative_total = 0; |
122 |
|
|
- |
123 |
|
|
-open HOLDOVER, ">&5" and select HOLDOVER; |
124 |
|
|
- |
125 |
|
|
-# |
126 |
|
|
-# Output cumulative values for intake the next time a log is processed |
127 |
|
|
-# |
128 |
|
|
-for my $c (keys %disp) |
129 |
|
|
-{ |
130 |
|
|
- $disp{$c}->{cum} = $disp{$c}->{curr}; |
131 |
|
|
- $current_total = $disp{$c}->{curr}; |
132 |
|
|
- $cumulative_total = $disp{$c}->{cum}; |
133 |
|
|
- |
134 |
|
|
- printf "%-30.30s %s %12d\n", $c, $disp{$c}->{epoch}, $disp{$c}->{cum}; |
135 |
|
|
-} |
136 |
|
|
- |
137 |
|
|
-# |
138 |
|
|
-# Output current logfile stats |
139 |
|
|
-# |
140 |
|
|
- |
141 |
|
|
-my $current_elapsed = tai64diff($last_timestamp, $first_timestamp); |
142 |
|
|
- |
143 |
|
|
-printf "# |
144 |
|
|
-# Most recent logfile |
145 |
|
|
-# ------------------- |
146 |
|
|
-# |
147 |
|
|
-# Start : %s |
148 |
|
|
-# Finish : %s |
149 |
|
|
-# Elapsed: %s |
150 |
|
|
-# |
151 |
|
|
-# Total transactions : %9d |
152 |
|
|
-# Average tx per hour: %9d |
153 |
|
|
-", |
154 |
|
|
- tai64utc($first_timestamp), |
155 |
|
|
- tai64utc($last_timestamp), |
156 |
|
|
- seconds_to_days($current_elapsed), |
157 |
|
|
- $current_total, |
158 |
|
|
- $current_total / ($current_elapsed / 3600), |
159 |
|
|
- ; |
160 |
|
|
- |
161 |
|
|
-# |
162 |
|
|
-# Output cumulative log stats |
163 |
|
|
-# |
164 |
|
|
-my $cumulative_elapsed = tai64diff($last_timestamp, $disp{'LOGFILE_EPOCH'}->{epoch}); |
165 |
|
|
- |
166 |
|
|
-printf "# |
167 |
|
|
-# Cumulative Totals |
168 |
|
|
-# ----------------- |
169 |
|
|
-# |
170 |
|
|
-# Start : %s |
171 |
|
|
-# Finish : %s |
172 |
|
|
-# Elapsed: %s |
173 |
|
|
-# |
174 |
|
|
-# Total transactions : %12d |
175 |
|
|
-# Average tx per hour: %12d |
176 |
|
|
-", |
177 |
|
|
- tai64utc($disp{'LOGFILE_EPOCH'}->{epoch}), |
178 |
|
|
- tai64utc($last_timestamp), |
179 |
|
|
- seconds_to_days($cumulative_elapsed), |
180 |
|
|
- $cumulative_total, |
181 |
|
|
- $cumulative_total / ($cumulative_elapsed / 3600), |
182 |
|
|
- ; |
183 |
|
|
- |
184 |
|
|
- |
185 |
|
|
-# |
186 |
|
|
-# Output per-plugin stats |
187 |
|
|
-# |
188 |
|
|
- |
189 |
|
|
-print "# |
190 |
|
|
-# Most Recent Logfile Cumulative Totals |
191 |
|
|
-# Disposition (plugin) Total Avg/Day Total Avg/Day |
192 |
|
|
-# ----------------------------------------------------------------------------\n"; |
193 |
|
|
- |
194 |
|
|
-my $printf_format = "# %-30.30s %6d %3d%% %8d %10d %3d%% %8d\n"; |
195 |
|
|
- |
196 |
|
|
-foreach my $c (sort { $disp{$b}->{curr} <=> $disp{$a}->{curr} } keys %disp) |
197 |
|
|
-{ |
198 |
|
|
- next if ($c eq 'LOGFILE_EPOCH'); |
199 |
|
|
- |
200 |
|
|
- printf $printf_format, |
201 |
|
|
- $c, |
202 |
|
|
- $disp{$c}->{curr}, |
203 |
|
|
- $disp{$c}->{curr} / $current_total * 100, |
204 |
|
|
- $disp{$c}->{curr} / ($current_elapsed / 86400), |
205 |
|
|
- $disp{$c}->{cum}, |
206 |
|
|
- $disp{$c}->{cum} / $cumulative_total * 100, |
207 |
|
|
- $disp{$c}->{cum} / (tai64diff($last_timestamp, $disp{$c}->{epoch}) / 86400), |
208 |
|
|
- ; |
209 |
|
|
-} |
210 |
|
|
- |
211 |
|
|
-print "# ----------------------------------------------------------------------------\n"; |
212 |
|
|
-printf $printf_format, |
213 |
|
|
- 'TOTALS', |
214 |
|
|
- $current_total, |
215 |
|
|
- 100, |
216 |
|
|
- $current_total / ($current_elapsed / 86400), |
217 |
|
|
- $cumulative_total, |
218 |
|
|
- 100, |
219 |
|
|
- $cumulative_total / ($cumulative_elapsed / 86400), |
220 |
|
|
- ; |
221 |
|
|
- |
222 |
|
|
-exit 0; |
223 |
|
|
- |
224 |
|
|
- |
225 |
|
|
-sub tai64utc { |
226 |
|
|
- my ($s) = @_; |
227 |
|
|
- |
228 |
|
|
- # @400000003f6c7bc5253bf98c |
229 |
|
|
- # 0123456789012345678901234 |
230 |
|
|
- # 0 1 2 |
231 |
|
|
- # |-------------||------| |
232 |
|
|
- if (substr($s, 0, 2) eq '@4') { |
233 |
|
|
- my $ts = hex(substr($s, 2, 15)); |
234 |
|
|
- $s = strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)); |
235 |
|
|
- } |
236 |
|
|
- return $s; |
237 |
|
|
-} |
238 |
|
|
- |
239 |
|
|
-# |
240 |
|
|
-# Return difference in seconds |
241 |
|
|
-# |
242 |
|
|
-sub tai64diff |
243 |
|
|
-{ |
244 |
|
|
- my ($s1, $s2) = @_; |
245 |
|
|
- |
246 |
|
|
- # @400000003f6c7bc5253bf98c |
247 |
|
|
- # 0123456789012345678901234 |
248 |
|
|
- # 0 1 2 |
249 |
|
|
- # |-------------||------| |
250 |
|
|
- if (substr($s1, 0, 2) eq '@4' and substr($s2, 0, 2) eq '@4') |
251 |
|
|
- { |
252 |
|
|
- my $ts1 = hex(substr($s1, 2, 15)); |
253 |
|
|
- my $ts2 = hex(substr($s2, 2, 15)); |
254 |
|
|
- return $ts1 - $ts2; |
255 |
|
|
- } |
256 |
|
|
- else |
257 |
|
|
- { |
258 |
|
|
- return 0; |
259 |
|
|
- } |
260 |
|
|
-} |
261 |
|
|
- |
262 |
|
|
- |
263 |
|
|
-# |
264 |
|
|
-# Return an english phrase representing a number of seconds |
265 |
|
|
-# |
266 |
|
|
-sub seconds_to_days |
267 |
|
|
-{ |
268 |
|
|
- my ($secs) = @_; |
269 |
|
|
- |
270 |
|
|
- my $phrase = sprintf "%d days, ", ($secs / 86400); |
271 |
|
|
- $secs %= 86400; |
272 |
|
|
- $phrase .= sprintf "%d hours, ", ($secs / 3600); |
273 |
|
|
- $secs %= 3600; |
274 |
|
|
- $phrase .= sprintf "%d mins, %d secs", ($secs / 60), ($secs % 60); |
275 |
|
|
-} |
276 |
|
|
- |
277 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-qpsmtpd-1.2.1/root/usr/local/bin/qplogsumm.pl mezzanine_patched_smeserver-qpsmtpd-1.2.1/root/usr/local/bin/qplogsumm.pl |
278 |
|
|
--- smeserver-qpsmtpd-1.2.1/root/usr/local/bin/qplogsumm.pl 1969-12-31 17:00:00.000000000 -0700 |
279 |
|
|
+++ mezzanine_patched_smeserver-qpsmtpd-1.2.1/root/usr/local/bin/qplogsumm.pl 2007-06-07 09:37:09.000000000 -0600 |
280 |
|
|
@@ -0,0 +1,272 @@ |
281 |
|
|
+#!/usr/bin/perl |
282 |
|
|
+# |
283 |
|
|
+ |
284 |
|
|
+=pod |
285 |
|
|
+ |
286 |
|
|
+=head1 SUMMARY |
287 |
|
|
+ |
288 |
|
|
+Works with multilog to analyse and summarise log entries generated by the logterse plugin. It is designed |
289 |
|
|
+to be invoked by multilog at log-rotation time. This is specified by an argument to multilog similar to: |
290 |
|
|
+ |
291 |
|
|
+=over 4 |
292 |
|
|
+ |
293 |
|
|
+multilog t !/path/to/qplogsumm ./main |
294 |
|
|
+ |
295 |
|
|
+=back |
296 |
|
|
+ |
297 |
|
|
+When qplogsumm is invoked, each line will be echoed, meaning the stored log is unchanged, but summary |
298 |
|
|
+information will be written to fd 5 and so stored in the 'state' file by multilog. |
299 |
|
|
+ |
300 |
|
|
+This file is fed in on fd 4 at the beginning of the next log rotation, so running totals, etc can be maintained. |
301 |
|
|
+ |
302 |
|
|
+=head1 State file format: |
303 |
|
|
+ |
304 |
|
|
+One entry per line containing three fields separated by whitespace: |
305 |
|
|
+ |
306 |
|
|
+=over 4 |
307 |
|
|
+ |
308 |
|
|
+=item 1. Disposition (plugin) name. |
309 |
|
|
+ |
310 |
|
|
+=item 2. tai64n timestamp recording the first time it was seen in a log. |
311 |
|
|
+ |
312 |
|
|
+=item 3. long-term running total. |
313 |
|
|
+ |
314 |
|
|
+=back |
315 |
|
|
+ |
316 |
|
|
+A disposition is effectively the plugin name that called DENY or the string 'queued' for |
317 |
|
|
+messages that made it through. |
318 |
|
|
+ |
319 |
|
|
+A line containing a disposition name of LOGFILE_EPOCH and a timestamp for the earliest known log entry. |
320 |
|
|
+ |
321 |
|
|
+Other derived data, such as percentages etc. can also appear in the file, commented |
322 |
|
|
+by a # character. This will be ignored on the next intake. |
323 |
|
|
+ |
324 |
|
|
+=head1 AUTHOR |
325 |
|
|
+ |
326 |
|
|
+Charles Butcher |
327 |
|
|
+ |
328 |
|
|
+=head1 VERSION |
329 |
|
|
+ |
330 |
|
|
+This is release 1.0 |
331 |
|
|
+ |
332 |
|
|
+=cut |
333 |
|
|
+ |
334 |
|
|
+use strict; |
335 |
|
|
+use POSIX qw(strftime); |
336 |
|
|
+ |
337 |
|
|
+ |
338 |
|
|
+my $FS = "\t"; # field separator used by logterse plugin |
339 |
|
|
+my %disp; # hash of dispositions |
340 |
|
|
+ |
341 |
|
|
+if (open PREVIOUS, "<&4") |
342 |
|
|
+{ |
343 |
|
|
+ while (<PREVIOUS>) |
344 |
|
|
+ { |
345 |
|
|
+ chomp(); |
346 |
|
|
+ next if m/^#/; |
347 |
|
|
+ next if m/^\s*$/; |
348 |
|
|
+ my ($plug_name, $plug_epoch, $plug_cumulative) = split /\s/; |
349 |
|
|
+ my $c = { epoch => $plug_epoch, cum => $plug_cumulative, curr => 0 }; |
350 |
|
|
+ $disp{$plug_name} = $c; |
351 |
|
|
+ } |
352 |
|
|
+ |
353 |
|
|
+ close PREVIOUS; |
354 |
|
|
+} |
355 |
|
|
+ |
356 |
|
|
+my $first_timestamp = 0; |
357 |
|
|
+my $last_timestamp = 0; |
358 |
|
|
+ |
359 |
|
|
+ |
360 |
|
|
+while (<>) |
361 |
|
|
+{ |
362 |
|
|
+ print; |
363 |
|
|
+ chomp; |
364 |
|
|
+ next unless m/terse plugin/; |
365 |
|
|
+ |
366 |
|
|
+ my ($timestamp_part, $log_part) = split '`'; |
367 |
|
|
+ my ($current_timestamp) = split /\s/, $timestamp_part; |
368 |
|
|
+ $first_timestamp = $current_timestamp unless $first_timestamp; |
369 |
|
|
+ $last_timestamp = $current_timestamp; |
370 |
|
|
+ |
371 |
|
|
+ my (@log_items) = split $FS, $log_part; |
372 |
|
|
+ my $disposition = $log_items[5]; |
373 |
|
|
+ next unless defined $disposition; |
374 |
|
|
+ |
375 |
|
|
+ if ($disp{$disposition}) |
376 |
|
|
+ { |
377 |
|
|
+ $disp{$disposition}->{curr} = 1; |
378 |
|
|
+ } |
379 |
|
|
+ else # a new plugin -- make a note of when it first appeared |
380 |
|
|
+ { |
381 |
|
|
+ my $c = { epoch => $current_timestamp, cum => 0, curr => 1 }; |
382 |
|
|
+ $disp{$disposition} = $c; |
383 |
|
|
+ } |
384 |
|
|
+} |
385 |
|
|
+ |
386 |
|
|
+ |
387 |
|
|
+# |
388 |
|
|
+# Set overall epoch |
389 |
|
|
+# |
390 |
|
|
+if (!exists $disp{'LOGFILE_EPOCH'}) |
391 |
|
|
+{ |
392 |
|
|
+ my $c = { epoch => $first_timestamp, cum => 0, curr => 0}; |
393 |
|
|
+ $disp{'LOGFILE_EPOCH'} = $c; |
394 |
|
|
+} |
395 |
|
|
+ |
396 |
|
|
+my $current_total = 0; |
397 |
|
|
+my $cumulative_total = 0; |
398 |
|
|
+ |
399 |
|
|
+open HOLDOVER, ">&5" and select HOLDOVER; |
400 |
|
|
+ |
401 |
|
|
+# |
402 |
|
|
+# Output cumulative values for intake the next time a log is processed |
403 |
|
|
+# |
404 |
|
|
+for my $c (keys %disp) |
405 |
|
|
+{ |
406 |
|
|
+ $disp{$c}->{cum} = $disp{$c}->{curr}; |
407 |
|
|
+ $current_total = $disp{$c}->{curr}; |
408 |
|
|
+ $cumulative_total = $disp{$c}->{cum}; |
409 |
|
|
+ |
410 |
|
|
+ printf "%-30.30s %s %12d\n", $c, $disp{$c}->{epoch}, $disp{$c}->{cum}; |
411 |
|
|
+} |
412 |
|
|
+ |
413 |
|
|
+# |
414 |
|
|
+# Output current logfile stats |
415 |
|
|
+# |
416 |
|
|
+ |
417 |
|
|
+my $current_elapsed = tai64diff($last_timestamp, $first_timestamp); |
418 |
|
|
+ |
419 |
|
|
+printf "# |
420 |
|
|
+# Most recent logfile |
421 |
|
|
+# ------------------- |
422 |
|
|
+# |
423 |
|
|
+# Start : %s |
424 |
|
|
+# Finish : %s |
425 |
|
|
+# Elapsed: %s |
426 |
|
|
+# |
427 |
|
|
+# Total transactions : %9d |
428 |
|
|
+# Average tx per hour: %9d |
429 |
|
|
+", |
430 |
|
|
+ tai64utc($first_timestamp), |
431 |
|
|
+ tai64utc($last_timestamp), |
432 |
|
|
+ seconds_to_days($current_elapsed), |
433 |
|
|
+ $current_total, |
434 |
|
|
+ $current_total / ($current_elapsed / 3600), |
435 |
|
|
+ ; |
436 |
|
|
+ |
437 |
|
|
+# |
438 |
|
|
+# Output cumulative log stats |
439 |
|
|
+# |
440 |
|
|
+my $cumulative_elapsed = tai64diff($last_timestamp, $disp{'LOGFILE_EPOCH'}->{epoch}); |
441 |
|
|
+ |
442 |
|
|
+printf "# |
443 |
|
|
+# Cumulative Totals |
444 |
|
|
+# ----------------- |
445 |
|
|
+# |
446 |
|
|
+# Start : %s |
447 |
|
|
+# Finish : %s |
448 |
|
|
+# Elapsed: %s |
449 |
|
|
+# |
450 |
|
|
+# Total transactions : %12d |
451 |
|
|
+# Average tx per hour: %12d |
452 |
|
|
+", |
453 |
|
|
+ tai64utc($disp{'LOGFILE_EPOCH'}->{epoch}), |
454 |
|
|
+ tai64utc($last_timestamp), |
455 |
|
|
+ seconds_to_days($cumulative_elapsed), |
456 |
|
|
+ $cumulative_total, |
457 |
|
|
+ $cumulative_total / ($cumulative_elapsed / 3600), |
458 |
|
|
+ ; |
459 |
|
|
+ |
460 |
|
|
+ |
461 |
|
|
+# |
462 |
|
|
+# Output per-plugin stats |
463 |
|
|
+# |
464 |
|
|
+ |
465 |
|
|
+print "# |
466 |
|
|
+# Most Recent Logfile Cumulative Totals |
467 |
|
|
+# Disposition (plugin) Total Avg/Day Total Avg/Day |
468 |
|
|
+# ----------------------------------------------------------------------------\n"; |
469 |
|
|
+ |
470 |
|
|
+my $printf_format = "# %-30.30s %6d %3d%% %8d %10d %3d%% %8d\n"; |
471 |
|
|
+ |
472 |
|
|
+foreach my $c (sort { $disp{$b}->{curr} <=> $disp{$a}->{curr} } keys %disp) |
473 |
|
|
+{ |
474 |
|
|
+ next if ($c eq 'LOGFILE_EPOCH'); |
475 |
|
|
+ |
476 |
|
|
+ printf $printf_format, |
477 |
|
|
+ $c, |
478 |
|
|
+ $disp{$c}->{curr}, |
479 |
|
|
+ $disp{$c}->{curr} / $current_total * 100, |
480 |
|
|
+ $disp{$c}->{curr} / ($current_elapsed / 86400), |
481 |
|
|
+ $disp{$c}->{cum}, |
482 |
|
|
+ $disp{$c}->{cum} / $cumulative_total * 100, |
483 |
|
|
+ $disp{$c}->{cum} / (tai64diff($last_timestamp, $disp{$c}->{epoch}) / 86400), |
484 |
|
|
+ ; |
485 |
|
|
+} |
486 |
|
|
+ |
487 |
|
|
+print "# ----------------------------------------------------------------------------\n"; |
488 |
|
|
+printf $printf_format, |
489 |
|
|
+ 'TOTALS', |
490 |
|
|
+ $current_total, |
491 |
|
|
+ 100, |
492 |
|
|
+ $current_total / ($current_elapsed / 86400), |
493 |
|
|
+ $cumulative_total, |
494 |
|
|
+ 100, |
495 |
|
|
+ $cumulative_total / ($cumulative_elapsed / 86400), |
496 |
|
|
+ ; |
497 |
|
|
+ |
498 |
|
|
+exit 0; |
499 |
|
|
+ |
500 |
|
|
+ |
501 |
|
|
+sub tai64utc { |
502 |
|
|
+ my ($s) = @_; |
503 |
|
|
+ |
504 |
|
|
+ # @400000003f6c7bc5253bf98c |
505 |
|
|
+ # 0123456789012345678901234 |
506 |
|
|
+ # 0 1 2 |
507 |
|
|
+ # |-------------||------| |
508 |
|
|
+ if (substr($s, 0, 2) eq '@4') { |
509 |
|
|
+ my $ts = hex(substr($s, 2, 15)); |
510 |
|
|
+ $s = strftime('%Y-%m-%d %H:%M:%S', gmtime($ts)); |
511 |
|
|
+ } |
512 |
|
|
+ return $s; |
513 |
|
|
+} |
514 |
|
|
+ |
515 |
|
|
+# |
516 |
|
|
+# Return difference in seconds |
517 |
|
|
+# |
518 |
|
|
+sub tai64diff |
519 |
|
|
+{ |
520 |
|
|
+ my ($s1, $s2) = @_; |
521 |
|
|
+ |
522 |
|
|
+ # @400000003f6c7bc5253bf98c |
523 |
|
|
+ # 0123456789012345678901234 |
524 |
|
|
+ # 0 1 2 |
525 |
|
|
+ # |-------------||------| |
526 |
|
|
+ if (substr($s1, 0, 2) eq '@4' and substr($s2, 0, 2) eq '@4') |
527 |
|
|
+ { |
528 |
|
|
+ my $ts1 = hex(substr($s1, 2, 15)); |
529 |
|
|
+ my $ts2 = hex(substr($s2, 2, 15)); |
530 |
|
|
+ return $ts1 - $ts2; |
531 |
|
|
+ } |
532 |
|
|
+ else |
533 |
|
|
+ { |
534 |
|
|
+ return 0; |
535 |
|
|
+ } |
536 |
|
|
+} |
537 |
|
|
+ |
538 |
|
|
+ |
539 |
|
|
+# |
540 |
|
|
+# Return an english phrase representing a number of seconds |
541 |
|
|
+# |
542 |
|
|
+sub seconds_to_days |
543 |
|
|
+{ |
544 |
|
|
+ my ($secs) = @_; |
545 |
|
|
+ |
546 |
|
|
+ my $phrase = sprintf "%d days, ", ($secs / 86400); |
547 |
|
|
+ $secs %= 86400; |
548 |
|
|
+ $phrase .= sprintf "%d hours, ", ($secs / 3600); |
549 |
|
|
+ $secs %= 3600; |
550 |
|
|
+ $phrase .= sprintf "%d mins, %d secs", ($secs / 60), ($secs % 60); |
551 |
|
|
+} |
552 |
|
|
+ |