diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:28:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:28:20 +0000 |
commit | dcc721a95bef6f0d8e6d8775b8efe33e5aecd562 (patch) | |
tree | 66a2774cd0ee294d019efd71d2544c70f42b2842 /tests/dynstats-json.sh | |
parent | Initial commit. (diff) | |
download | rsyslog-dcc721a95bef6f0d8e6d8775b8efe33e5aecd562.tar.xz rsyslog-dcc721a95bef6f0d8e6d8775b8efe33e5aecd562.zip |
Adding upstream version 8.2402.0.upstream/8.2402.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dynstats-json.sh')
-rwxr-xr-x | tests/dynstats-json.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/dynstats-json.sh b/tests/dynstats-json.sh new file mode 100755 index 0000000..ba11cdd --- /dev/null +++ b/tests/dynstats-json.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# added 2016-03-30 by singh.janmejay +# This file is part of the rsyslog project, released under ASL 2.0 +echo =============================================================================== +echo \[dynstats-json.sh\]: test for verifying stats are reported correctly in json format +. ${srcdir:=.}/diag.sh init +generate_conf +add_conf ' +dyn_stats(name="stats_one") +dyn_stats(name="stats_two") + +ruleset(name="stats") { + action(type="omfile" file="'${RSYSLOG_DYNNAME}'.out.stats.log") +} + +module(load="../plugins/impstats/.libs/impstats" interval="2" severity="7" resetCounters="on" Ruleset="stats" bracketing="on" format="json") + +template(name="outfmt" type="string" string="%msg%\n") + +set $.p = field($msg, 32, 1); +if ($.p == "foo") then { + set $.ign = dyn_inc("stats_one", $.p); + set $.ign = dyn_inc("stats_two", $.p); +} + +action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt") +' +startup +wait_for_stats_flush ${RSYSLOG_DYNNAME}.out.stats.log +injectmsg_file $srcdir/testsuites/dynstats_input_1 +wait_queueempty +wait_for_stats_flush ${RSYSLOG_DYNNAME}.out.stats.log +echo doing shutdown +shutdown_when_empty +echo wait on shutdown +wait_shutdown +custom_content_check '{ "name": "global", "origin": "dynstats", "values": { "stats_one.ops_overflow": 0, "stats_one.new_metric_add": 1, "stats_one.no_metric": 0, "stats_one.metrics_purged": 0, "stats_one.ops_ignored": 0, "stats_one.purge_triggered": 0, "stats_two.ops_overflow": 0, "stats_two.new_metric_add": 1, "stats_two.no_metric": 0, "stats_two.metrics_purged": 0, "stats_two.ops_ignored": 0, "stats_two.purge_triggered": 0 } }' "${RSYSLOG_DYNNAME}.out.stats.log" +custom_content_check '{ "name": "stats_one", "origin": "dynstats.bucket", "values": { "foo": 1 } }' "${RSYSLOG_DYNNAME}.out.stats.log" +custom_content_check '{ "name": "stats_two", "origin": "dynstats.bucket", "values": { "foo": 1 } }' "${RSYSLOG_DYNNAME}.out.stats.log" +exit_test |