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;
43 procf = fopen(
"/proc/sysrq-trigger",
"a");
45 crm_perror(LOG_WARNING,
"Opening sysrq-trigger failed");
49 fprintf(procf,
"%c\n", t);
51 #endif // SUPPORT_PROCFS
57 pcmk_panic_local(
void)
60 uid_t uid = geteuid();
61 pid_t ppid = getppid();
63 if(uid != 0 && ppid > 1) {
74 }
else if (uid != 0) {
80 union sigval signal_value;
82 memset(&signal_value, 0,
sizeof(signal_value));
86 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
87 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd(%d) to panic", ppid);
89 #endif // SUPPORT_PROCFS
98 if (
safe_str_eq(
"crash", getenv(
"PCMK_panic_action"))) {
121 union sigval signal_value;
122 pid_t ppid = getppid();
126 memset(&signal_value, 0,
sizeof(signal_value));
128 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
129 crm_perror(LOG_EMERG,
"Cannot signal SBD(%d) to terminate", sbd_pid);
145 static struct qb_log_callsite *panic_cs = NULL;
147 if (panic_cs == NULL) {
154 if (panic_cs && panic_cs->targets) {
157 "Shutting down instead of panicking the node: origin=%s, sbd=%d, parent=%d",
158 origin, sbd_pid, getppid());
164 do_crm_log_always(LOG_EMERG,
"Signaling sbd(%d) to panic the system: %s", sbd_pid, origin);
176 char *pidfile = NULL;
177 char *sbd_path = NULL;
192 crm_trace(
"SBD detected at pid=%d (file)", sbd_pid);
198 crm_trace(
"SBD detected at pid=%d (proc)", sbd_pid);
199 #endif // SUPPORT_PROCFS
216 static long sbd_timeout = -2;
218 if (sbd_timeout == -2) {
219 sbd_timeout =
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
229 return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
237 if (st_timeout < 0) {
239 crm_debug(
"Using calculated value %ld for stonith-watchdog-timeout (%s)",
243 if (st_timeout == 0) {
244 crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
245 value? value :
"default");
249 "Shutting down: stonith-watchdog-timeout configured (%s) but SBD not active",
250 (value? value :
"auto"));
257 if (st_timeout < sbd_timeout) {
259 "Shutting down: stonith-watchdog-timeout (%s) too short (must be >%ldms)",
264 crm_info(
"Watchdog configured with stonith-watchdog-timeout %s and SBD timeout %ldms",
const char * pcmk_strerror(int rc)
long crm_get_sbd_timeout(void)
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
gboolean check_sbd_timeout(const char *value)
long long crm_get_msec(const char *input)
unsigned int crm_trace_nonlog
long crm_auto_watchdog_timeout(void)
#define crm_debug(fmt, args...)
#define crm_trace(fmt, args...)
void pcmk_panic(const char *origin)
long crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
#define do_crm_log_always(level, fmt, args...)
Log a message using constant severity.
#define crm_perror(level, fmt, args...)
Log a system error message.
pid_t pcmk_locate_sbd(void)
#define safe_str_eq(a, b)
int crm_procfs_pid_of(const char *name)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define crm_info(fmt, args...)