summaryrefslogtreecommitdiffstats
path: root/tests/syslog_caller.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-09-29 14:31:44 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2010-09-29 14:31:44 +0200
commit33888b84e7dc6ec4341e066c68c7077cade24a7b (patch)
tree4467aeecc3b543d9dd5b193a05813187ca3a2349 /tests/syslog_caller.c
parent829a446c9f00e2f7016f09e18358458e2cc02189 (diff)
downloadrsyslog-33888b84e7dc6ec4341e066c68c7077cade24a7b.tar.gz
rsyslog-33888b84e7dc6ec4341e066c68c7077cade24a7b.tar.xz
rsyslog-33888b84e7dc6ec4341e066c68c7077cade24a7b.zip
imuxsock: indicate when rate limiting begins, include pid in rl messages
also improved test tool
Diffstat (limited to 'tests/syslog_caller.c')
-rw-r--r--tests/syslog_caller.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/tests/syslog_caller.c b/tests/syslog_caller.c
index 60f24166..3f2702a6 100644
--- a/tests/syslog_caller.c
+++ b/tests/syslog_caller.c
@@ -5,6 +5,11 @@
* It is highly suggested NOT to "base" any derivative work
* on this tool ;)
*
+ * Options
+ *
+ * -s severity (0..7 accoding to syslog spec, r "rolling", default 6)
+ * -m number of messages to generate (default 500)
+ *
* Part of the testbench for rsyslog.
*
* Copyright 2010 Rainer Gerhards and Adiscon GmbH.
@@ -28,21 +33,43 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <getopt.h>
#include <syslog.h>
+static void usage(void)
+{
+ fprintf(stderr, "usage: syslog_caller num-messages\n");
+ exit(1);
+}
+
+
int main(int argc, char *argv[])
{
int i;
- int sev = 0;
- if(argc != 2) {
- fprintf(stderr, "usage: syslog_caller num-messages\n");
- exit(1);
- }
+ int opt;
+ int bRollingSev = 0;
+ int sev = 6;
+ int msgs = 500;
- int msgs = atoi(argv[1]);
+ while((opt = getopt(argc, argv, "m:s:")) != -1) {
+ switch (opt) {
+ case 's': if(*optarg == 'r') {
+ bRollingSev = 1;
+ sev = 0;
+ } else
+ sev = atoi(optarg);
+ break;
+ case 'm': msgs = atoi(optarg);
+ break;
+ default: usage();
+ break;
+ }
+ }
for(i = 0 ; i < msgs ; ++i) {
syslog(sev % 8, "test message nbr %d, severity=%d", i, sev % 8);
- sev++;
+ if(bRollingSev)
+ sev++;
}
+ return(0);
}