Skip to content

3.6queue/f/stats reset - #14

Merged
bazsi merged 36 commits into
masterfrom
3.6queue/f/stats-reset
Dec 2, 2013
Merged

bazsi merged 36 commits into
masterfrom
3.6queue/f/stats-reset

Conversation

@bazsi

@bazsi bazsi commented Nov 16, 2013

Copy link
Copy Markdown
Collaborator

No description provided.

@bazsi

bazsi commented Nov 27, 2013

Copy link
Copy Markdown
Collaborator Author

Branch is updated to operate stats-lifetime() as discussed on the mailing list.

Another round of review would be needed, thanks.

@algernon

Copy link
Copy Markdown
Contributor

Will do the review today, thanks for the heads up!

bazsi added 28 commits December 1, 2013 13:22
Instead of open coding the implementation, use the function.

Signed-off-by: Balazs Scheidler <[email protected]>
syslog-ng tracks counters for each $PROGRAM it receives at stats-level(3),
add a last-update timestamp too.

Signed-off-by: Balazs Scheidler <[email protected]>
Earlier this include was acquired through stats.h, but that header got
rid off that.
Previously statistic counters were cleaned up when they were orphaned,
at reload time. This is not really good for anything as at high stats
levels, syslog-ng can consume a lot of memory for random $PROGRAM, $HOST
values. Pruning these at reload time doesn't really solve the problem.

In subsequent patches this cleanup scheme is being changed to a timer
based approach that regularly cleans up counters that were updated
a long time ago.

Signed-off-by: Balazs Scheidler <[email protected]>
…and_increment_dynamic_counter()

To make it easier to understand its purpose.

Signed-off-by: Balazs Scheidler <[email protected]>
This patch adds a new function that cleans up counters that were updated
the given time interval ago. It only cleans up dynamic entries, e.g.
counters that relate to $HOST, $PROGRAM and $HOST_FROM.

Signed-off-by: Balazs Scheidler <[email protected]>
This patch implements a periodic timer that cleans up stats counters
after a specific lifetime. It defaults to 10 minutes.

Every 10 minutes, syslog-ng will walk the set of registered counters
and drops all that are older than the specific lifetime.

The user configurability is coming in a separate patch.

Signed-off-by: Balazs Scheidler <[email protected]>
This patch implements stats-lifetime() option that controls how long a
dynamic stats counter is alive. The setting is not exact, as syslog-ng will
actively check the whole set of counters every once in a while, and then
prune those that are too old. It may happen that some of the counters live
a bit longer than the stats-lifetime() setting.

Signed-off-by: Balazs Scheidler <[email protected]>
Use a separate StatsOptions structure and separate grammar rules to
parse them. The stats subsystem became independent of the GlobalConfig
class, it just happens to use a member.

This patch also removes stats-timer.c as the timer requires access
to the global StatsOptions instance.

Signed-off-by: Balazs Scheidler <[email protected]>
Only to be used internall by the stats implementation.

Signed-off-by: Balazs Scheidler <[email protected]>
This patch renames StatsCounter to StatsCluster that better describes its
purpose, as it encapsulates a cluster of related counters.

Signed-off-by: Balazs Scheidler <[email protected]>
…unctions

To make the internal stats counter hash accessible by other stats related
modules.
and remove access to the underlying arrays, except from the accessor
functions.
This patch adds static qualifiers to the above functions and hides the
related string arrays within the functions.
This patch removes messages.h and misc.h from stats.c as they are no longer needed.
@bazsi
bazsi merged commit 583b3f2 into master Dec 2, 2013
@bazsi
bazsi deleted the 3.6queue/f/stats-reset branch December 2, 2013 13:49
@bazsi
bazsi restored the 3.6queue/f/stats-reset branch December 6, 2013 23:00
@bazsi
bazsi deleted the 3.6queue/f/stats-reset branch December 7, 2013 07:22
furiel pushed a commit to furiel/syslog-ng that referenced this pull request Feb 1, 2018
Kokan added a commit to Kokan/syslog-ng that referenced this pull request Oct 2, 2020
Every time a key created a counter names is allocated. But it is not
freed. The only time it is freed when a new stats-cluster is created
from it (first time looked up) and the counter_names owenership
transfared to the stats-cluster.

With this patch the allocation is delayed to the ownership change, thus
only allocated if there is still a pointer to the memory.

Reproduction:
1. syslog-ng configuration with at least one network source
2. start syslog-ng with a leak detector
(2.1 optional do restart (in order to have the exact leak as above))
3. stop syslog-ng

