improved descriptions of exit reasons (#19730)
Costa Tsaousis committed
Feb 28, 2025 at 08:50 UTC
0244b18608758a75cd15913a4c7a7c58f12927f5
2 files changed
+36
-31
src/daemon/daemon-status-file.c
+35
-31
@@ -9,7 +9,7 @@
9
#include <openssl/pem.h>
10
#include <openssl/err.h>
11
12
-#define STATUS_FILE_VERSION 4
12
+#define STATUS_FILE_VERSION 5
13
14
#define STATUS_FILENAME "status-netdata.json"
15
@@ -741,13 +741,14 @@ void daemon_status_file_check_crash(void) {
741
case DAEMON_STATUS_EXITED:
742
if(last_session_status.exit_reason == EXIT_REASON_NONE) {
743
cause = "exit no reason";
744
- msg = "Netdata was last stopped gracefully (no exit reason set)";
744
+ msg = "Netdata was last stopped gracefully, without setting a reason";
745
if(!last_session_status.timestamp_ut)
746
dump_json = false;
747
}
748
- else if(!is_exit_reason_normal(last_session_status.exit_reason)) {
749
- cause = "exit on fatal";
750
- msg = "Netdata was last stopped gracefully (encountered an error)";
748
+ else if(last_session_status.exit_reason != EXIT_REASON_NONE &&
749
+ !is_exit_reason_normal(last_session_status.exit_reason)) {
750
+ cause = "fatal and exit";
751
+ msg = "Netdata was last stopped gracefully after it encountered a fatal error";
752
pri = PRI_NETDATA_BUG;
753
post_crash_report = true;
754
}
@@ -766,12 +767,25 @@ void daemon_status_file_check_crash(void) {
767
}
768
else {
769
cause = "exit instructed";
769
- msg = "Netdata was last stopped gracefully (instructed to do so)";
770
+ msg = "Netdata was last stopped gracefully";
771
}
772
break;
773
774
case DAEMON_STATUS_INITIALIZING:
774
- if (OS_SYSTEM_DISK_SPACE_OK(last_session_status.var_cache) &&
775
+ if (last_session_status.exit_reason == EXIT_REASON_NONE &&
776
+ !UUIDiszero(session_status.boot_id) &&
777
+ !UUIDiszero(last_session_status.boot_id) &&
778
+ !os_boot_ids_match(session_status.boot_id, last_session_status.boot_id)) {
779
+ cause = "abnormal power off";
780
+ msg = "The system was abnormally powered off while Netdata was starting";
781
+ pri = PRI_USER_SHOULD_FIX;
782
+ }
783
+ else if (last_session_status.exit_reason & EXIT_REASON_OUT_OF_MEMORY) {
784
+ cause = "out of memory";
785
+ msg = "Netdata was last crashed while starting, because it couldn't allocate memory";
786
+ pri = PRI_USER_SHOULD_FIX;
787
+ }
788
+ else if (OS_SYSTEM_DISK_SPACE_OK(last_session_status.var_cache) &&
789
last_session_status.var_cache.is_read_only) {
790
cause = "disk read-only";
791
msg = "Netdata couldn't start because the disk is readonly";
@@ -784,31 +798,19 @@ void daemon_status_file_check_crash(void) {
798
pri = PRI_USER_SHOULD_FIX;
799
}
800
else if (OS_SYSTEM_DISK_SPACE_OK(last_session_status.var_cache) &&
787
- last_session_status.var_cache.free_bytes < 1 * 1024 * 1024) {
801
+ last_session_status.var_cache.free_bytes < 10 * 1024 * 1024) {
802
cause = "disk almost full";
803
msg = "Netdata couldn't start while the disk is almost full";
804
pri = PRI_USER_SHOULD_FIX;
805
}
792
- else if (last_session_status.exit_reason == EXIT_REASON_NONE &&
793
- !UUIDiszero(session_status.boot_id) &&
794
- !UUIDiszero(last_session_status.boot_id) &&
795
- !UUIDeq(session_status.boot_id, last_session_status.boot_id)) {
796
- cause = "abnormal power off";
797
- msg = "The system was abnormally powered off while Netdata was starting";
798
- pri = PRI_USER_SHOULD_FIX;
799
- }
800
- else if (last_session_status.exit_reason & EXIT_REASON_OUT_OF_MEMORY) {
801
- cause = "out of memory";
802
- msg = "Netdata was last crashed while starting, because it couldn't allocate memory";
803
- pri = PRI_USER_SHOULD_FIX;
804
- }
805
- else if (!is_exit_reason_normal(last_session_status.exit_reason)) {
806
+ else if (last_session_status.exit_reason != EXIT_REASON_NONE &&
807
+ !is_exit_reason_normal(last_session_status.exit_reason)) {
808
cause = "fatal on start";
809
msg = "Netdata was last crashed while starting, because of a fatal error";
810
pri = PRI_NETDATA_BUG;
811
}
812
else {
811
- cause = "crashed on start";
813
+ cause = "killed hard on start";
814
msg = "Netdata was last killed/crashed while starting";
815
pri = PRI_BAD_BUT_NO_REASON;
816
}
@@ -817,21 +819,22 @@ void daemon_status_file_check_crash(void) {
819
break;
820
821
case DAEMON_STATUS_EXITING:
820
- if(!is_exit_reason_normal(last_session_status.exit_reason)) {
821
- cause = "crashed on fatal";
822
+ if(last_session_status.exit_reason != EXIT_REASON_NONE &&
823
+ !is_exit_reason_normal(last_session_status.exit_reason)) {
824
+ cause = "fatal on exit";
825
msg = "Netdata was last killed/crashed while exiting after encountering an error";
826
}
827
else if(last_session_status.exit_reason & EXIT_REASON_SYSTEM_SHUTDOWN) {
825
- cause = "crashed on system shutdown";
828
+ cause = "killed hard on shutdown";
829
msg = "Netdata was last killed/crashed while exiting due to system shutdown";
830
}
831
else if(new_version || (last_session_status.exit_reason & EXIT_REASON_UPDATE)) {
829
- cause = "crashed on update";
832
+ cause = "killed hard on update";
833
msg = "Netdata was last killed/crashed while exiting to update to a new version";
834
}
835
else {
833
- cause = "crashed on exit";
834
- msg = "Netdata was last killed/crashed while exiting (instructed to do so)";
836
+ cause = "killed hard on exit";
837
+ msg = "Netdata was last killed/crashed while it was instructed to exit";
838
}
839
pri = PRI_NETDATA_BUG;
840
post_crash_report = true;
@@ -841,7 +844,7 @@ void daemon_status_file_check_crash(void) {
844
if (last_session_status.exit_reason == EXIT_REASON_NONE &&
845
!UUIDiszero(session_status.boot_id) &&
846
!UUIDiszero(last_session_status.boot_id) &&
844
- !UUIDeq(session_status.boot_id, last_session_status.boot_id)) {
847
+ !os_boot_ids_match(session_status.boot_id, last_session_status.boot_id)) {
848
cause = "abnormal power off";
849
msg = "The system was abnormally powered off while Netdata was running";
850
pri = PRI_USER_SHOULD_FIX;
@@ -851,7 +854,8 @@ void daemon_status_file_check_crash(void) {
854
msg = "Netdata was last crashed because it couldn't allocate memory";
855
pri = PRI_USER_SHOULD_FIX;
856
}
854
- else if (!is_exit_reason_normal(last_session_status.exit_reason)) {
857
+ else if (last_session_status.exit_reason != EXIT_REASON_NONE &&
858
+ !is_exit_reason_normal(last_session_status.exit_reason)) {
859
cause = "killed fatal";
860
msg = "Netdata was last crashed due to a fatal error";
861
pri = PRI_NETDATA_BUG;
src/libnetdata/exit/exit_initiated.c
+1
@@ -18,6 +18,7 @@ ENUM_STR_MAP_DEFINE(EXIT_REASON) = {
18
{ EXIT_REASON_SYSTEM_SHUTDOWN, "system-shutdown"},
19
{ EXIT_REASON_SERVICE_STOP, "service-stop"},
20
{ EXIT_REASON_UPDATE, "update"},
21
+ { EXIT_REASON_OUT_OF_MEMORY, "out-of-memory"},
22
23
// terminator
24
{0, NULL},