13 #include <sys/ioctl.h> 14 #include <sys/reboot.h> 16 #include <sys/types.h> 24 # include <sys/mman.h> 27 static int sbd_pid = 0;
37 #define SYSRQ "/proc/sys/kernel/sysrq" 43 static bool need_init =
true;
53 procf = fopen(
SYSRQ,
"r");
58 if (fscanf(procf,
"%d", &c) != 1) {
68 procf = fopen(
SYSRQ,
"w");
73 fprintf(procf,
"%d", c);
75 #endif // SUPPORT_PROCFS 87 procf = fopen(
"/proc/sysrq-trigger",
"a");
89 crm_perror(LOG_WARNING,
"Opening sysrq-trigger failed");
93 fprintf(procf,
"%c\n", t);
95 #endif // SUPPORT_PROCFS 101 pcmk_panic_local(
void)
104 uid_t uid = geteuid();
105 pid_t ppid = getppid();
107 if(uid != 0 && ppid > 1) {
117 }
else if (uid != 0) {
123 union sigval signal_value;
125 memset(&signal_value, 0,
sizeof(signal_value));
129 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
130 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd(%d) to panic", ppid);
132 #endif // SUPPORT_PROCFS 141 if (
safe_str_eq(
"crash", getenv(
"PCMK_panic_action"))) {
164 union sigval signal_value;
165 pid_t ppid = getppid();
169 memset(&signal_value, 0,
sizeof(signal_value));
171 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
172 crm_perror(LOG_EMERG,
"Cannot signal SBD(%d) to terminate", sbd_pid);
188 static struct qb_log_callsite *panic_cs = NULL;
190 if (panic_cs == NULL) {
197 if (panic_cs && panic_cs->targets) {
200 "Shutting down instead of panicking the node: origin=%s, sbd=%d, parent=%d",
201 origin, sbd_pid, getppid());
207 do_crm_log_always(LOG_EMERG,
"Signaling sbd(%d) to panic the system: %s", sbd_pid, origin);
219 char *pidfile = NULL;
220 char *sbd_path = NULL;
235 crm_trace(
"SBD detected at pid=%d (file)", sbd_pid);
241 crm_trace(
"SBD detected at pid=%d (proc)", sbd_pid);
242 #endif // SUPPORT_PROCFS 259 const char *env_value = getenv(
"SBD_WATCHDOG_TIMEOUT");
270 if (st_timeout <= 0) {
271 crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
272 value? value :
"default");
276 "Shutting down: stonith-watchdog-timeout configured (%s) but SBD not active",
284 if (st_timeout < sbd_timeout) {
286 "Shutting down: stonith-watchdog-timeout (%s) too short (must be >%ldms)",
291 crm_info(
"Watchdog configured with stonith-watchdog-timeout %s and SBD timeout %ldms",
long crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
const char * pcmk_strerror(int rc)
pid_t pcmk_locate_sbd(void)
long long crm_get_msec(const char *input)
unsigned int crm_trace_nonlog
long crm_get_sbd_timeout(void)
#define crm_debug(fmt, args...)
#define crm_trace(fmt, args...)
#define do_crm_log_always(level, fmt, args...)
Log a message using constant severity.
#define DAEMON_RESPAWN_STOP
#define crm_perror(level, fmt, args...)
Log a system error message.
gboolean check_sbd_timeout(const char *value)
#define safe_str_eq(a, b)
int crm_procfs_pid_of(const char *name)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
void pcmk_panic(const char *origin)
#define crm_info(fmt, args...)