"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/validate.c" between
monit-5.25.3.tar.gz and monit-5.26.0.tar.gz

About: Monit is a utility for managing and monitoring processes, files, directories and filesystems (with automatic error recovery).

validate.c  (monit-5.25.3):validate.c  (monit-5.26.0)
skipping to change at line 401 skipping to change at line 401
break; break;
default: default:
LogError("'%s' error -- unknown resource ID: [%d]\n", s- >name, r->resource_id); LogError("'%s' error -- unknown resource ID: [%d]\n", s- >name, r->resource_id);
return State_Failed; return State_Failed;
} }
Event_post(s, Event_Resource, rv, r->action, "%s", report); Event_post(s, Event_Resource, rv, r->action, "%s", report);
return rv; return rv;
} }
static State_Type _checkLoadAverage(Resource_T r, double loadavg, char *name, ch
ar report[STRLEN]) {
if (Util_evalDoubleQExpression(r->operator, loadavg, r->limit)) {
snprintf(report, STRLEN, "%s of %.1f matches resource limit [%s
%s %.1f]", name, loadavg, name, operatorshortnames[r->operator], r->limit);
return State_Failed;
}
snprintf(report, STRLEN, "%s check succeeded [current %s = %.1f]", name,
name, loadavg);
return State_Succeeded;
}
static State_Type _checkSystemResources(Service_T s, Resource_T r) { static State_Type _checkSystemResources(Service_T s, Resource_T r) {
ASSERT(s); ASSERT(s);
ASSERT(r); ASSERT(r);
State_Type rv = State_Succeeded; State_Type rv = State_Succeeded;
char report[STRLEN] = {}, buf1[10], buf2[10]; char report[STRLEN] = {}, buf1[10], buf2[10];
switch (r->resource_id) { switch (r->resource_id) {
case Resource_CpuPercent: case Resource_CpuPercent:
{ {
float cpu = float cpu =
#ifdef HAVE_CPU_WAIT #ifdef HAVE_CPU_WAIT
skipping to change at line 502 skipping to change at line 511
if (Util_evalDoubleQExpression(r->operator, syst eminfo.swap.usage.bytes, r->limit)) { if (Util_evalDoubleQExpression(r->operator, syst eminfo.swap.usage.bytes, r->limit)) {
rv = State_Failed; rv = State_Failed;
snprintf(report, STRLEN, "swap amount of %s matches resource limit [swap amount %s %s]", Fmt_bytes2str(systeminfo.swap.u sage.bytes, buf1), operatorshortnames[r->operator], Fmt_bytes2str(r->limit, buf2 )); snprintf(report, STRLEN, "swap amount of %s matches resource limit [swap amount %s %s]", Fmt_bytes2str(systeminfo.swap.u sage.bytes, buf1), operatorshortnames[r->operator], Fmt_bytes2str(r->limit, buf2 ));
} else { } else {
snprintf(report, STRLEN, "swap amount ch eck succeeded [current swap amount = %s]", Fmt_bytes2str(systeminfo.swap.usage.b ytes, buf1)); snprintf(report, STRLEN, "swap amount ch eck succeeded [current swap amount = %s]", Fmt_bytes2str(systeminfo.swap.usage.b ytes, buf1));
} }
} }
break; break;
case Resource_LoadAverage1m: case Resource_LoadAverage1m:
if (Util_evalDoubleQExpression(r->operator, systeminfo.l rv = _checkLoadAverage(r, systeminfo.loadavg[0], "loadav
oadavg[0], r->limit)) { g (1min)", report);
rv = State_Failed;
snprintf(report, STRLEN, "loadavg(1min) of %.1f
matches resource limit [loadavg(1min) %s %.1f]", systeminfo.loadavg[0], operator
shortnames[r->operator], r->limit);
} else {
snprintf(report, STRLEN, "loadavg(1min) check su
cceeded [current loadavg(1min) = %.1f]", systeminfo.loadavg[0]);
}
break; break;
case Resource_LoadAverage5m: case Resource_LoadAverage5m:
if (Util_evalDoubleQExpression(r->operator, systeminfo.l rv = _checkLoadAverage(r, systeminfo.loadavg[1], "loadav
oadavg[1], r->limit)) { g (5min)", report);
rv = State_Failed;
snprintf(report, STRLEN, "loadavg(5min) of %.1f
matches resource limit [loadavg(5min) %s %.1f]", systeminfo.loadavg[1], operator
shortnames[r->operator], r->limit);
} else {
snprintf(report, STRLEN, "loadavg(5min) check su
cceeded [current loadavg(5min) = %.1f]", systeminfo.loadavg[1]);
}
break; break;
case Resource_LoadAverage15m: case Resource_LoadAverage15m:
if (Util_evalDoubleQExpression(r->operator, systeminfo.l rv = _checkLoadAverage(r, systeminfo.loadavg[2], "loadav
oadavg[2], r->limit)) { g (15min)", report);
rv = State_Failed; break;
snprintf(report, STRLEN, "loadavg(15min) of %.1f
matches resource limit [loadavg(15min) %s %.1f]", systeminfo.loadavg[2], operat case Resource_LoadAveragePerCore1m:
orshortnames[r->operator], r->limit); rv = _checkLoadAverage(r, systeminfo.loadavg[0] / (doubl
} else { e)systeminfo.cpu.count, "loadavg per core (1min)", report);
snprintf(report, STRLEN, "loadavg(15min) check s break;
ucceeded [current loadavg(15min) = %.1f]", systeminfo.loadavg[2]);
} case Resource_LoadAveragePerCore5m:
rv = _checkLoadAverage(r, systeminfo.loadavg[1] / (doubl
e)systeminfo.cpu.count, "loadavg per core (5min)", report);
break;
case Resource_LoadAveragePerCore15m:
rv = _checkLoadAverage(r, systeminfo.loadavg[2] / (doubl
e)systeminfo.cpu.count, "loadavg per core (15min)", report);
break; break;
default: default:
LogError("'%s' error -- unknown resource ID: [%d]\n", s- >name, r->resource_id); LogError("'%s' error -- unknown resource ID: [%d]\n", s- >name, r->resource_id);
return State_Failed; return State_Failed;
} }
Event_post(s, Event_Resource, rv, r->action, "%s", report); Event_post(s, Event_Resource, rv, r->action, "%s", report);
return rv; return rv;
} }
 End of changes. 4 change blocks. 
30 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)