"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/util.c" between
monit-5.27.2.tar.gz and monit-5.28.0.tar.gz

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

util.c  (monit-5.27.2):util.c  (monit-5.28.0)
skipping to change at line 797 skipping to change at line 797
if (s->restart->has_uid) if (s->restart->has_uid)
printf(" as uid %d", s->restart->uid); printf(" as uid %d", s->restart->uid);
if (s->restart->has_gid) if (s->restart->has_gid)
printf(" as gid %d", s->restart->gid); printf(" as gid %d", s->restart->gid);
printf(" timeout %s", Convert_time2str(s->restart->timeout, (cha r[11]){})); printf(" timeout %s", Convert_time2str(s->restart->timeout, (cha r[11]){}));
printf("\n"); printf("\n");
} }
for (NonExist_T o = s->nonexistlist; o; o = o->next) { for (NonExist_T o = s->nonexistlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Existence", StringBuffer_toString(Util_ printRule(buf, o->action, "if does not exist"))); printf(" %-20s = %s\n", "Existence", StringBuffer_toString(Util_ printRule(false, buf, o->action, "if does not exist")));
} }
for (Exist_T o = s->existlist; o; o = o->next) { for (Exist_T o = s->existlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Non-Existence", StringBuffer_toString(U til_printRule(buf, o->action, "if exist"))); printf(" %-20s = %s\n", "Non-Existence", StringBuffer_toString(U til_printRule(false, buf, o->action, "if exist")));
} }
for (Dependant_T o = s->dependantlist; o; o = o->next) for (Dependant_T o = s->dependantlist; o; o = o->next)
if (o->dependant != NULL) if (o->dependant != NULL)
printf(" %-20s = %s\n", "Depends on Service", o->dependa nt); printf(" %-20s = %s\n", "Depends on Service", o->dependa nt);
for (Pid_T o = s->pidlist; o; o = o->next) { for (Pid_T o = s->pidlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Pid", StringBuffer_toString(Util_printR ule(buf, o->action, "if changed"))); printf(" %-20s = %s\n", "Pid", StringBuffer_toString(Util_printR ule(false, buf, o->action, "if changed")));
} }
for (Pid_T o = s->ppidlist; o; o = o->next) { for (Pid_T o = s->ppidlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "PPid", StringBuffer_toString(Util_print Rule(buf, o->action, "if changed"))); printf(" %-20s = %s\n", "PPid", StringBuffer_toString(Util_print Rule(false, buf, o->action, "if changed")));
} }
for (FsFlag_T o = s->fsflaglist; o; o = o->next) { for (FsFlag_T o = s->fsflaglist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Filesystem flags", StringBuffer_toStrin g(Util_printRule(buf, o->action, "if changed"))); printf(" %-20s = %s\n", "Filesystem flags", StringBuffer_toStrin g(Util_printRule(false, buf, o->action, "if changed")));
} }
if (s->type == Service_Program) { if (s->type == Service_Program) {
printf(" %-20s = ", "Program timeout"); printf(" %-20s = ", "Program timeout");
printf("terminate the program if not finished within %s\n", Conv ert_time2str(s->program->timeout, (char[11]){})); printf("terminate the program if not finished within %s\n", Conv ert_time2str(s->program->timeout, (char[11]){}));
for (Status_T o = s->statuslist; o; o = o->next) { for (Status_T o = s->statuslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->operator == Operator_Changed) if (o->operator == Operator_Changed)
printf(" %-20s = %s\n", "Status", StringBuffer_t oString(Util_printRule(buf, o->action, "if exit value changed"))); printf(" %-20s = %s\n", "Status", StringBuffer_t oString(Util_printRule(false, buf, o->action, "if exit value changed")));
else else
printf(" %-20s = %s\n", "Status", StringBuffer_t oString(Util_printRule(buf, o->action, "if exit value %s %d", operatorshortnames [o->operator], o->return_value))); printf(" %-20s = %s\n", "Status", StringBuffer_t oString(Util_printRule(false, buf, o->action, "if exit value %s %d", operatorsho rtnames[o->operator], o->return_value)));
} }
} }
if (s->checksum && s->checksum->action) { if (s->checksum && s->checksum->action) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Checksum", printf(" %-20s = %s\n", "Checksum",
s->checksum->test_changes s->checksum->test_changes
? ?
StringBuffer_toString(Util_printRule(buf, s->checksum->ac tion, "if changed %s", checksumnames[s->checksum->type])) StringBuffer_toString(Util_printRule(false, buf, s->check sum->action, "if changed %s", checksumnames[s->checksum->type]))
: :
StringBuffer_toString(Util_printRule(buf, s->checksum->ac tion, "if failed %s(%s)", s->checksum->hash, checksumnames[s->checksum->type])) StringBuffer_toString(Util_printRule(false, buf, s->check sum->action, "if failed %s(%s)", s->checksum->hash, checksumnames[s->checksum->t ype]))
); );
} }
if (s->perm && s->perm->action) { if (s->perm && s->perm->action) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Permission", printf(" %-20s = %s\n", "Permission",
s->perm->test_changes s->perm->test_changes
? ?
StringBuffer_toString(Util_printRule(buf, s->perm->action , "if changed")) StringBuffer_toString(Util_printRule(false, buf, s->perm- >action, "if changed"))
: :
StringBuffer_toString(Util_printRule(buf, s->perm->action , "if failed %04o", s->perm->perm)) StringBuffer_toString(Util_printRule(false, buf, s->perm- >action, "if failed %04o", s->perm->perm))
); );
} }
if (s->uid && s->uid->action) { if (s->uid && s->uid->action) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "UID", StringBuffer_toString(Util_printR ule(buf, s->uid->action, "if failed %d", s->uid->uid))); printf(" %-20s = %s\n", "UID", StringBuffer_toString(Util_printR ule(false, buf, s->uid->action, "if failed %d", s->uid->uid)));
} }
if (s->euid && s->euid->action) { if (s->euid && s->euid->action) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "EUID", StringBuffer_toString(Util_print Rule(buf, s->euid->action, "if failed %d", s->euid->uid))); printf(" %-20s = %s\n", "EUID", StringBuffer_toString(Util_print Rule(false, buf, s->euid->action, "if failed %d", s->euid->uid)));
} }
for (SecurityAttribute_T o = s->secattrlist; o; o = o->next) { for (SecurityAttribute_T o = s->secattrlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Security attribute", StringBuffer_toStr ing(Util_printRule(buf, o->action, "if failed %s", o->attribute))); printf(" %-20s = %s\n", "Security attribute", StringBuffer_toStr ing(Util_printRule(false, buf, o->action, "if failed %s", o->attribute)));
} }
for (Filedescriptors_T o = s->filedescriptorslist; o; o = o->next) { for (Filedescriptors_T o = s->filedescriptorslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->total) { if (o->total) {
printf(" %-20s = %s\n", "Total filedescriptors", StringB uffer_toString(Util_printRule(buf, o->action, "if %s %lld", operatornames[o->ope rator], o->limit_absolute))); printf(" %-20s = %s\n", "Total filedescriptors", StringB uffer_toString(Util_printRule(false, buf, o->action, "if %s %lld", operatornames [o->operator], o->limit_absolute)));
} else { } else {
if (o->limit_absolute > -1) if (o->limit_absolute > -1)
printf(" %-20s = %s\n", "Filedescriptors", Strin gBuffer_toString(Util_printRule(buf, o->action, "if %s %lld", operatornames[o->o perator], o->limit_absolute))); printf(" %-20s = %s\n", "Filedescriptors", Strin gBuffer_toString(Util_printRule(false, buf, o->action, "if %s %lld", operatornam es[o->operator], o->limit_absolute)));
else else
printf(" %-20s = %s\n", "Filedescriptors", Strin gBuffer_toString(Util_printRule(buf, o->action, "if %s %.1f%%", operatornames[o- >operator], o->limit_percent))); printf(" %-20s = %s\n", "Filedescriptors", Strin gBuffer_toString(Util_printRule(false, buf, o->action, "if %s %.1f%%", operatorn ames[o->operator], o->limit_percent)));
} }
} }
if (s->gid && s->gid->action) { if (s->gid && s->gid->action) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "GID", StringBuffer_toString(Util_printR ule(buf, s->gid->action, "if failed %d", s->gid->gid))); printf(" %-20s = %s\n", "GID", StringBuffer_toString(Util_printR ule(false, buf, s->gid->action, "if failed %d", s->gid->gid)));
} }
for (Icmp_T o = s->icmplist; o; o = o->next) { for (Icmp_T o = s->icmplist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
const char *output = StringBuffer_toString(Util_printRule(buf, o StringBuffer_T buf2 = StringBuffer_create(64);
->action, StringBuffer_append(buf2, "if %s count %d size %d with timeout %
"if failed [count %d size %d with timeou s", o->check_invers ? "succeeded" : "failed", o->count, o->size, Convert_time2st
t %s%s%s]", o->count, o->size, Convert_time2str(o->timeout, (char[11]){}), o->ou r(o->timeout, (char[11]){}));
tgoing.ip ? " via address " : "", o->outgoing.ip ? o->outgoing.ip : "")); if (o->responsetime.limit > -1.)
StringBuffer_append(buf2, " and responsetime %s %s", ope
ratornames[o->responsetime.operator], Convert_time2str(o->responsetime.limit, (c
har[11]){}));
if (o->outgoing.ip)
StringBuffer_append(buf2, " via address %s", o->outgoin
g.ip);
switch (o->family) { switch (o->family) {
case Socket_Ip4: case Socket_Ip4:
printf(" %-20s = %s\n", "Ping4", output); printf(" %-20s = %s\n", "Ping4", StringBuffer_to String(Util_printRule(o->check_invers, buf, o->action, "%s", StringBuffer_toStri ng(buf2))));
break; break;
case Socket_Ip6: case Socket_Ip6:
printf(" %-20s = %s\n", "Ping6", output); printf(" %-20s = %s\n", "Ping6", StringBuffer_to String(Util_printRule(o->check_invers, buf, o->action, "%s", StringBuffer_toStri ng(buf2))));
break; break;
default: default:
printf(" %-20s = %s\n", "Ping", output); printf(" %-20s = %s\n", "Ping", StringBuffer_toS tring(Util_printRule(o->check_invers, buf, o->action, "%s", StringBuffer_toStrin g(buf2))));
break; break;
} }
StringBuffer_free(&buf2);
} }
for (Port_T o = s->portlist; o; o = o->next) { for (Port_T o = s->portlist; o; o = o->next) {
StringBuffer_clear(buf);
StringBuffer_T buf2 = StringBuffer_create(64); StringBuffer_T buf2 = StringBuffer_create(64);
StringBuffer_append(buf2, "if failed [%s]:%d%s", StringBuffer_append(buf2, "if %s [%s]:%d%s",
o->hostname, o->target.net.port, Util_portRequestDescrip o->check_invers ? "succeeded" : "failed", o->hostname, o
tion(o)); ->target.net.port, Util_portRequestDescription(o));
if (o->outgoing.ip) if (o->outgoing.ip)
StringBuffer_append(buf2, " via address %s", o->outgoing .ip); StringBuffer_append(buf2, " via address %s", o->outgoing .ip);
StringBuffer_append(buf2, " type %s/%s protocol %s with timeout %s", StringBuffer_append(buf2, " type %s/%s protocol %s with timeout %s",
Util_portTypeDescription(o), Util_portIpDescription(o), o->protocol->name, Convert_time2str(o->timeout, (char[11]){})); Util_portTypeDescription(o), Util_portIpDescription(o), o->protocol->name, Convert_time2str(o->timeout, (char[11]){}));
if (o->retry > 1) if (o->retry > 1)
StringBuffer_append(buf2, " and retry %d times", o->retr y); StringBuffer_append(buf2, " and retry %d times", o->retr y);
if (o->responsetime.limit > -1.)
StringBuffer_append(buf2, " and responsetime %s %s", ope
ratornames[o->responsetime.operator], Convert_time2str(o->responsetime.limit, (c
har[11]){}));
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (o->target.net.ssl.options.flags) { if (o->target.net.ssl.options.flags) {
StringBuffer_append(buf2, " using TLS"); StringBuffer_append(buf2, " using TLS");
const char *options = Ssl_printOptions(&o->target.net.ss l.options, (char[STRLEN]){}, STRLEN); const char *options = Ssl_printOptions(&o->target.net.ss l.options, (char[STRLEN]){}, STRLEN);
if (options && *options) if (options && *options)
StringBuffer_append(buf2, " with options {%s}", options); StringBuffer_append(buf2, " with options {%s}", options);
if (o->target.net.ssl.certificate.minimumDays > 0) if (o->target.net.ssl.certificate.minimumDays > 0)
StringBuffer_append(buf2, " and certificate vali d for at least %d days", o->target.net.ssl.certificate.minimumDays); StringBuffer_append(buf2, " and certificate vali d for at least %d days", o->target.net.ssl.certificate.minimumDays);
if (o->target.net.ssl.options.checksum) if (o->target.net.ssl.options.checksum)
StringBuffer_append(buf2, " and certificate chec ksum %s equal to '%s'", checksumnames[o->target.net.ssl.options.checksumType], o ->target.net.ssl.options.checksum); StringBuffer_append(buf2, " and certificate chec ksum %s equal to '%s'", checksumnames[o->target.net.ssl.options.checksumType], o ->target.net.ssl.options.checksum);
} }
#endif #endif
StringBuffer_clear(buf); printf(" %-20s = %s\n", "Port", StringBuffer_toString(Util_print
printf(" %-20s = %s\n", "Port", StringBuffer_toString(Util_print Rule(o->check_invers, buf, o->action, "%s", StringBuffer_toString(buf2))));
Rule(buf, o->action, "%s", StringBuffer_toString(buf2))));
StringBuffer_free(&buf2); StringBuffer_free(&buf2);
} }
for (Port_T o = s->socketlist; o; o = o->next) { for (Port_T o = s->socketlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
StringBuffer_T buf2 = StringBuffer_create(64);
StringBuffer_append(buf2, "if %s %s type %s protocol %s with tim
eout %s", o->check_invers ? "succeeded" : "failed", o->target.unix.pathname, Uti
l_portTypeDescription(o), o->protocol->name, Convert_time2str(o->timeout, (char[
11]){}));
if (o->retry > 1) if (o->retry > 1)
printf(" %-20s = %s\n", "Unix Socket", StringBuffer_toSt StringBuffer_append(buf2, " and retry %d times", o->retr
ring(Util_printRule(buf, o->action, "if failed %s type %s protocol %s with timeo y);
ut %s and retry %d times", o->target.unix.pathname, Util_portTypeDescription(o), if (o->responsetime.limit > -1.)
o->protocol->name, Convert_time2str(o->timeout, (char[11]){}), o->retry))); StringBuffer_append(buf2, " and responsetime %s %s", ope
else ratornames[o->responsetime.operator], Convert_time2str(o->responsetime.limit, (c
printf(" %-20s = %s\n", "Unix Socket", StringBuffer_toSt har[11]){}));
ring(Util_printRule(buf, o->action, "if failed %s type %s protocol %s with timeo printf(" %-20s = %s\n", "Unix Socket", StringBuffer_toString(Uti
ut %s", o->target.unix.pathname, Util_portTypeDescription(o), o->protocol->name, l_printRule(o->check_invers, buf, o->action, "%s", StringBuffer_toString(buf2)))
Convert_time2str(o->timeout, (char[11]){})))); );
} }
for (Timestamp_T o = s->timestamplist; o; o = o->next) { for (Timestamp_T o = s->timestamplist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", timestampnames[o->type], printf(" %-20s = %s\n", timestampnames[o->type],
o->test_changes o->test_changes
? ?
StringBuffer_toString(Util_printRule(buf, o->action, "if changed")) StringBuffer_toString(Util_printRule(false, buf, o->actio n, "if changed"))
: :
StringBuffer_toString(Util_printRule(buf, o->action, "if %s %s", operatornames[o->operator], Convert_time2str(o->time * 1000., (char[11]) {}))) StringBuffer_toString(Util_printRule(false, buf, o->actio n, "if %s %s", operatornames[o->operator], Convert_time2str(o->time * 1000., (ch ar[11]){})))
); );
} }
for (Size_T o = s->sizelist; o; o = o->next) { for (Size_T o = s->sizelist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Size", printf(" %-20s = %s\n", "Size",
o->test_changes o->test_changes
? ?
StringBuffer_toString(Util_printRule(buf, o->action, "if changed")) StringBuffer_toString(Util_printRule(false, buf, o->actio n, "if changed"))
: :
StringBuffer_toString(Util_printRule(buf, o->action, "if %s %llu byte(s)", operatornames[o->operator], o->size)) StringBuffer_toString(Util_printRule(false, buf, o->actio n, "if %s %llu byte(s)", operatornames[o->operator], o->size))
); );
} }
for (LinkStatus_T o = s->linkstatuslist; o; o = o->next) { for (LinkStatus_T o = s->linkstatuslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Link status", StringBuffer_toString(Uti l_printRule(buf, o->action, "if failed"))); printf(" %-20s = %s\n", "Link status", StringBuffer_toString(Uti l_printRule(o->check_invers, buf, o->action, "if %s", o->check_invers ? "up" : " down")));
} }
for (LinkSpeed_T o = s->linkspeedlist; o; o = o->next) { for (LinkSpeed_T o = s->linkspeedlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Link capacity", StringBuffer_toString(U til_printRule(buf, o->action, "if changed"))); printf(" %-20s = %s\n", "Link capacity", StringBuffer_toString(U til_printRule(false, buf, o->action, "if changed")));
} }
for (LinkSaturation_T o = s->linksaturationlist; o; o = o->next) { for (LinkSaturation_T o = s->linksaturationlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Link utilization", StringBuffer_toStrin g(Util_printRule(buf, o->action, "if %s %.1f%%", operatornames[o->operator], o-> limit))); printf(" %-20s = %s\n", "Link utilization", StringBuffer_toStrin g(Util_printRule(false, buf, o->action, "if %s %.1f%%", operatornames[o->operato r], o->limit)));
} }
for (Bandwidth_T o = s->uploadbyteslist; o; o = o->next) { for (Bandwidth_T o = s->uploadbyteslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->range == Time_Second) { if (o->range == Time_Second) {
printf(" %-20s = %s\n", "Upload bytes", StringBuffer_toS tring(Util_printRule(buf, o->action, "if %s %s/s", operatornames[o->operator], C onvert_bytes2str(o->limit, buffer)))); printf(" %-20s = %s\n", "Upload bytes", StringBuffer_toS tring(Util_printRule(false, buf, o->action, "if %s %s/s", operatornames[o->opera tor], Convert_bytes2str(o->limit, buffer))));
} else { } else {
printf(" %-20s = %s\n", "Total upload bytes", StringBuff er_toString(Util_printRule(buf, o->action, "if %s %s in last %d %s(s)", operator names[o->operator], Convert_bytes2str(o->limit, buffer), o->rangecount, Util_tim estr(o->range)))); printf(" %-20s = %s\n", "Total upload bytes", StringBuff er_toString(Util_printRule(false, buf, o->action, "if %s %s in last %d %s(s)", o peratornames[o->operator], Convert_bytes2str(o->limit, buffer), o->rangecount, U til_timestr(o->range))));
} }
} }
for (Bandwidth_T o = s->uploadpacketslist; o; o = o->next) { for (Bandwidth_T o = s->uploadpacketslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->range == Time_Second) { if (o->range == Time_Second) {
printf(" %-20s = %s\n", "Upload packets", StringBuffer_t oString(Util_printRule(buf, o->action, "if %s %lld packets/s", operatornames[o-> operator], o->limit))); printf(" %-20s = %s\n", "Upload packets", StringBuffer_t oString(Util_printRule(false, buf, o->action, "if %s %lld packets/s", operatorna mes[o->operator], o->limit)));
} else { } else {
printf(" %-20s = %s\n", "Total upload packets", StringBu ffer_toString(Util_printRule(buf, o->action, "if %s %lld packets in last %d %s(s )", operatornames[o->operator], o->limit, o->rangecount, Util_timestr(o->range)) )); printf(" %-20s = %s\n", "Total upload packets", StringBu ffer_toString(Util_printRule(false, buf, o->action, "if %s %lld packets in last %d %s(s)", operatornames[o->operator], o->limit, o->rangecount, Util_timestr(o-> range))));
} }
} }
for (Bandwidth_T o = s->downloadbyteslist; o; o = o->next) { for (Bandwidth_T o = s->downloadbyteslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->range == Time_Second) { if (o->range == Time_Second) {
printf(" %-20s = %s\n", "Download bytes", StringBuffer_t oString(Util_printRule(buf, o->action, "if %s %s/s", operatornames[o->operator], Convert_bytes2str(o->limit, buffer)))); printf(" %-20s = %s\n", "Download bytes", StringBuffer_t oString(Util_printRule(false, buf, o->action, "if %s %s/s", operatornames[o->ope rator], Convert_bytes2str(o->limit, buffer))));
} else { } else {
printf(" %-20s = %s\n", "Total download bytes", StringBu ffer_toString(Util_printRule(buf, o->action, "if %s %s in last %d %s(s)", operat ornames[o->operator], Convert_bytes2str(o->limit, buffer), o->rangecount, Util_t imestr(o->range)))); printf(" %-20s = %s\n", "Total download bytes", StringBu ffer_toString(Util_printRule(false, buf, o->action, "if %s %s in last %d %s(s)", operatornames[o->operator], Convert_bytes2str(o->limit, buffer), o->rangecount, Util_timestr(o->range))));
} }
} }
for (Bandwidth_T o = s->downloadpacketslist; o; o = o->next) { for (Bandwidth_T o = s->downloadpacketslist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->range == Time_Second) { if (o->range == Time_Second) {
printf(" %-20s = %s\n", "Download packets", StringBuffer _toString(Util_printRule(buf, o->action, "if %s %lld packets/s", operatornames[o ->operator], o->limit))); printf(" %-20s = %s\n", "Download packets", StringBuffer _toString(Util_printRule(false, buf, o->action, "if %s %lld packets/s", operator names[o->operator], o->limit)));
} else { } else {
printf(" %-20s = %s\n", "Total downl. packets", StringBu ffer_toString(Util_printRule(buf, o->action, "if %s %lld packets in last %d %s(s )", operatornames[o->operator], o->limit, o->rangecount, Util_timestr(o->range)) )); printf(" %-20s = %s\n", "Total downl. packets", StringBu ffer_toString(Util_printRule(false, buf, o->action, "if %s %lld packets in last %d %s(s)", operatornames[o->operator], o->limit, o->rangecount, Util_timestr(o-> range))));
} }
} }
for (Uptime_T o = s->uptimelist; o; o = o->next) { for (Uptime_T o = s->uptimelist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Uptime", StringBuffer_toString(Util_pri ntRule(buf, o->action, "if %s %llu second(s)", operatornames[o->operator], o->up time))); printf(" %-20s = %s\n", "Uptime", StringBuffer_toString(Util_pri ntRule(false, buf, o->action, "if %s %llu second(s)", operatornames[o->operator] , o->uptime)));
} }
if (s->type != Service_Process) { if (s->type != Service_Process) {
for (Match_T o = s->matchignorelist; o; o = o->next) { for (Match_T o = s->matchignorelist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Ignore content", StringBuffer_t oString(Util_printRule(buf, o->action, "if content %s \"%s\"", o->not ? "!=" : " =", o->match_string))); printf(" %-20s = %s\n", "Ignore content", StringBuffer_t oString(Util_printRule(false, buf, o->action, "if content %s \"%s\"", o->not ? " !=" : "=", o->match_string)));
} }
for (Match_T o = s->matchlist; o; o = o->next) { for (Match_T o = s->matchlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
printf(" %-20s = %s\n", "Content", StringBuffer_toString (Util_printRule(buf, o->action, "if content %s \"%s\"", o->not ? "!=" : "=", o-> match_string))); printf(" %-20s = %s\n", "Content", StringBuffer_toString (Util_printRule(false, buf, o->action, "if content %s \"%s\"", o->not ? "!=" : " =", o->match_string)));
} }
} }
for (FileSystem_T o = s->filesystemlist; o; o = o->next) { for (FileSystem_T o = s->filesystemlist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
if (o->resource == Resource_Inode) { if (o->resource == Resource_Inode) {
printf(" %-20s = %s\n", "Inodes usage limit", printf(" %-20s = %s\n", "Inodes usage limit",
o->limit_absolute > -1 o->limit_absolute > -1
? ?
StringBuffer_toString(Util_printRule(buf, o->acti on, "if %s %lld", operatornames[o->operator], o->limit_absolute)) StringBuffer_toString(Util_printRule(false, buf, o->action, "if %s %lld", operatornames[o->operator], o->limit_absolute))
: :
StringBuffer_toString(Util_printRule(buf, o->acti on, "if %s %.1f%%", operatornames[o->operator], o->limit_percent)) StringBuffer_toString(Util_printRule(false, buf, o->action, "if %s %.1f%%", operatornames[o->operator], o->limit_percent))
); );
} else if (o->resource == Resource_InodeFree) { } else if (o->resource == Resource_InodeFree) {
printf(" %-20s = %s\n", "Inodes free limit", printf(" %-20s = %s\n", "Inodes free limit",
o->limit_absolute > -1 o->limit_absolute > -1
? ?
StringBuffer_toString(Util_printRule(buf, o->acti on, "if %s %lld", operatornames[o->operator], o->limit_absolute)) StringBuffer_toString(Util_printRule(false, buf, o->action, "if %s %lld", operatornames[o->operator], o->limit_absolute))
: :
StringBuffer_toString(Util_printRule(buf, o->acti on, "if %s %.1f%%", operatornames[o->operator], o->limit_percent)) StringBuffer_toString(Util_printRule(false, buf, o->action, "if %s %.1f%%", operatornames[o->operator], o->limit_percent))
); );
} else if (o->resource == Resource_Space) { } else if (o->resource == Resource_Space) {
if (o->limit_absolute > -1) { if (o->limit_absolute > -1) {
printf(" %-20s = %s\n", "Space usage limit", Str ingBuffer_toString(Util_printRule(buf, o->action, "if %s %s", operatornames[o->o perator], Convert_bytes2str(o->limit_absolute, buffer)))); printf(" %-20s = %s\n", "Space usage limit", Str ingBuffer_toString(Util_printRule(false, buf, o->action, "if %s %s", operatornam es[o->operator], Convert_bytes2str(o->limit_absolute, buffer))));
} else { } else {
printf(" %-20s = %s\n", "Space usage limit", Stri ngBuffer_toString(Util_printRule(buf, o->action, "if %s %.1f%%", operatornames[o ->operator], o->limit_percent))); printf(" %-20s = %s\n", "Space usage limit", Stri ngBuffer_toString(Util_printRule(false, buf, o->action, "if %s %.1f%%", operator names[o->operator], o->limit_percent)));
} }
} else if (o->resource == Resource_SpaceFree) { } else if (o->resource == Resource_SpaceFree) {
if (o->limit_absolute > -1) { if (o->limit_absolute > -1) {
printf(" %-20s = %s\n", "Space free limit", Stri ngBuffer_toString(Util_printRule(buf, o->action, "if %s %s", operatornames[o->op erator], Convert_bytes2str(o->limit_absolute, buffer)))); printf(" %-20s = %s\n", "Space free limit", Stri ngBuffer_toString(Util_printRule(false, buf, o->action, "if %s %s", operatorname s[o->operator], Convert_bytes2str(o->limit_absolute, buffer))));
} else { } else {
printf(" %-20s = %s\n", "Space free limit", Strin gBuffer_toString(Util_printRule(buf, o->action, "if %s %.1f%%", operatornames[o- >operator], o->limit_percent))); printf(" %-20s = %s\n", "Space free limit", Strin gBuffer_toString(Util_printRule(false, buf, o->action, "if %s %.1f%%", operatorn ames[o->operator], o->limit_percent)));
} }
} else if (o->resource == Resource_ReadBytes) { } else if (o->resource == Resource_ReadBytes) {
printf(" %-20s = %s\n", "Read limit", StringBuffer_toStr ing(Util_printRule(buf, o->action, "if read %s %s/s", operatornames[o->operator] , Convert_bytes2str(o->limit_absolute, (char[10]){})))); printf(" %-20s = %s\n", "Read limit", StringBuffer_toStr ing(Util_printRule(false, buf, o->action, "if read %s %s/s", operatornames[o->op erator], Convert_bytes2str(o->limit_absolute, (char[10]){}))));
} else if (o->resource == Resource_ReadOperations) { } else if (o->resource == Resource_ReadOperations) {
printf(" %-20s = %s\n", "Read limit", StringBuffer_toStr ing(Util_printRule(buf, o->action, "if read %s %llu operations/s", operatornames [o->operator], o->limit_absolute))); printf(" %-20s = %s\n", "Read limit", StringBuffer_toStr ing(Util_printRule(false, buf, o->action, "if read %s %llu operations/s", operat ornames[o->operator], o->limit_absolute)));
} else if (o->resource == Resource_WriteBytes) { } else if (o->resource == Resource_WriteBytes) {
printf(" %-20s = %s\n", "Write limit", StringBuffer_toSt ring(Util_printRule(buf, o->action, "if write %s %s/s", operatornames[o->operato r], Convert_bytes2str(o->limit_absolute, (char[10]){})))); printf(" %-20s = %s\n", "Write limit", StringBuffer_toSt ring(Util_printRule(false, buf, o->action, "if write %s %s/s", operatornames[o-> operator], Convert_bytes2str(o->limit_absolute, (char[10]){}))));
} else if (o->resource == Resource_WriteOperations) { } else if (o->resource == Resource_WriteOperations) {
printf(" %-20s = %s\n", "Write limit", StringBuffer_toSt ring(Util_printRule(buf, o->action, "if write %s %llu operations/s", operatornam es[o->operator], o->limit_absolute))); printf(" %-20s = %s\n", "Write limit", StringBuffer_toSt ring(Util_printRule(false, buf, o->action, "if write %s %llu operations/s", oper atornames[o->operator], o->limit_absolute)));
} else if (o->resource == Resource_ServiceTime) { } else if (o->resource == Resource_ServiceTime) {
printf(" %-20s = %s\n", "Service time limit", StringBuff er_toString(Util_printRule(buf, o->action, "if service time %s %s/operation", op eratornames[o->operator], Convert_time2str(o->limit_absolute, (char[11]){})))); printf(" %-20s = %s\n", "Service time limit", StringBuff er_toString(Util_printRule(false, buf, o->action, "if service time %s %s/operati on", operatornames[o->operator], Convert_time2str(o->limit_absolute, (char[11]){ }))));
} }
} }
for (Resource_T o = s->resourcelist; o; o = o->next) { for (Resource_T o = s->resourcelist; o; o = o->next) {
StringBuffer_clear(buf); StringBuffer_clear(buf);
switch (o->resource_id) { switch (o->resource_id) {
case Resource_CpuPercent: case Resource_CpuPercent:
printf(" %-20s = ", "CPU usage limit"); printf(" %-20s = ", "CPU usage limit");
break; break;
skipping to change at line 1219 skipping to change at line 1229
case Resource_CpuSystem: case Resource_CpuSystem:
case Resource_CpuWait: case Resource_CpuWait:
case Resource_CpuNice: case Resource_CpuNice:
case Resource_CpuHardIRQ: case Resource_CpuHardIRQ:
case Resource_CpuSoftIRQ: case Resource_CpuSoftIRQ:
case Resource_CpuSteal: case Resource_CpuSteal:
case Resource_CpuGuest: case Resource_CpuGuest:
case Resource_CpuGuestNice: case Resource_CpuGuestNice:
case Resource_MemoryPercent: case Resource_MemoryPercent:
case Resource_SwapPercent: case Resource_SwapPercent:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %.1f%%", operatornames[o->operator], o->limit))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %.1f%%", operatornames[o->operator], o->limit))) ;
break; break;
case Resource_MemoryKbyte: case Resource_MemoryKbyte:
case Resource_SwapKbyte: case Resource_SwapKbyte:
case Resource_MemoryKbyteTotal: case Resource_MemoryKbyteTotal:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %s", operatornames[o->operator], Convert_bytes2str(o->l imit, buffer)))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %s", operatornames[o->operator], Convert_bytes2s tr(o->limit, buffer))));
break; break;
case Resource_LoadAverage1m: case Resource_LoadAverage1m:
case Resource_LoadAverage5m: case Resource_LoadAverage5m:
case Resource_LoadAverage15m: case Resource_LoadAverage15m:
case Resource_LoadAveragePerCore1m: case Resource_LoadAveragePerCore1m:
case Resource_LoadAveragePerCore5m: case Resource_LoadAveragePerCore5m:
case Resource_LoadAveragePerCore15m: case Resource_LoadAveragePerCore15m:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %.1f", operatornames[o->operator], o->limit))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %.1f", operatornames[o->operator], o->limit)));
break; break;
case Resource_Threads: case Resource_Threads:
case Resource_Children: case Resource_Children:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %.0f", operatornames[o->operator], o->limit))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %.0f", operatornames[o->operator], o->limit)));
break; break;
case Resource_ReadBytes: case Resource_ReadBytes:
case Resource_WriteBytes: case Resource_WriteBytes:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %s/s", operatornames[o->operator], Convert_bytes2str(o- >limit, (char[10]){})))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %s/s", operatornames[o->operator], Convert_bytes 2str(o->limit, (char[10]){}))));
break; break;
case Resource_ReadBytesPhysical: case Resource_ReadBytesPhysical:
case Resource_WriteBytesPhysical: case Resource_WriteBytesPhysical:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %s/s", operatornames[o->operator], Convert_bytes2str(o- >limit, (char[10]){})))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %s/s", operatornames[o->operator], Convert_bytes 2str(o->limit, (char[10]){}))));
break; break;
case Resource_ReadOperations: case Resource_ReadOperations:
case Resource_WriteOperations: case Resource_WriteOperations:
printf("%s", StringBuffer_toString(Util_printRul e(buf, o->action, "if %s %.0f operations/s", operatornames[o->operator], o->limi t))); printf("%s", StringBuffer_toString(Util_printRul e(false, buf, o->action, "if %s %.0f operations/s", operatornames[o->operator], o->limit)));
break; break;
default: default:
break; break;
} }
printf("\n"); printf("\n");
} }
if (s->every.type == Every_SkipCycles) if (s->every.type == Every_SkipCycles)
printf(" %-20s = Check service every %d cycles\n", "Every", s->e very.spec.cycle.number); printf(" %-20s = Check service every %d cycles\n", "Every", s->e very.spec.cycle.number);
skipping to change at line 1786 skipping to change at line 1796
StringBuffer_T Util_printEventratio(Action_T action, StringBuffer_T buf) { StringBuffer_T Util_printEventratio(Action_T action, StringBuffer_T buf) {
if (action->cycles > 1) { if (action->cycles > 1) {
if (action->count == action->cycles) if (action->count == action->cycles)
StringBuffer_append(buf, "for %d cycles ", action->cycle s); StringBuffer_append(buf, "for %d cycles ", action->cycle s);
else else
StringBuffer_append(buf, "for %d times within %d cycles ", action->count, action->cycles); StringBuffer_append(buf, "for %d times within %d cycles ", action->count, action->cycles);
} }
return buf; return buf;
} }
StringBuffer_T Util_printRule(StringBuffer_T buf, EventAction_T action, const ch ar *rule, ...) { StringBuffer_T Util_printRule(bool inverse, StringBuffer_T buf, EventAction_T ac tion, const char *rule, ...) {
ASSERT(buf); ASSERT(buf);
ASSERT(action); ASSERT(action);
ASSERT(rule); ASSERT(rule);
// Variable part // Variable part
va_list ap; va_list ap;
va_start(ap, rule); va_start(ap, rule);
StringBuffer_vappend(buf, rule, ap); StringBuffer_vappend(buf, rule, ap);
va_end(ap); va_end(ap);
// Constant part (failure action) // Constant part (failure action)
StringBuffer_append(buf, " "); StringBuffer_append(buf, " ");
Util_printEventratio(action->failed, buf); Util_printEventratio(action->failed, buf);
StringBuffer_append(buf, "then "); StringBuffer_append(buf, "then ");
Util_printAction(action->failed, buf); Util_printAction(action->failed, buf);
// Print the success part only if it's non default action (alert is impl icit => skipped for simpler output) // Print the success part only if it's non default action (alert is impl icit => skipped for simpler output)
if (action->succeeded->id != Action_Ignored && action->succeeded->id != Action_Alert) { if (action->succeeded->id != Action_Ignored && action->succeeded->id != Action_Alert) {
StringBuffer_append(buf, " else if succeeded "); StringBuffer_append(buf, " else if ");
StringBuffer_append(buf, inverse ? "failed " : "succeeded ");
Util_printEventratio(action->succeeded, buf); Util_printEventratio(action->succeeded, buf);
StringBuffer_append(buf, "then "); StringBuffer_append(buf, "then ");
Util_printAction(action->succeeded, buf); Util_printAction(action->succeeded, buf);
} }
return buf; return buf;
} }
const char *Util_portIpDescription(Port_T p) { const char *Util_portIpDescription(Port_T p) {
switch (p->family) { switch (p->family) {
case Socket_Ip: case Socket_Ip:
 End of changes. 69 change blocks. 
81 lines changed or deleted 98 lines changed or added

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