13 #include <sys/ioctl.h>
14 #include <sys/reboot.h>
16 #include <sys/types.h>
24 # include <sys/mman.h>
27 static pid_t sbd_pid = 0;
44 procf = fopen(
"/proc/sysrq-trigger",
"a");
46 crm_perror(LOG_WARNING,
"Opening sysrq-trigger failed");
50 fprintf(procf,
"%c\n", t);
58 pcmk_panic_local(
void)
61 uid_t uid = geteuid();
62 pid_t ppid = getppid();
64 if(uid != 0 && ppid > 1) {
71 crm_emerg(
"Signaling parent %lld to panic", (
long long) ppid);
75 }
else if (uid != 0) {
81 union sigval signal_value;
83 memset(&signal_value, 0,
sizeof(signal_value));
85 crm_emerg(
"Signaling pacemakerd[%lld] to panic", (
long long) ppid);
87 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
88 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd[%lld] to panic",
100 if (
safe_str_eq(
"crash", getenv(
"PCMK_panic_action"))) {
109 crm_emerg(
"Reboot failed, escalating to parent %lld: %s " CRM_XS " rc=%d",
124 union sigval signal_value;
125 pid_t ppid = getppid();
127 crm_emerg(
"Signaling sbd[%lld] to panic", (
long long) sbd_pid);
129 memset(&signal_value, 0,
sizeof(signal_value));
131 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
132 crm_perror(LOG_EMERG,
"Cannot signal sbd[%lld] to terminate",
133 (
long long) sbd_pid);
149 static struct qb_log_callsite *panic_cs = NULL;
151 if (panic_cs == NULL) {
158 if (panic_cs && panic_cs->targets) {
160 crm_emerg(
"Shutting down instead of panicking the node "
161 CRM_XS " origin=%s sbd=%lld parent=%d",
162 origin, (
long long) sbd_pid, getppid());
168 crm_emerg(
"Signaling sbd[%lld] to panic the system: %s",
169 (
long long) sbd_pid, origin);
173 crm_emerg(
"Panicking the system directly: %s", origin);
181 char *pidfile = NULL;
182 char *sbd_path = NULL;
196 crm_trace(
"SBD detected at pid %lld (via PID file %s)",
197 (
long long) sbd_pid, pidfile);
203 crm_trace(
"SBD detected at pid %lld (via procfs)",
204 (
long long) sbd_pid);
222 static long sbd_timeout = -2;
224 if (sbd_timeout == -2) {
225 sbd_timeout =
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
235 return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
243 if (st_timeout < 0) {
245 crm_debug(
"Using calculated value %ld for stonith-watchdog-timeout (%s)",
249 if (st_timeout == 0) {
250 crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
251 value? value :
"default");
254 crm_emerg(
"Shutting down: stonith-watchdog-timeout configured (%s) "
255 "but SBD not active", (value? value :
"auto"));
262 if (st_timeout < sbd_timeout) {
263 crm_emerg(
"Shutting down: stonith-watchdog-timeout (%s) too short "
264 "(must be >%ldms)", value, sbd_timeout);
268 crm_info(
"Watchdog configured with stonith-watchdog-timeout %s and SBD timeout %ldms",
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
pid_t pcmk__procfs_pid_of(const char *name)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
#define safe_str_eq(a, b)
#define crm_info(fmt, args...)
unsigned int crm_trace_nonlog
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
#define crm_debug(fmt, args...)
#define crm_trace(fmt, args...)
#define crm_emerg(fmt, args...)
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
long pcmk__auto_watchdog_timeout()
long pcmk__get_sbd_timeout(void)
pid_t pcmk_locate_sbd(void)
void pcmk_panic(const char *origin)
bool pcmk__valid_sbd_timeout(const char *value)