summaryrefslogtreecommitdiffstats
path: root/tests/dynstats-vg.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:28:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:28:20 +0000
commitdcc721a95bef6f0d8e6d8775b8efe33e5aecd562 (patch)
tree66a2774cd0ee294d019efd71d2544c70f42b2842 /tests/dynstats-vg.sh
parentInitial commit. (diff)
downloadrsyslog-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-vg.sh')
-rwxr-xr-xtests/dynstats-vg.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/dynstats-vg.sh b/tests/dynstats-vg.sh
new file mode 100755
index 0000000..9a0ff8b
--- /dev/null
+++ b/tests/dynstats-vg.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# added 2015-11-13 by singh.janmejay
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[dynstats-vg.sh\]: test for gathering stats over dynamic metric names with valgrind
+. ${srcdir:=.}/diag.sh init
+generate_conf
+add_conf '
+ruleset(name="stats") {
+ action(type="omfile" file="'${RSYSLOG_DYNNAME}'.out.stats.log")
+}
+
+module(load="../plugins/impstats/.libs/impstats" interval="1" severity="7" resetCounters="on" Ruleset="stats" bracketing="on")
+
+template(name="outfmt" type="string" string="%msg% %$.increment_successful%\n")
+
+dyn_stats(name="msg_stats")
+
+set $.msg_prefix = field($msg, 32, 1);
+
+set $.increment_successful = dyn_inc("msg_stats", $.msg_prefix);
+
+action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt")
+'
+startup_vg
+wait_for_stats_flush ${RSYSLOG_DYNNAME}.out.stats.log
+injectmsg_file $srcdir/testsuites/dynstats_input
+wait_queueempty
+content_check "foo 001 0"
+content_check "bar 002 0"
+content_check "baz 003 0"
+content_check "foo 004 0"
+content_check "baz 005 0"
+content_check "foo 006 0"
+rst_msleep 1100 # wait for stats flush
+echo doing shutdown
+shutdown_when_empty
+echo wait on shutdown
+wait_shutdown_vg
+check_exit_vg
+custom_content_check 'bar=1' "${RSYSLOG_DYNNAME}.out.stats.log"
+first_column_sum_check 's/.*foo=\([0-9]*\)/\1/g' 'foo=' "${RSYSLOG_DYNNAME}.out.stats.log" 3
+first_column_sum_check 's/.*bar=\([0-9]*\)/\1/g' 'bar=' "${RSYSLOG_DYNNAME}.out.stats.log" 1
+first_column_sum_check 's/.*baz=\([0-9]*\)/\1/g' 'baz=' "${RSYSLOG_DYNNAME}.out.stats.log" 2
+exit_test