@cryptotaxi247 / netdata-1 / commits / 7805aad17

delay max should by default be max(up * multiplier, down * multiplier)

Costa Tsaousis (ktsaou) committed Sep 14, 2016 at 20:53 UTC 7805aad17c55629710842c5cea75e90bbb44e860
1 file changed +26
src/health.c
+26
@@ -1086,6 +1086,11 @@ static inline int health_parse_delay(
1086 int *delay_max_duration,
1087 float *delay_multiplier) {
1088
1089 + char given_up = 0;
1090 + char given_down = 0;
1091 + char given_max = 0;
1092 + char given_multiplier = 0;
1093 +
1094 char *s = string;
1095 while(*s) {
1096 char *key = s;
@@ -1104,12 +1109,14 @@ static inline int health_parse_delay(
1109 error("Health configuration at line %zu of file '%s/%s': invalid value '%s' for '%s' keyword",
1110 line, path, file, value, key);
1111 }
1112 + else given_up = 1;
1113 }
1114 else if(!strcasecmp(key, "down")) {
1115 if (!health_parse_duration(value, delay_down_duration)) {
1116 error("Health configuration at line %zu of file '%s/%s': invalid value '%s' for '%s' keyword",
1117 line, path, file, value, key);
1118 }
1119 + else given_down = 1;
1120 }
1121 else if(!strcasecmp(key, "multiplier")) {
1122 *delay_multiplier = strtof(value, NULL);
@@ -1117,12 +1124,14 @@ static inline int health_parse_delay(
1124 error("Health configuration at line %zu of file '%s/%s': invalid value '%s' for '%s' keyword",
1125 line, path, file, value, key);
1126 }
1127 + else given_multiplier = 1;
1128 }
1129 else if(!strcasecmp(key, "max")) {
1130 if (!health_parse_duration(value, delay_max_duration)) {
1131 error("Health configuration at line %zu of file '%s/%s': invalid value '%s' for '%s' keyword",
1132 line, path, file, value, key);
1133 }
1134 + else given_max = 1;
1135 }
1136 else {
1137 error("Health configuration at line %zu of file '%s/%s': unknown keyword '%s'",
@@ -1130,6 +1139,23 @@ static inline int health_parse_delay(
1139 }
1140 }
1141
1142 + if(!given_up)
1143 + *delay_up_duration = 0;
1144 +
1145 + if(!given_down)
1146 + *delay_down_duration = 0;
1147 +
1148 + if(!given_multiplier)
1149 + *delay_multiplier = 1.0;
1150 +
1151 + if(!given_max) {
1152 + if((*delay_max_duration) < (*delay_up_duration) * (*delay_multiplier))
1153 + *delay_max_duration = (*delay_up_duration) * (*delay_multiplier);
1154 +
1155 + if((*delay_max_duration) < (*delay_down_duration) * (*delay_multiplier))
1156 + *delay_max_duration = (*delay_down_duration) * (*delay_multiplier);
1157 + }
1158 +
1159 return 1;
1160 }
1161