@cryptotaxi247 / netdata-1 / commits / 4cd6b1a6a

properly handle interactions between CLEAR, WARNING, CRITICAL

Costa Tsaousis committed Aug 18, 2016 at 02:04 UTC 4cd6b1a6a78eb872906deb7a776cffff03298719
1 file changed +26 -4
src/health.c
+26 -4
@@ -1733,6 +1733,7 @@ void *health_main(void *ptr) {
1733 buffer_tostring(rc->warning->error_msg),
1734 rc->source
1735 );
1736 +
1737 warning_status = rrdcalc_value2status(rc->warning->result);
1738 }
1739 }
@@ -1769,11 +1770,32 @@ void *health_main(void *ptr) {
1770
1771 int status = RRDCALC_STATUS_UNDEFINED;
1772
1772 - if(warning_status == RRDCALC_STATUS_RAISED)
1773 - status = RRDCALC_STATUS_WARNING;
1773 + switch(warning_status) {
1774 + case RRDCALC_STATUS_CLEAR:
1775 + status = RRDCALC_STATUS_CLEAR;
1776 + break;
1777 +
1778 + case RRDCALC_STATUS_RAISED:
1779 + status = RRDCALC_STATUS_WARNING;
1780 + break;
1781 +
1782 + default:
1783 + break;
1784 + }
1785
1775 - if(critical_status == RRDCALC_STATUS_RAISED)
1776 - status = RRDCALC_STATUS_CRITICAL;
1786 + switch(critical_status) {
1787 + case RRDCALC_STATUS_CLEAR:
1788 + if(status == RRDCALC_STATUS_UNDEFINED)
1789 + status = RRDCALC_STATUS_CLEAR;
1790 + break;
1791 +
1792 + case RRDCALC_STATUS_RAISED:
1793 + status = RRDCALC_STATUS_CRITICAL;
1794 + break;
1795 +
1796 + default:
1797 + break;
1798 + }
1799
1800 if(status != rc->status) {
1801 health_alarm_log(time(NULL), rc->name, rc->rrdset->id, rc->exec, now - rc->last_status_change, rc->old_value, rc->value, rc->status, status, rc->source);