@cryptotaxi247 / netdata-1 / commits / 52afab175

daemon status 24c (#20003)

* keep the highest cloud status * keep the interesting statuses to depict cloud connectivity * more control * make fault address 0x0 appear only when we have a signal, to make it easy spot null pointers in signals

Costa Tsaousis committed Mar 31, 2025 at 15:05 UTC 52afab175197dcf959ac8fc6d055231e24d45948
1 file changed +20 -3
src/daemon/status-file.c
+20 -3
@@ -228,7 +228,12 @@ static void daemon_status_file_to_json(BUFFER *wb, DAEMON_STATUS_FILE *ds) {
228
229 if(ds->v >= 18) {
230 char buf[UINT64_HEX_MAX_LENGTH];
231 - print_uint64_hex(buf, ds->fatal.fault_address);
231 +
232 + if(ds->fatal.signal_code)
233 + print_uint64_hex(buf, ds->fatal.fault_address);
234 + else
235 + buf[0] = '\0';
236 +
237 buffer_json_member_add_string(wb, "fault_address", buf);
238 }
239
@@ -412,7 +417,10 @@ static bool daemon_status_file_from_json(json_object *jobj, void *data, BUFFER *
417
418 char buf[UINT64_HEX_MAX_LENGTH];
419 JSONC_PARSE_TXT2CHAR_OR_ERROR_AND_RETURN(jobj, path, "fault_address", buf, error, required_v18);
415 - ds->fatal.fault_address = str2ull_encoded(buf);
420 + if(buf[0])
421 + ds->fatal.fault_address = str2ull_encoded(buf);
422 + else
423 + ds->fatal.fault_address = 0;
424 }
425
426 if(version >= 23)
@@ -536,7 +544,16 @@ static void daemon_status_file_refresh(DAEMON_STATUS status) {
544 session_status.invocation = nd_log_get_invocation_id();
545 session_status.db_mode = default_rrd_memory_mode;
546 session_status.db_tiers = nd_profile.storage_tiers;
539 - session_status.cloud_status = cloud_status();
547 +
548 + // we keep the highest cloud status, to know how the agent gets connected to netdata.cloud
549 + CLOUD_STATUS cs = cloud_status();
550 + if(!session_status.cloud_status || // it is ok to overwrite this
551 + session_status.cloud_status == CLOUD_STATUS_AVAILABLE || // it is ok to overwrite this
552 + session_status.cloud_status == CLOUD_STATUS_OFFLINE || // it is ok to overwrite this
553 + cs == CLOUD_STATUS_BANNED || // this is a final state
554 + cs == CLOUD_STATUS_ONLINE || // this is a final state
555 + cs == CLOUD_STATUS_INDIRECT) // this is a final state
556 + session_status.cloud_status = cs;
557
558 session_status.oom_protection = dbengine_out_of_memory_protection;
559 session_status.netdata_max_rss = process_max_rss();