"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,
},
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,
}
}
+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;
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);
}
}
}