=================================================================
==2095056==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x55a4f86db781 in calloc (/tmp/install/sbin/syslog-ng+0xc5781)
    #1 0x7f343f03a941 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x50941)
    syslog-ng#2 0x7f343acb37c7 in _make_connection_conter_stats_queryable /home/user/src/syslog-ng/build/../modules/afsocket/afsocket-source.c:1007:9
    syslog-ng#3 0x7f343acb30f3 in afsocket_sd_init_method /home/user/src/syslog-ng/build/../modules/afsocket/afsocket-source.c:1060:5
    syslog-ng#4 0x7f343acbc358 in afinet_sd_init /home/user/src/syslog-ng/build/../modules/afsocket/afinet-source.c:103:8
    syslog-ng#5 0x7f343f248e1a in log_pipe_init /home/user/src/syslog-ng/build/../lib/logpipe.h:301:23
    syslog-ng#6 0x7f343f248c88 in cfg_tree_start /home/user/src/syslog-ng/build/../lib/cfg-tree.c:1419:12
    syslog-ng#7 0x7f343f23af71 in cfg_init /home/user/src/syslog-ng/build/../lib/cfg.c:368:8
    syslog-ng#8 0x7f343f270b3c in main_loop_reload_config_apply /home/user/src/syslog-ng/build/../lib/mainloop.c:276:41
    syslog-ng#9 0x7f343f273162 in _consume_action /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:240:3
    syslog-ng#10 0x7f343f27321f in _invoke_sync_call_actions /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:250:7
    syslog-ng#11 0x7f343f2736ba in main_loop_worker_sync_call /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:396:7
    syslog-ng#12 0x7f343f2709d1 in main_loop_reload_config_commence /home/user/src/syslog-ng/build/../lib/mainloop.c:340:3
    syslog-ng#13 0x7f343f275852 in control_connection_reload /home/user/src/syslog-ng/build/../lib/mainloop-control.c:167:3
    syslog-ng#14 0x7f343f290c80 in control_connection_io_input /home/user/src/syslog-ng/build/../lib/control/control-server.c:378:3
    syslog-ng#15 0x7f343efd4b2c  (/usr/lib/libivykis.so.0+0x6b2c)
    syslog-ng#16 0x7f343f239c50 in run_application_hook /home/user/src/syslog-ng/build/../lib/apphook.c:125:11

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x55a4f86db781 in calloc (/tmp/install/sbin/syslog-ng+0xc5781)
    #1 0x7f343f03a941 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x50941)
    syslog-ng#2 0x7f343acb3e27 in _stop_connection_counter_stats_queryable /home/user/src/syslog-ng/build/../modules/afsocket/afsocket-source.c:1027:9
    syslog-ng#3 0x7f343acb38bd in afsocket_sd_deinit_method /home/user/src/syslog-ng/build/../modules/afsocket/afsocket-source.c:1073:3
    syslog-ng#4 0x7f343f2491d4 in log_pipe_deinit /home/user/src/syslog-ng/build/../lib/logpipe.h:316:25
    syslog-ng#5 0x7f343f2490e5 in cfg_tree_stop /home/user/src/syslog-ng/build/../lib/cfg-tree.c:1439:12
    syslog-ng#6 0x7f343f23b2d1 in cfg_deinit /home/user/src/syslog-ng/build/../lib/cfg.c:387:10
    syslog-ng#7 0x7f343f271ec2 in main_loop_exit_finish /home/user/src/syslog-ng/build/../lib/mainloop.c:427:3
    syslog-ng#8 0x7f343f273162 in _consume_action /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:240:3
    syslog-ng#9 0x7f343f27321f in _invoke_sync_call_actions /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:250:7
    syslog-ng#9 0x7f343f27321f in _invoke_sync_call_actions /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:250:7
    syslog-ng#10 0x7f343f2736ba in main_loop_worker_sync_call /home/user/src/syslog-ng/build/../lib/mainloop-worker.c:396:7
    syslog-ng#11 0x7f343f2709d1 in main_loop_reload_config_commence /home/user/src/syslog-ng/build/../lib/mainloop.c:340:3
    syslog-ng#12 0x7f343f275852 in control_connection_reload /home/user/src/syslog-ng/build/../lib/mainloop-control.c:167:3
    syslog-ng#13 0x7f343f290c80 in control_connection_io_input /home/user/src/syslog-ng/build/../lib/control/control-server.c:378:3
    syslog-ng#14 0x7f343efd4b2c  (/usr/lib/libivykis.so.0+0x6b2c)
    syslog-ng#15 0x7f343f239c50 in run_application_hook /home/user/src/syslog-ng/build/../lib/apphook.c:125:11

Signed-off-by: Kokan <[email protected]>
HofiOne pushed a commit to HofiOne/syslog-ng that referenced this pull request Jun 10, 2024
syslog-ng-collector: update syslog-ng image location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants