12 #include <sys/ioctl.h> 13 #include <sys/reboot.h> 15 #include <sys/types.h> 23 # include <sys/mman.h> 26 static int sbd_pid = 0;
36 #define SYSRQ "/proc/sys/kernel/sysrq" 42 static bool need_init =
true;
52 procf = fopen(
SYSRQ,
"r");
57 if (fscanf(procf,
"%d", &c) != 1) {
67 procf = fopen(
SYSRQ,
"w");
72 fprintf(procf,
"%d", c);
74 #endif // SUPPORT_PROCFS 86 procf = fopen(
"/proc/sysrq-trigger",
"a");
88 crm_perror(LOG_WARNING,
"Opening sysrq-trigger failed");
92 fprintf(procf,
"%c\n", t);
94 #endif // SUPPORT_PROCFS 100 pcmk_panic_local(
void)
103 uid_t uid = geteuid();
104 pid_t ppid = getppid();
106 if(uid != 0 && ppid > 1) {
116 }
else if (uid != 0) {
122 union sigval signal_value;
124 memset(&signal_value, 0,
sizeof(signal_value));
128 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
129 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd(%d) to panic", ppid);
131 #endif // SUPPORT_PROCFS 140 if (
safe_str_eq(
"crash", getenv(
"PCMK_panic_action"))) {
163 union sigval signal_value;
164 pid_t ppid = getppid();
168 memset(&signal_value, 0,
sizeof(signal_value));
170 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
171 crm_perror(LOG_EMERG,
"Cannot signal SBD(%d) to terminate", sbd_pid);
187 static struct qb_log_callsite *panic_cs = NULL;
189 if (panic_cs == NULL) {
196 if (panic_cs && panic_cs->targets) {
199 "Shutting down instead of panicking the node: origin=%s, sbd=%d, parent=%d",
200 origin, sbd_pid, getppid());
206 do_crm_log_always(LOG_EMERG,
"Signaling sbd(%d) to panic the system: %s", sbd_pid, origin);
218 char *pidfile = NULL;
219 char *sbd_path = NULL;
234 crm_trace(
"SBD detected at pid=%d (file)", sbd_pid);
240 crm_trace(
"SBD detected at pid=%d (proc)", sbd_pid);
241 #endif // SUPPORT_PROCFS 258 const char *env_value = getenv(
"SBD_WATCHDOG_TIMEOUT");
269 if (st_timeout <= 0) {
270 crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
271 value? value :
"default");
275 "Shutting down: stonith-watchdog-timeout configured (%s) but SBD not active",
283 if (st_timeout < sbd_timeout) {
285 "Shutting down: stonith-watchdog-timeout (%s) too short (must be >%ldms)",
290 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...)