mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
core: make log messages about unit processes exiting recognizable
This commit is contained in:
parent
7c047d7443
commit
91bbd9b796
|
@ -359,6 +359,15 @@ Support: %SUPPORT_URL%
|
||||||
|
|
||||||
The unit @UNIT@ has entered the 'failed' state with result '@UNIT_RESULT@'.
|
The unit @UNIT@ has entered the 'failed' state with result '@UNIT_RESULT@'.
|
||||||
|
|
||||||
|
-- 98e322203f7a4ed290d09fe03c09fe15
|
||||||
|
Subject: Unit process exited
|
||||||
|
Defined-By: systemd
|
||||||
|
Support: %SUPPORT_URL%
|
||||||
|
|
||||||
|
An @COMMAND@= process belonging to unit @UNIT@ has exited.
|
||||||
|
|
||||||
|
The process' exit code is '@EXIT_CODE@' and its exit status is @EXIT_STATUS@.
|
||||||
|
|
||||||
-- 50876a9db00f4c40bde1a2ad381c3a1b
|
-- 50876a9db00f4c40bde1a2ad381c3a1b
|
||||||
Subject: The system is configured in a way that might cause problems
|
Subject: The system is configured in a way that might cause problems
|
||||||
Defined-By: systemd
|
Defined-By: systemd
|
||||||
|
|
|
@ -1270,8 +1270,11 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||||
m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
|
m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_unit_full(u, f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE, 0,
|
unit_log_process_exit(
|
||||||
"Mount process exited, code=%s status=%i", sigchld_code_to_string(code), status);
|
u, f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
|
||||||
|
"Mount process",
|
||||||
|
mount_exec_command_to_string(m->control_command_id),
|
||||||
|
code, status);
|
||||||
|
|
||||||
/* Note that due to the io event priority logic, we can be sure the new mountinfo is loaded
|
/* Note that due to the io event priority logic, we can be sure the new mountinfo is loaded
|
||||||
* before we process the SIGCHLD for the mount command. */
|
* before we process the SIGCHLD for the mount command. */
|
||||||
|
|
|
@ -3233,21 +3233,13 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||||
|
|
||||||
/* When this is a successful exit, let's log about the exit code on DEBUG level. If this is a failure
|
/* When this is a successful exit, let's log about the exit code on DEBUG level. If this is a failure
|
||||||
* and the process exited on its own via exit(), then let's make this a NOTICE, under the assumption
|
* and the process exited on its own via exit(), then let's make this a NOTICE, under the assumption
|
||||||
* that the service already logged the reason at a higher log level on its own. However, if the service
|
* that the service already logged the reason at a higher log level on its own. (Internally,
|
||||||
* died due to a signal, then it most likely didn't say anything about any reason, hence let's raise
|
* unit_log_process_exit() will possibly bump this to WARNING if the service died due to a signal.) */
|
||||||
* our log level to WARNING then. */
|
unit_log_process_exit(
|
||||||
|
u, f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
|
||||||
log_struct(f == SERVICE_SUCCESS ? LOG_DEBUG :
|
"Main process",
|
||||||
(code == CLD_EXITED ? LOG_NOTICE : LOG_WARNING),
|
service_exec_command_to_string(SERVICE_EXEC_START),
|
||||||
LOG_UNIT_MESSAGE(u, "Main process exited, code=%s, status=%i/%s",
|
code, status);
|
||||||
sigchld_code_to_string(code), status,
|
|
||||||
strna(code == CLD_EXITED
|
|
||||||
? exit_status_to_string(status, EXIT_STATUS_FULL)
|
|
||||||
: signal_to_string(status))),
|
|
||||||
"EXIT_CODE=%s", sigchld_code_to_string(code),
|
|
||||||
"EXIT_STATUS=%i", status,
|
|
||||||
LOG_UNIT_ID(u),
|
|
||||||
LOG_UNIT_INVOCATION_ID(u));
|
|
||||||
|
|
||||||
if (s->result == SERVICE_SUCCESS)
|
if (s->result == SERVICE_SUCCESS)
|
||||||
s->result = f;
|
s->result = f;
|
||||||
|
@ -3336,9 +3328,11 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||||
f = SERVICE_SUCCESS;
|
f = SERVICE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_unit_full(u, f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, 0,
|
unit_log_process_exit(
|
||||||
"Control process exited, code=%s status=%i",
|
u, f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
|
||||||
sigchld_code_to_string(code), status);
|
"Control process",
|
||||||
|
service_exec_command_to_string(s->control_command_id),
|
||||||
|
code, status);
|
||||||
|
|
||||||
if (s->result == SERVICE_SUCCESS)
|
if (s->result == SERVICE_SUCCESS)
|
||||||
s->result = f;
|
s->result = f;
|
||||||
|
|
|
@ -2968,9 +2968,11 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||||
f = SOCKET_SUCCESS;
|
f = SOCKET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_unit_full(u, f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE, 0,
|
unit_log_process_exit(
|
||||||
"Control process exited, code=%s status=%i",
|
u, f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
|
||||||
sigchld_code_to_string(code), status);
|
"Control process",
|
||||||
|
socket_exec_command_to_string(s->control_command_id),
|
||||||
|
code, status);
|
||||||
|
|
||||||
if (s->result == SOCKET_SUCCESS)
|
if (s->result == SOCKET_SUCCESS)
|
||||||
s->result = f;
|
s->result = f;
|
||||||
|
|
|
@ -1011,8 +1011,11 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||||
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
|
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_unit_full(u, f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE, 0,
|
unit_log_process_exit(
|
||||||
"Swap process exited, code=%s status=%i", sigchld_code_to_string(code), status);
|
u, f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
|
||||||
|
"Swap process",
|
||||||
|
swap_exec_command_to_string(s->control_command_id),
|
||||||
|
code, status);
|
||||||
|
|
||||||
switch (s->state) {
|
switch (s->state) {
|
||||||
|
|
||||||
|
|
|
@ -5456,6 +5456,35 @@ void unit_log_failure(Unit *u, const char *result) {
|
||||||
"UNIT_RESULT=%s", result);
|
"UNIT_RESULT=%s", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unit_log_process_exit(
|
||||||
|
Unit *u,
|
||||||
|
int level,
|
||||||
|
const char *kind,
|
||||||
|
const char *command,
|
||||||
|
int code,
|
||||||
|
int status) {
|
||||||
|
|
||||||
|
assert(u);
|
||||||
|
assert(kind);
|
||||||
|
|
||||||
|
if (code != CLD_EXITED)
|
||||||
|
level = LOG_WARNING;
|
||||||
|
|
||||||
|
log_struct(level,
|
||||||
|
"MESSAGE_ID=" SD_MESSAGE_UNIT_PROCESS_EXIT_STR,
|
||||||
|
LOG_UNIT_MESSAGE(u, "%s exited, code=%s, status=%i/%s",
|
||||||
|
kind,
|
||||||
|
sigchld_code_to_string(code), status,
|
||||||
|
strna(code == CLD_EXITED
|
||||||
|
? exit_status_to_string(status, EXIT_STATUS_FULL)
|
||||||
|
: signal_to_string(status))),
|
||||||
|
"EXIT_CODE=%s", sigchld_code_to_string(code),
|
||||||
|
"EXIT_STATUS=%i", status,
|
||||||
|
"COMMAND=%s", strna(command),
|
||||||
|
LOG_UNIT_ID(u),
|
||||||
|
LOG_UNIT_INVOCATION_ID(u));
|
||||||
|
}
|
||||||
|
|
||||||
static const char* const collect_mode_table[_COLLECT_MODE_MAX] = {
|
static const char* const collect_mode_table[_COLLECT_MODE_MAX] = {
|
||||||
[COLLECT_INACTIVE] = "inactive",
|
[COLLECT_INACTIVE] = "inactive",
|
||||||
[COLLECT_INACTIVE_OR_FAILED] = "inactive-or-failed",
|
[COLLECT_INACTIVE_OR_FAILED] = "inactive-or-failed",
|
||||||
|
|
|
@ -807,6 +807,7 @@ const char *unit_label_path(Unit *u);
|
||||||
int unit_pid_attachable(Unit *unit, pid_t pid, sd_bus_error *error);
|
int unit_pid_attachable(Unit *unit, pid_t pid, sd_bus_error *error);
|
||||||
|
|
||||||
void unit_log_failure(Unit *u, const char *result);
|
void unit_log_failure(Unit *u, const char *result);
|
||||||
|
void unit_log_process_exit(Unit *u, int level, const char *kind, const char *command, int code, int status);
|
||||||
|
|
||||||
/* Macros which append UNIT= or USER_UNIT= to the message */
|
/* Macros which append UNIT= or USER_UNIT= to the message */
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,9 @@ _SD_BEGIN_DECLARATIONS;
|
||||||
#define SD_MESSAGE_SPAWN_FAILED SD_ID128_MAKE(64,12,57,65,1c,1b,4e,c9,a8,62,4d,7a,40,a9,e1,e7)
|
#define SD_MESSAGE_SPAWN_FAILED SD_ID128_MAKE(64,12,57,65,1c,1b,4e,c9,a8,62,4d,7a,40,a9,e1,e7)
|
||||||
#define SD_MESSAGE_SPAWN_FAILED_STR SD_ID128_MAKE_STR(64,12,57,65,1c,1b,4e,c9,a8,62,4d,7a,40,a9,e1,e7)
|
#define SD_MESSAGE_SPAWN_FAILED_STR SD_ID128_MAKE_STR(64,12,57,65,1c,1b,4e,c9,a8,62,4d,7a,40,a9,e1,e7)
|
||||||
|
|
||||||
|
#define SD_MESSAGE_UNIT_PROCESS_EXIT SD_ID128_MAKE(98,e3,22,20,3f,7a,4e,d2,90,d0,9f,e0,3c,09,fe,15)
|
||||||
|
#define SD_MESSAGE_UNIT_PROCESS_EXIT_STR SD_ID128_MAKE_STR(98,e3,22,20,3f,7a,4e,d2,90,d0,9f,e0,3c,09,fe,15)
|
||||||
|
|
||||||
#define SD_MESSAGE_FORWARD_SYSLOG_MISSED SD_ID128_MAKE(00,27,22,9c,a0,64,41,81,a7,6c,4e,92,45,8a,fa,2e)
|
#define SD_MESSAGE_FORWARD_SYSLOG_MISSED SD_ID128_MAKE(00,27,22,9c,a0,64,41,81,a7,6c,4e,92,45,8a,fa,2e)
|
||||||
#define SD_MESSAGE_FORWARD_SYSLOG_MISSED_STR \
|
#define SD_MESSAGE_FORWARD_SYSLOG_MISSED_STR \
|
||||||
SD_ID128_MAKE_STR(00,27,22,9c,a0,64,41,81,a7,6c,4e,92,45,8a,fa,2e)
|
SD_ID128_MAKE_STR(00,27,22,9c,a0,64,41,81,a7,6c,4e,92,45,8a,fa,2e)
|
||||||
|
|
Loading…
Reference in a new issue