From: Konrad Kuchciak Date: Mon, 30 Nov 2020 09:04:46 +0000 (+0100) Subject: Add 'xxx_reporting_period' config options X-Git-Tag: submit/tizen/20201203.125951~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed85829496ed28070ecce581ffe75c9946f2f0a9;p=platform%2Fcore%2Fsystem%2Fstability-monitor.git Add 'xxx_reporting_period' config options Added four new config options: - cpu_reporting_period - mem_reporting_period - io_reporting_period - fd_reporting_period -1 means to report only once value >= 0 denotes minimum period of time (seconds) between reports Change-Id: Ia63483bca90864ec5cc7f0c2295c4c8d60d991d8 --- diff --git a/config/default.conf b/config/default.conf index 195a9df..a9b4d53 100644 --- a/config/default.conf +++ b/config/default.conf @@ -9,16 +9,20 @@ "cpu_limit_avg": 4, "cpu_avg_period": 10, "cpu_limit_peak": 4, + "cpu_reporting_period": 20, "mem_limit_avg": 1, "mem_avg_period": 10, "mem_limit_peak": 1, + "mem_reporting_period": 20, "io_limit_avg": 100.0, "io_avg_period": 10, "io_limit_peak": 100.0, + "io_reporting_period": 20, "fd_limit": 1000, + "fd_reporting_period": 60, }, diff --git a/src/data_source.h b/src/data_source.h index 69257e0..27809ee 100644 --- a/src/data_source.h +++ b/src/data_source.h @@ -43,6 +43,8 @@ struct data_source { void *extra_data; int action_in_progress; + int reporting_period; /* seconds */ + unsigned long long last_report_time; int (*update)(struct data_source *ds, struct raw_data_item *rd_global, diff --git a/src/data_sources/tsm_cpu.c b/src/data_sources/tsm_cpu.c index 3d972eb..92cac5e 100644 --- a/src/data_sources/tsm_cpu.c +++ b/src/data_sources/tsm_cpu.c @@ -96,6 +96,11 @@ static int apply_config(struct data_source *ds, char *key, struct json_object *v return 0; } + if (strcmp(key, "cpu_reporting_period") == 0) { + ds->reporting_period = json_object_get_int(val); + return 0; + } + return -1; } diff --git a/src/data_sources/tsm_fd.c b/src/data_sources/tsm_fd.c index 665b587..9ba8417 100644 --- a/src/data_sources/tsm_fd.c +++ b/src/data_sources/tsm_fd.c @@ -55,6 +55,11 @@ static int apply_config(struct data_source *ds, char *key, struct json_object *v return 0; } + if (strcmp(key, "fd_reporting_period") == 0) { + ds->reporting_period = json_object_get_int(val); + return 0; + } + return -1; } diff --git a/src/data_sources/tsm_io.c b/src/data_sources/tsm_io.c index f2e5819..40e2f7e 100644 --- a/src/data_sources/tsm_io.c +++ b/src/data_sources/tsm_io.c @@ -93,6 +93,11 @@ static int apply_config(struct data_source *ds, char *key, struct json_object *v return 0; } + if (strcmp(key, "io_reporting_period") == 0) { + ds->reporting_period = json_object_get_int(val); + return 0; + } + return -1; } diff --git a/src/data_sources/tsm_mem.c b/src/data_sources/tsm_mem.c index 287d23f..7fbde5a 100644 --- a/src/data_sources/tsm_mem.c +++ b/src/data_sources/tsm_mem.c @@ -68,6 +68,11 @@ static int apply_config(struct data_source *ds, char *key, struct json_object *v return 0; } + if (strcmp(key, "mem_reporting_period") == 0) { + ds->reporting_period = json_object_get_int(val); + return 0; + } + return -1; } diff --git a/src/process.c b/src/process.c index e6f9001..cf6b183 100644 --- a/src/process.c +++ b/src/process.c @@ -392,6 +392,18 @@ const char *process_class_to_string(int class) } } +static void _run_action(struct data_source *ds, enum limit_type lt) +{ + unsigned long long t = time_now(); + + if ((ds->reporting_period < 0 && ds->last_report_time == 0) || + (ds->reporting_period >= 0 && t - ds->last_report_time > ds->reporting_period * USEC_PER_SEC)) { + + ds->action(ds, lt); + ds->last_report_time = t; + } +} + void process_check_limits(struct proc_info *process) { struct data_source *ds; @@ -411,16 +423,14 @@ void process_check_limits(struct proc_info *process) if (sample_is_greater(last_sample, &ds->limit.peak)) { _I_PROC(process, "%s: PEAK limit exceeded (%s)", ds->name, smpl2str(last_sample)); - - ds->action(ds, LIMIT_TYPE_PEAK); + _run_action(ds, LIMIT_TYPE_PEAK); } /* Avg limit */ if (sc->average > ds->limit.avg) { _I_PROC(process, "%s: AVG limit exceeded (%2.3lf)", ds->name, sc->average); - - ds->action(ds, LIMIT_TYPE_AVG); + _run_action(ds, LIMIT_TYPE_AVG); } } }