13 #include <sys/ioctl.h> 14 #include <sys/reboot.h> 16 #include <sys/types.h> 23 static pid_t sbd_pid = 0;
32 procf = fopen(
"/proc/sysrq-trigger",
"a");
34 crm_perror(LOG_WARNING,
"Opening sysrq-trigger failed");
38 fprintf(procf,
"%c\n", t);
40 #endif // HAVE_LINUX_PROCFS 53 uid_t uid = geteuid();
54 pid_t ppid = getppid();
57 if(uid != 0 && ppid > 1) {
64 crm_emerg(
"Signaling parent %lld to panic", (
long long) ppid);
68 }
else if (uid != 0) {
74 union sigval signal_value;
76 memset(&signal_value, 0,
sizeof(signal_value));
78 crm_emerg(
"Signaling pacemakerd[%lld] to panic", (
long long) ppid);
80 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
81 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd[%lld] to panic",
84 #endif // HAVE_LINUX_PROCFS 110 crm_emerg(
"Reboot failed, escalating to parent %lld: %s " CRM_XS " rc=%d",
129 union sigval signal_value;
130 pid_t ppid = getppid();
132 crm_emerg(
"Signaling sbd[%lld] to panic", (
long long) sbd_pid);
134 memset(&signal_value, 0,
sizeof(signal_value));
136 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
137 crm_perror(LOG_EMERG,
"Cannot signal sbd[%lld] to terminate",
138 (
long long) sbd_pid);
169 crm_emerg(
"Shutting down instead of panicking the node " 170 CRM_XS " origin=%s sbd=%lld parent=%d",
171 origin, (
long long) sbd_pid, getppid());
179 crm_emerg(
"Signaling sbd[%lld] to panic the system: %s",
180 (
long long) sbd_pid, origin);
184 crm_emerg(
"Panicking the system directly: %s", origin);
196 char *pidfile = NULL;
197 char *sbd_path = NULL;
211 crm_trace(
"SBD detected at pid %lld (via PID file %s)",
212 (
long long) sbd_pid, pidfile);
214 #if HAVE_LINUX_PROCFS 218 crm_trace(
"SBD detected at pid %lld (via procfs)",
219 (
long long) sbd_pid);
220 #endif // HAVE_LINUX_PROCFS 237 static long sbd_timeout = -2;
239 if (sbd_timeout == -2) {
240 sbd_timeout =
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
249 static bool checked_sync_resource_startup =
false;
251 if (!checked_sync_resource_startup) {
252 const char *sync_env = getenv(
"SBD_SYNC_RESOURCE_STARTUP");
254 if (sync_env == NULL) {
255 crm_trace(
"Defaulting to %sstart-up synchronization with sbd",
259 crm_warn(
"Defaulting to %sstart-up synchronization with sbd " 260 "because environment value '%s' is invalid",
263 checked_sync_resource_startup =
true;
265 return sync_resource_startup != 0;
273 return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
281 if (st_timeout < 0) {
283 crm_debug(
"Using calculated value %ld for stonith-watchdog-timeout (%s)",
287 if (st_timeout == 0) {
288 crm_debug(
"Watchdog may be enabled but stonith-watchdog-timeout is disabled (%s)",
289 value? value :
"default");
292 crm_emerg(
"Shutting down: stonith-watchdog-timeout configured (%s) " 293 "but SBD not active", (value? value :
"auto"));
300 if (st_timeout < sbd_timeout) {
301 crm_emerg(
"Shutting down: stonith-watchdog-timeout (%s) too short " 302 "(must be >%ldms)", value, sbd_timeout);
306 crm_info(
"Watchdog configured with stonith-watchdog-timeout %s and SBD timeout %ldms",
#define pcmk__if_tracing(if_action, else_action)
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
void pcmk__panic(const char *origin)
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
bool pcmk__get_sbd_sync_resource_startup(void)
bool pcmk__valid_sbd_timeout(const char *value)
long pcmk__get_sbd_timeout(void)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
const char * pcmk__env_option(const char *option)
#define crm_warn(fmt, args...)
#define crm_emerg(fmt, args...)
#define crm_debug(fmt, args...)
#define PCMK__ENV_PANIC_ACTION
#define crm_trace(fmt, args...)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
pid_t pcmk__procfs_pid_of(const char *name)
int crm_str_to_boolean(const char *s, int *ret)
#define PCMK__SBD_SYNC_DEFAULT
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
pid_t pcmk__locate_sbd(void)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
long pcmk__auto_watchdog_timeout(void)
#define crm_info(fmt, args...)