-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to run a trigger when RAS mc_event occurs, The mc_event trigger is separated to CE trigger and UE trigger, this is because CE is more frequently than UE, CE trigger will lead to more performance hits. Users can choose different trigger for CE/UE to reduce this effect. Users can config trigger in /etc/sysconfig/rasdaemon: TRIGGER_DIR: The trigger diretory MC_CE_TRIGGER: The script executed when corrected error occurs. MC_UE_TRIGGER: The script executed when uncorrected error occurs. No script will be executed if MC_CE_TRIGGER/MC_UE_TRIGGER is null. Signed-off-by: Ruidong Tian <[email protected]>
- Loading branch information
Ruidong Tian
committed
Feb 26, 2024
1 parent
f9cb13b
commit a4c9676
Showing
8 changed files
with
217 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
# This shell script can be executed by rasdaemon in daemon mode when a | ||
# mc_event is occured, environment variables include all information | ||
# reported by tracepoint. | ||
# | ||
# environment: | ||
# TIMESTAMP Timestamp when error occurred | ||
# COUNT Number of errors of the same type | ||
# TYPE Error type from Corrected/Uncorrected | ||
# MESSAGE Error message | ||
# LABEL Label of the affected DIMM(s) | ||
# MC_INDEX DIMM identifier from DMI/SMBIOS if available | ||
# TOP_LAYER Top layer of the error | ||
# MIDDLE_LAYER Middle layer of the error | ||
# LOWER_LAYER Low layer of the error | ||
# ADDRESS Error address | ||
# GRAIN Minimum granularity for an error report, in bytes | ||
# SYNDROME Syndrome of the error (or 0 if unknown or if the syndrome is not applicable) | ||
# DRIVER_DETAIL Other driver-specific detail about the error | ||
# | ||
|
||
[ -x ./mc_event_trigger.local ] && . ./mc_event_trigger.local | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#define _GNU_SOURCE | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <sys/wait.h> | ||
#include "ras-logger.h" | ||
#include "trigger.h" | ||
|
||
void run_trigger(const char *trigger, char *argv[], char **env, const char* reporter) | ||
{ | ||
pid_t child; | ||
char *path; | ||
int status; | ||
char *trigger_dir = getenv("TRIGGER_DIR"); | ||
|
||
|
||
log(SYSLOG, LOG_INFO, "Running trigger `%s' (reporter: %s)\n", trigger, reporter); | ||
|
||
if (asprintf(&path, "%s/%s", trigger_dir, trigger) < 0) | ||
return; | ||
|
||
child = fork(); | ||
if (child < 0) { | ||
log(SYSLOG, LOG_ERR, "Cannot create process for trigger"); | ||
return; | ||
} | ||
|
||
if (child == 0) { | ||
execve(path, argv, env); | ||
_exit(127); | ||
} else { | ||
waitpid(child, &status, 0); | ||
if (WIFEXITED(status) && WEXITSTATUS(status)) { | ||
log(SYSLOG, LOG_INFO, "Trigger %s exited with status %d", | ||
trigger, WEXITSTATUS(status)); | ||
} else if (WIFSIGNALED(status)) { | ||
log(SYSLOG, LOG_INFO, "Trigger %s killed by signal %d", | ||
trigger, WTERMSIG(status)); | ||
} | ||
} | ||
} | ||
|
||
int trigger_check(char *s) | ||
{ | ||
char *name; | ||
int rc; | ||
char *trigger_dir = getenv("TRIGGER_DIR"); | ||
|
||
if (trigger_dir) { | ||
if (asprintf(&name, "%s/%s", trigger_dir, s) < 0) | ||
return -1; | ||
} else | ||
name = s; | ||
|
||
rc = access(name, R_OK|X_OK); | ||
|
||
if (trigger_dir) | ||
free(name); | ||
|
||
return rc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __TRIGGER_H__ | ||
#define __TRIGGER_H__ | ||
|
||
struct event_trigger { | ||
const char *name; | ||
void (*setup)(void); | ||
}; | ||
|
||
int trigger_check(char *s); | ||
void run_trigger(const char *trigger, char *argv[], char **env, const char* reporter); | ||
|
||
|
||
#endif |