* 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 <xm@subsignal.org>
+ * Copyright (C) 2009 Jo-Philipp Wich <jow@openwrt.org>
*/
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <signal.h>
+#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
/* 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"
-
-/* SSHd error action */
-#define SSHD_ACTION "/etc/init.d/dropbear", "/etc/init.d/dropbear", "restart"
-
/* Watchdog device */
#define WATCH_DEVICE "/dev/watchdog"
#define WATCH_SHUTDOWN 'V'
/* System load error action and treshold */
#define LOAD_TRESHOLD 15.00
-#define LOAD_ACTION "/sbin/reboot"
+#define LOAD_ACTION "/sbin/reboot", "/sbin/reboot"
/* Fallback binary name (passed by makefile) */
#ifndef BINARY
};
/* 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;
};
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 */
}
/* 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)