ce->last_time = vl->time;
ce->last_update = cdtime();
ce->interval = vl->interval;
- ce->state = STATE_OKAY;
+ ce->state = STATE_UNKNOWN;
if (c_avl_insert(cache_tree, key_copy, ce) != 0) {
sfree(key_copy);
/* If the state didn't change, report if `persistent' is specified. If the
* state is `okay', then only report if `persist_ok` flag is set. */
if (state == state_old) {
- if ((th->flags & UT_FLAG_PERSIST) == 0)
+ if (state == STATE_UNKNOWN) {
+ /* From UNKNOWN to UNKNOWN. Persist doesn't apply here. */
+ return 0;
+ } else if ((th->flags & UT_FLAG_PERSIST) == 0)
return 0;
else if ((state == STATE_OKAY) && ((th->flags & UT_FLAG_PERSIST_OK) == 0))
return 0;
snprintf(buf, bufsize, ": All data sources are within range again. "
"Current value of \"%s\" is %f.",
ds->ds[ds_index].name, values[ds_index]);
+ } else if (state == STATE_UNKNOWN) {
+ ERROR("ut_report_state: metric transition to UNKNOWN from a different "
+ "state. This shouldn't happen.");
+ return 0;
} else {
double min;
double max;
if (ds != NULL) {
ds_name = ds->ds[ds_index].name;
if ((th->data_source[0] != 0) && (strcmp(ds_name, th->data_source) != 0))
- return STATE_OKAY;
+ return STATE_UNKNOWN;
}
if ((th->flags & UT_FLAG_INVERT) != 0) {
case STATE_WARNING:
hysteresis_for_warning = th->hysteresis;
break;
+ case STATE_UNKNOWN:
case STATE_OKAY:
/* do nothing -- the hysteresis only applies to the non-normal states */
break;
*
* Checks all data sources of a value list against the given threshold, using
* the ut_check_one_data_source function above. Returns the worst status,
- * which is `okay' if nothing has failed.
+ * which is `okay' if nothing has failed or `unknown' if no valid datasource was
+ * defined.
* Returns less than zero if the data set doesn't have any data sources.
*/
static int ut_check_one_threshold(const data_set_t *ds, const value_list_t *vl,
if (ds != NULL) {
ds_name = ds->ds[ds_index].name;
if ((th->data_source[0] != 0) && (strcmp(ds_name, th->data_source) != 0))
- return STATE_OKAY;
+ return STATE_UNKNOWN;
}
if ((th->flags & UT_FLAG_INVERT) != 0) {
/* XXX: This is an experimental code, not optimized, not fast, not reliable,
* and probably, do not work as you expect. Enjoy! :D */
- if ((th->hysteresis > 0) &&
- ((prev_state = uc_get_state(ds, vl)) != STATE_OKAY)) {
+ prev_state = uc_get_state(ds, vl);
+ if ((th->hysteresis > 0) && (prev_state != STATE_OKAY) &&
+ (prev_state != STATE_UNKNOWN)) {
switch (prev_state) {
case STATE_ERROR:
if ((!isnan(th->failure_min) &&