watchdogd
Advanced system & process supervisor for Linux
wdog.h
Go to the documentation of this file.
1 /* Watchdog API for the process supervisor, its clients, and others
2  *
3  * Copyright (C) 2015-2024 Joachim Wiberg <troglobit@gmail.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 #ifndef WDOG_H_
41 #define WDOG_H_
42 
43 #include <time.h>
44 
46 typedef enum {
58 } wdog_code_t;
59 
61 typedef struct
62 {
63  unsigned int counter;
64  unsigned int wid;
65  wdog_code_t code;
66  unsigned int enabled;
67  char label[48];
68  struct tm date;
70 
73 /*
74  * Check if watchdogd API is actively responding,
75  * returns %TRUE(1) or %FALSE(0)
76  */
77 int wdog_ping (void);
78 int wdog_reload (void);
79 
80 int wdog_enable (int enable); /* Attempt to temp. disable */
81 int wdog_status (int *status); /* Check if enabled */
82 
83 int wdog_failed (wdog_code_t code, int pid, char *label, unsigned int timeout);
84 
85 int wdog_reset (int pid, char *label);
86 int wdog_reset_timeout (int pid, char *label, unsigned int timeout);
87 
95 int wdog_set_debug(int enable);
96 
102 int wdog_get_debug(int *status);
103 
109 int wdog_set_loglevel(char *level);
110 
115 char *wdog_get_loglevel(void);
116 
122 int wdog_reset_counter(unsigned int *counter);
123 
134 int wdog_reset_reason(wdog_reason_t *reason);
135 
145 int wdog_reset_reason_raw(wdog_reason_t *reason);
146 
152 char *wdog_reset_reason_str(wdog_reason_t *reason);
153 
164 int wdog_reset_reason_clr(void);
165 
166 /*
167  * Process supervisor API, see also compat.h
168  */
169 
183 int wdog_subscribe(char *label, unsigned int timeout, unsigned int *next_ack);
184 
194 int wdog_unsubscribe(int id, unsigned int ack);
195 
210 int wdog_kick(int id, unsigned int timeout, unsigned int ack, unsigned int *next_ack);
211 
223 int wdog_extend_kick(int id, unsigned int timeout, unsigned int *ack);
224 
235 int wdog_kick2(int id, unsigned int *ack);
236 
237 /*
238  * Compatibility wrapper layer
239  */
240 #include "compat.h"
241 
242 #endif /* WDOG_H_ */
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
unsigned int enabled
Unused, kept for compat.
Definition: wdog.h:66
wdog_code_t
Reset reason codes.
Definition: wdog.h:46
int wdog_kick(int id, unsigned int timeout, unsigned int ack, unsigned int *next_ack)
Kick the watchdog with a custom timeout (old API)
unsigned int counter
Global reset counter, not per-reason.
Definition: wdog.h:63
Likely, WDT timed out.
Definition: wdog.h:54
Supervised process.
Definition: wdog.h:49
filenr pluing
Definition: wdog.h:55
int wdog_reset_reason_raw(wdog_reason_t *reason)
Get reset reason (raw).
Unused?
Definition: wdog.h:48
Supervised process.
Definition: wdog.h:51
int wdog_reset_reason(wdog_reason_t *reason)
Get reset reason.
int wdog_set_debug(int enable)
Toggle debug messages in daemon.
int wdog_reset_counter(unsigned int *counter)
Get system reset counter (updated on every watchdog reset, incl.
Operator requested system reboot.
Definition: wdog.h:53
int wdog_reset_reason_clr(void)
Clear reset reason, including reset counter.
loadavg plugin
Definition: wdog.h:57
int wdog_get_debug(int *status)
Get daemon debug status.
int wdog_subscribe(char *label, unsigned int timeout, unsigned int *next_ack)
Start supervising a subscriber.
Supervised process.
Definition: wdog.h:50
int wdog_kick2(int id, unsigned int *ack)
Kick the watchdog.
wdog_code_t code
Reset reason code, use wdog_reset_reason_str()
Definition: wdog.h:65
int wdog_extend_kick(int id, unsigned int timeout, unsigned int *ack)
Kick the watchdog with a custom timeout.
Supervised process.
Definition: wdog.h:52
int wdog_set_loglevel(char *level)
Change daemon log level.
char * wdog_get_loglevel(void)
Get daemon log level.
unsigned int wid
Watchdog ID of process causing reset.
Definition: wdog.h:64
int wdog_unsubscribe(int id, unsigned int ack)
Stop supervising a subscriber.
Reset reason data.
Definition: wdog.h:61
After reset/power-on.
Definition: wdog.h:47
meminfo plugin
Definition: wdog.h:56
char * wdog_reset_reason_str(wdog_reason_t *reason)
Translates wdog_code_t to human-readable string.