diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-04-29 19:12:45 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-04-29 19:12:45 +0300 |
commit | 8196b4281500ef4f6e0cba4ff1f20f6d41e92f17 (patch) | |
tree | cec8dfeaf2a2cf0ae73816a84f8dba41bd14274b | |
parent | 3ababf4edb89be0b164d8e9cb1cad5b009de9778 (diff) | |
download | wydawca-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-- | NEWS | 8 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | doc/wydawca.texi | 72 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/config.c | 85 | ||||
-rw-r--r-- | src/micron.c | 398 | ||||
-rw-r--r-- | src/micron.h | 40 | ||||
-rw-r--r-- | src/timer.c | 5 | ||||
-rw-r--r-- | src/wydawca.h | 3 |
9 files changed, 559 insertions, 59 deletions
@@ -1,4 +1,4 @@ | |||
1 | Wydawca NEWS -- history of user-visible changes. 2020-04-27 | 1 | Wydawca NEWS -- history of user-visible changes. 2020-04-29 |
2 | See the end of file for copying conditions. | 2 | See the end of file for copying conditions. |
3 | 3 | ||
4 | Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. | 4 | Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. |
@@ -75,7 +75,11 @@ notification connections. Default is 16. | |||
75 | This new statement configures the maximum idle timeout of an | 75 | This new statement configures the maximum idle timeout of an |
76 | upload notification connection. Default is 10 seconds. | 76 | upload notification connection. Default is 10 seconds. |
77 | 77 | ||
78 | ** stat-report-interval statement | 78 | ** stat-report-schedule statement |
79 | |||
80 | Schedules generation of statistic reports in daemon mode. The | ||
81 | argument 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 | |||
56 | AC_HEADER_STDBOOL | 56 | AC_HEADER_STDBOOL |
57 | AC_SYS_LARGEFILE | 57 | AC_SYS_LARGEFILE |
58 | 58 | ||
59 | AC_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. |
60 | AC_FUNC_FORK | 65 | AC_FUNC_FORK |
61 | AC_FUNC_MALLOC | 66 | AC_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 |
2237 | At the end of the run, @command{wydawca} can print a detailed | 2237 | Periodically @command{wydawca} produces statistic dumps. These dumps |
2238 | statistics of its execution on the diagnostic channel @samp{info}. | 2238 | are displayed on the diagnostic channel @samp{info} (and optionally |
2239 | The statistics is printed only if at least one of its items is not zero. | 2239 | mailed to the admimistrator). The frequency with which they are |
2240 | produced is defined by the @code{stat-report-schedule} configuration | ||
2241 | statement. | ||
2242 | |||
2243 | @deffn {Config} stat-report-schedule time | ||
2244 | Schedules generation of statistic reports. The @var{time} argument | ||
2245 | is a time specification in @samp{crontab} format | ||
2246 | (@pxref{crontab,,,crontab(5),crontab(5) manual page}). By default, | ||
2247 | reports are generated hourly. | ||
2248 | |||
2249 | To create reports each three hours, set | ||
2250 | |||
2251 | @example | ||
2252 | stat-report-schedule "0 */3 * * *"; | ||
2253 | @end example | ||
2254 | |||
2255 | To create them at midnight, use | ||
2256 | |||
2257 | @example | ||
2258 | stat-report-schedule "@@midnight"; | ||
2259 | @end example | ||
2260 | @end deffn | ||
2261 | |||
2262 | Statistic report is suppressed if there were no uploads since the last | ||
2263 | report. | ||
2264 | |||
2240 | The following example illustrates what you might get if you configured | 2265 | The following example illustrates what you might get if you configured |
2241 | full statistics output: | 2266 | full statistic reports: |
2242 | 2267 | ||
2243 | @smallexample | 2268 | @smallexample |
2244 | errors: 0 | 2269 | errors: 0 |
@@ -2256,8 +2281,8 @@ symlinks created: 0 | |||
2256 | symlinks removed: 0 | 2281 | symlinks 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 |
2260 | unique configuration keyword is associated with it. The statistics | 2285 | unique configuration keyword is associated with it. The statistic |
2261 | items and their corresponding keywords are described in the table | 2286 | items and their corresponding keywords are described in the table |
2262 | below: | 2287 | below: |
2263 | 2288 | ||
@@ -2322,12 +2347,12 @@ A symlink is created. | |||
2322 | A symlink is removed. | 2347 | A symlink is removed. |
2323 | @end table | 2348 | @end table |
2324 | 2349 | ||
2325 | There are two ways to enable the statistics logging. The | 2350 | There 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 |
2331 | configured using the @code{statistics} statement. This statement takes | 2356 | configured using the @code{statistics} statement. This statement takes |
2332 | a list of arguments, each one being one of the keywords, described | 2357 | a list of arguments, each one being one of the keywords, described |
2333 | above. For example, the following statement causes only the | 2358 | above. 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 |
2358 | output. This keyword may also be followed by any number of statistics | 2383 | report. This keyword may also be followed by any number of statistic |
2359 | keywords, which are in this case @emph{excluded} from the | 2384 | item names, which are in this case @emph{excluded} from the |
2360 | summary. For example, to output all statistics, except errors and | 2385 | summary. For example, to output all statistic data, except errors and |
2361 | warnings one would set: | 2386 | warnings 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 |
2549 | by @command{wydawca}. In daemon mode, it is scheduled periodically | 2574 | by @command{wydawca}. In daemon mode, it is scheduled periodically |
2550 | as controlled by @code{stat-report-interval} statement. In cron mode | 2575 | as controlled by the @code{stat-report-schedule} statement. In cron mode |
2551 | it is emitted when all spools have been processed. | 2576 | it is emitted when all spools have been processed. |
2552 | 2577 | ||
2553 | For compatibility with @command{wydawca} versions prior to 3.1.95, the | 2578 | For 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 | |||
2603 | runs at. | 2628 | runs at. |
2604 | 2629 | ||
2605 | @deffn {mod_mailutils} admin-address email | 2630 | @deffn {mod_mailutils} admin-address email |
2606 | Sets the admin email address or addresses. The statistics | 2631 | Sets the admin email address or addresses. The statistic |
2607 | notifications and any notifications configured to be sent to admins | 2632 | notifications and any notifications configured to be sent to admins |
2608 | will be forwarded to this address. The @var{email} argument is either | 2633 | will be forwarded to this address. The @var{email} argument is either |
2609 | a @acronym{RFC} 822 email address, or a list of such addresses. For | 2634 | a @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 |
2824 | The argument is a list of statistics keywords as described in | 2849 | The 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 |
2826 | counters for at least one of the requested categories are not | 2851 | counters for at least one of the requested categories are not |
2827 | zero. For example, the following statement requires sending | 2852 | zero. For example, the following statement requires sending |
2828 | notifications only if there occurred any errors or access violation | 2853 | notifications 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 |
2846 | The variables available for use in statistics reports are: | 2871 | The 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 |
3279 | Specifies the message to be logged. The @var{text} argument can | 3304 | Specifies the message to be logged. The @var{text} argument can |
3280 | contain references to statistics variables (@pxref{statistics | 3305 | contain references to statistic variables (@pxref{statistic |
3281 | variables}). | 3306 | variables}). |
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}. |
3463 | archive-signatures @var{arg:@i{boolean}}; | 3488 | archive-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}. | ||
3492 | stat-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}. |
3467 | statistics @var{items:@i{string}}; | 3497 | statistics @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\ |