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();
59 int reboot_cmd = RB_AUTOBOOT;
61 if(uid != 0 && ppid > 1) {
68 crm_emerg(
"Signaling parent %lld to panic", (
long long) ppid);
72 }
else if (uid != 0) {
78 union sigval signal_value;
80 memset(&signal_value, 0,
sizeof(signal_value));
82 crm_emerg(
"Signaling pacemakerd[%lld] to panic", (
long long) ppid);
84 if(ppid > 1 && sigqueue(ppid, SIGQUIT, signal_value) < 0) {
85 crm_perror(LOG_EMERG,
"Cannot signal pacemakerd[%lld] to panic",
88 #endif // HAVE_LINUX_PROCFS 99 panic_action += strlen(
"sync-");
108 reboot_cmd = RB_POWER_OFF;
109 #elif defined(RB_POWEROFF) 110 reboot_cmd = RB_POWEROFF;
114 sysrq_trigger(sysrq);
118 crm_emerg(
"Reboot failed, escalating to parent %lld: %s " CRM_XS " rc=%d",
137 union sigval signal_value;
138 pid_t ppid = getppid();
140 crm_emerg(
"Signaling sbd[%lld] to panic", (
long long) sbd_pid);
142 memset(&signal_value, 0,
sizeof(signal_value));
144 if(sigqueue(sbd_pid, SIGKILL, signal_value) < 0) {
145 crm_perror(LOG_EMERG,
"Cannot signal sbd[%lld] to terminate",
146 (
long long) sbd_pid);
177 crm_emerg(
"Shutting down instead of panicking the node " 178 CRM_XS " origin=%s sbd=%lld parent=%d",
179 origin, (
long long) sbd_pid, getppid());
187 crm_emerg(
"Signaling sbd[%lld] to panic the system: %s",
188 (
long long) sbd_pid, origin);
192 crm_emerg(
"Panicking the system directly: %s", origin);
204 char *pidfile = NULL;
205 char *sbd_path = NULL;
219 crm_trace(
"SBD detected at pid %lld (via PID file %s)",
220 (
long long) sbd_pid, pidfile);
222 #if HAVE_LINUX_PROCFS 226 crm_trace(
"SBD detected at pid %lld (via procfs)",
227 (
long long) sbd_pid);
228 #endif // HAVE_LINUX_PROCFS 245 static long sbd_timeout = -2;
247 if (sbd_timeout == -2) {
248 sbd_timeout =
crm_get_msec(getenv(
"SBD_WATCHDOG_TIMEOUT"));
257 static bool checked_sync_resource_startup =
false;
259 if (!checked_sync_resource_startup) {
260 const char *sync_env = getenv(
"SBD_SYNC_RESOURCE_STARTUP");
262 if (sync_env == NULL) {
263 crm_trace(
"Defaulting to %sstart-up synchronization with sbd",
267 crm_warn(
"Defaulting to %sstart-up synchronization with sbd " 268 "because environment value '%s' is invalid",
271 checked_sync_resource_startup =
true;
273 return sync_resource_startup != 0;
281 return (sbd_timeout <= 0)? 0 : (2 * sbd_timeout);
293 if (st_timeout < 0) {
295 crm_debug(
"Using calculated value %ld for " 300 if (st_timeout == 0) {
303 value? value :
"default");
307 " configured (%s) but SBD not active",
308 pcmk__s(value,
"auto"));
315 if (st_timeout < sbd_timeout) {
317 " (%s) too short (must be >%ldms)",
323 " %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)
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
long pcmk__get_sbd_watchdog_timeout(void)
bool pcmk__valid_stonith_watchdog_timeout(const char *value)
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)
long pcmk__auto_stonith_watchdog_timeout(void)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
#define crm_info(fmt, args...)
#define PCMK_OPT_STONITH_WATCHDOG_TIMEOUT