From 33888b84e7dc6ec4341e066c68c7077cade24a7b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 29 Sep 2010 14:31:44 +0200 Subject: imuxsock: indicate when rate limiting begins, include pid in rl messages also improved test tool --- tests/syslog_caller.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'tests') 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 #include +#include #include +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); } -- cgit