aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-29 19:12:45 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-29 19:12:45 +0300
commit8196b4281500ef4f6e0cba4ff1f20f6d41e92f17 (patch)
treecec8dfeaf2a2cf0ae73816a84f8dba41bd14274b
parent3ababf4edb89be0b164d8e9cb1cad5b009de9778 (diff)
downloadwydawca-8196b4281500ef4f6e0cba4ff1f20f6d41e92f17.tar.gz
wydawca-8196b4281500ef4f6e0cba4ff1f20f6d41e92f17.tar.bz2
Improve statistic reporter scheduling.
Use crontab format specification to define the frequency of statistic report generation. * src/wydawca.h (stat_report_schedule): New variable. Replaces stat_report_interval. * configure.ac: Check for struct tm.tm_gmtoff. * src/config.c: New keyword: stat-report-schedule. * src/micron.c: New file. * src/micron.h: New file. * src/Makefile.am: Add new files. * src/timer.c (wy_thr_stat): Use micron scheduler. * doc/wydawca.texi: Document stat-report-schedule. * NEWS: Document stat-report-schedule.
-rw-r--r--NEWS8
-rw-r--r--configure.ac5
-rw-r--r--doc/wydawca.texi72
-rw-r--r--src/Makefile.am2
-rw-r--r--src/config.c85
-rw-r--r--src/micron.c398
-rw-r--r--src/micron.h40
-rw-r--r--src/timer.c5
-rw-r--r--src/wydawca.h3
9 files changed, 559 insertions, 59 deletions
diff --git a/NEWS b/NEWS
index ebe721e..2778180 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
1Wydawca NEWS -- history of user-visible changes. 2020-04-27 1Wydawca NEWS -- history of user-visible changes. 2020-04-29
2See the end of file for copying conditions. 2See the end of file for copying conditions.
3 3
4Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. 4Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>.
@@ -75,7 +75,11 @@ notification connections. Default is 16.
75This new statement configures the maximum idle timeout of an 75This new statement configures the maximum idle timeout of an
76upload notification connection. Default is 10 seconds. 76upload notification connection. Default is 10 seconds.
77 77
78** stat-report-interval statement 78** stat-report-schedule statement
79
80Schedules generation of statistic reports in daemon mode. The
81argument is a crontab(5) time specification. The default is
82"@hourly".
79 83
80** The "statistics" event. 84** The "statistics" event.
81 85
diff --git a/configure.ac b/configure.ac
index 1aed22a..2cffbed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,11 @@ AC_TYPE_SIZE_T
56AC_HEADER_STDBOOL 56AC_HEADER_STDBOOL
57AC_SYS_LARGEFILE 57AC_SYS_LARGEFILE
58 58
59AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,
60 [#include <sys/types.h>
61#include <time.h>
62])
63
59# Checks for library functions. 64# Checks for library functions.
60AC_FUNC_FORK 65AC_FUNC_FORK
61AC_FUNC_MALLOC 66AC_FUNC_MALLOC
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index 349d9ba..ddfcca9 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -2234,11 +2234,36 @@ EOT;
2234@node statistics 2234@node statistics
2235@section Statistics 2235@section Statistics
2236@cindex statistics 2236@cindex statistics
2237At the end of the run, @command{wydawca} can print a detailed 2237Periodically @command{wydawca} produces statistic dumps. These dumps
2238statistics of its execution on the diagnostic channel @samp{info}. 2238are displayed on the diagnostic channel @samp{info} (and optionally
2239The statistics is printed only if at least one of its items is not zero. 2239mailed to the admimistrator). The frequency with which they are
2240produced is defined by the @code{stat-report-schedule} configuration
2241statement.
2242
2243@deffn {Config} stat-report-schedule time
2244Schedules generation of statistic reports. The @var{time} argument
2245is a time specification in @samp{crontab} format
2246(@pxref{crontab,,,crontab(5),crontab(5) manual page}). By default,
2247reports are generated hourly.
2248
2249To create reports each three hours, set
2250
2251@example
2252stat-report-schedule "0 */3 * * *";
2253@end example
2254
2255To create them at midnight, use
2256
2257@example
2258stat-report-schedule "@@midnight";
2259@end example
2260@end deffn
2261
2262Statistic report is suppressed if there were no uploads since the last
2263report.
2264
2240The following example illustrates what you might get if you configured 2265The following example illustrates what you might get if you configured
2241full statistics output: 2266full statistic reports:
2242 2267
2243@smallexample 2268@smallexample
2244errors: 0 2269errors: 0
@@ -2256,8 +2281,8 @@ symlinks created: 0
2256symlinks removed: 0 2281symlinks removed: 0
2257@end smallexample 2282@end smallexample
2258 2283
2259 Each item in this statistics is configurable, and a 2284 Each item in this report is configurable, and a
2260unique configuration keyword is associated with it. The statistics 2285unique configuration keyword is associated with it. The statistic
2261items and their corresponding keywords are described in the table 2286items and their corresponding keywords are described in the table
2262below: 2287below:
2263 2288
@@ -2322,12 +2347,12 @@ A symlink is created.
2322A symlink is removed. 2347A symlink is removed.
2323@end table 2348@end table
2324 2349
2325There are two ways to enable the statistics logging. The 2350There are two ways to enable statistic reports. The
2326@dfn{built-in} statistics output is enabled using the 2351@dfn{built-in} statistic output is enabled using the
2327@code{statistics} keyword. 2352@code{statistics} keyword.
2328 2353
2329@deffn {Config} statistics list 2354@deffn {Config} statistics list
2330 The amount of information included in the statistics summary is 2355 The amount of information included in statistic report is
2331configured using the @code{statistics} statement. This statement takes 2356configured using the @code{statistics} statement. This statement takes
2332a list of arguments, each one being one of the keywords, described 2357a list of arguments, each one being one of the keywords, described
2333above. For example, the following statement causes only the 2358above. For example, the following statement causes only the
@@ -2354,10 +2379,10 @@ statistics none;
2354@end smallexample 2379@end smallexample
2355 2380
2356@kwindex all@r{, statistics} 2381@kwindex all@r{, statistics}
2357 Another special keyword is @samp{all}. It enables full statistics 2382 Another special keyword is @samp{all}. It enables full statistic
2358output. This keyword may also be followed by any number of statistics 2383report. This keyword may also be followed by any number of statistic
2359keywords, which are in this case @emph{excluded} from the 2384item names, which are in this case @emph{excluded} from the
2360summary. For example, to output all statistics, except errors and 2385summary. For example, to output all statistic data, except errors and
2361warnings one would set: 2386warnings one would set:
2362 2387
2363@smallexample 2388@smallexample
@@ -2547,7 +2572,7 @@ detailed description.
2547@item statistics 2572@item statistics
2548 This event produces statistics about the recent jobs performed 2573 This event produces statistics about the recent jobs performed
2549by @command{wydawca}. In daemon mode, it is scheduled periodically 2574by @command{wydawca}. In daemon mode, it is scheduled periodically
2550as controlled by @code{stat-report-interval} statement. In cron mode 2575as controlled by the @code{stat-report-schedule} statement. In cron mode
2551it is emitted when all spools have been processed. 2576it is emitted when all spools have been processed.
2552 2577
2553For compatibility with @command{wydawca} versions prior to 3.1.95, the 2578For compatibility with @command{wydawca} versions prior to 3.1.95, the
@@ -2603,7 +2628,7 @@ constructed from the name of the user @command{wydawca} runs as
2603runs at. 2628runs at.
2604 2629
2605@deffn {mod_mailutils} admin-address email 2630@deffn {mod_mailutils} admin-address email
2606Sets the admin email address or addresses. The statistics 2631Sets the admin email address or addresses. The statistic
2607notifications and any notifications configured to be sent to admins 2632notifications and any notifications configured to be sent to admins
2608will be forwarded to this address. The @var{email} argument is either 2633will be forwarded to this address. The @var{email} argument is either
2609a @acronym{RFC} 822 email address, or a list of such addresses. For 2634a @acronym{RFC} 822 email address, or a list of such addresses. For
@@ -2821,8 +2846,8 @@ where @var{name} is the message name as used in @code{define-message}.
2821@end deffn 2846@end deffn
2822 2847
2823@deffn {mail-statistics} statistics item-list 2848@deffn {mail-statistics} statistics item-list
2824The argument is a list of statistics keywords as described in 2849The argument is a list of statistic item names as described in
2825@ref{statistics}. A report will be sent only if statistics 2850@ref{statistics}. A report will be sent only if statistic
2826counters for at least one of the requested categories are not 2851counters for at least one of the requested categories are not
2827zero. For example, the following statement requires sending 2852zero. For example, the following statement requires sending
2828notifications only if there occurred any errors or access violation 2853notifications only if there occurred any errors or access violation
@@ -2843,9 +2868,9 @@ The statistics message is sent to addresses configured by
2843@code{admin-address} statement (@pxref{mod_mailutils, admin-address}). 2868@code{admin-address} statement (@pxref{mod_mailutils, admin-address}).
2844 2869
2845@cindex variables in admin notifications 2870@cindex variables in admin notifications
2846The variables available for use in statistics reports are: 2871The variables available for use in statistic reports are:
2847 2872
2848@anchor{statistics variables} 2873@anchor{statistic variables}
2849@multitable @columnfractions 0.30 0.70 2874@multitable @columnfractions 0.30 0.70
2850@headitem Variable @tab Replaced with 2875@headitem Variable @tab Replaced with
2851@kwindex date 2876@kwindex date
@@ -3277,7 +3302,7 @@ This statement is ignored if the @code{message} statement is present.
3277 3302
3278@deffn {mod_logstat config} message text 3303@deffn {mod_logstat config} message text
3279Specifies the message to be logged. The @var{text} argument can 3304Specifies the message to be logged. The @var{text} argument can
3280contain references to statistics variables (@pxref{statistics 3305contain references to statistic variables (@pxref{statistic
3281variables}). 3306variables}).
3282@end deffn 3307@end deffn
3283 3308
@@ -3462,7 +3487,12 @@ umask @var{mask:@i{octal}};
3462# @xref{archivation, archive-signatures}. 3487# @xref{archivation, archive-signatures}.
3463archive-signatures @var{arg:@i{boolean}}; 3488archive-signatures @var{arg:@i{boolean}};
3464 3489
3465# @r{Print these stats at the end of each run.} 3490# @r{Schedule generation of statistic reports.}
3491# @xref{statistics}.
3492stat-report-schedule @var{time:@i{crontab-time}};
3493
3494# @r{Generate statistic reports if one or more of these items
3495# changed.}
3466# @xref{statistics}. 3496# @xref{statistics}.
3467statistics @var{items:@i{string}}; 3497statistics @var{items:@i{string}};
3468 3498
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b70f5e..15238d4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,6 +44,8 @@ wydawca_SOURCES=\
44 null.c\ 44 null.c\
45 timer.c\ 45 timer.c\
46 thread_name.c\ 46 thread_name.c\