X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=contrib%2Fpackage%2Ffreifunk-watchdog%2Fsrc%2Fwatchdog.h;h=6f2382de38b54717b8d90e86af40594188b958a6;hb=HEAD;hp=d11396f807f2524a181915f5753202b96e6238b4;hpb=214511aafc65d340174c93703efd1e158b076be1;p=project%2Fluci.git diff --git a/contrib/package/freifunk-watchdog/src/watchdog.h b/contrib/package/freifunk-watchdog/src/watchdog.h index d11396f80..6f2382de3 100644 --- a/contrib/package/freifunk-watchdog/src/watchdog.h +++ b/contrib/package/freifunk-watchdog/src/watchdog.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * Copyright (C) 2009 Jo-Philipp Wich + * Copyright (C) 2009 Jo-Philipp Wich */ #include @@ -28,25 +28,45 @@ #include #include #include +#include +#include +#include #include #include #include +#include +#include #include "ucix.h" #include "wireless.22.h" -/* Check interval */ -#define INTERVAL 30 +/* Watchdog poll interval */ +#define BASE_INTERVAL 5 + +/* Action interval (N * BASE_INTERVAL) */ +#define ACTION_INTERVAL 6 + +/* Hysteresis */ +#define HYSTERESIS 3 /* How to call myself in the logs */ #define SYSLOG_IDENT "Freifunk Watchdog" +/* Process error action */ +#define PROC_ACTION curr_proc->initscript, curr_proc->initscript, "restart" + /* Wifi error action */ #define WIFI_ACTION "/sbin/wifi", "/sbin/wifi" -/* Crond error action */ -#define CRON_ACTION "/etc/init.d/cron", "/etc/init.d/cron", "restart" +/* Watchdog device */ +#define WATCH_DEVICE "/dev/watchdog" +#define WATCH_SHUTDOWN 'V' +#define WATCH_KEEPALIVE '\0' + +/* System load error action and treshold */ +#define LOAD_TRESHOLD 15.00 +#define LOAD_ACTION "/sbin/reboot", "/sbin/reboot" /* Fallback binary name (passed by makefile) */ #ifndef BINARY @@ -63,7 +83,7 @@ struct wifi_tuple { }; /* structure to hold tuple-list and uci context during iteration */ -struct uci_itr_ctx { +struct uci_wifi_iface_itr_ctx { struct wifi_tuple *list; struct uci_context *ctx; }; @@ -71,6 +91,23 @@ struct uci_itr_ctx { typedef struct wifi_tuple wifi_tuple_t; +/* process name/exec tuples */ +struct process_tuple { + char process[PATH_MAX + 1]; + char initscript[PATH_MAX + 1]; + int restart; + struct process_tuple *next; +}; + +/* structure to hold tuple-list and uci context during iteration */ +struct uci_process_itr_ctx { + struct process_tuple *list; + struct uci_context *ctx; +}; + +typedef struct process_tuple process_tuple_t; + + /* ioctl() helper (stolen from iwlib) */ static inline int iw_ioctl(int skfd, /* Socket to the kernel */ @@ -86,22 +123,20 @@ iw_ioctl(int skfd, /* Socket to the kernel */ } /* fork() & execl() helper */ -#define EXEC(x) \ - do { \ - switch(fork()) \ - { \ - case -1: \ - syslog(LOG_CRIT, "Unable to fork child: %s", \ - strerror(errno)); \ - \ - break; \ - \ - case 0: \ - execl(x, NULL); \ - syslog(LOG_CRIT, "Unable to execute action: %s", \ - strerror(errno)); \ - \ - return 1; \ - } \ +#define EXEC(x) \ + do { \ + switch(fork()) \ + { \ + case -1: \ + syslog(LOG_CRIT, "Unable to fork child: %s", \ + strerror(errno)); \ + break; \ + \ + case 0: \ + execl(x, NULL); \ + syslog(LOG_CRIT, "Unable to execute action: %s", \ + strerror(errno)); \ + return 1; \ + } \ } while(0)