From 04ff91ae138e0e2aa12255961f4ada36b93388cd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 13 Mar 2009 09:35:36 +0000 Subject: [PATCH] Initial import. --- .cvsignore | 1 + README.Fedora | 34 +++ README.watchdog.ipmi | 107 +++++++++ import.log | 1 + sources | 1 + watchdog-5.5-cleanup-nfs.patch | 20 ++ watchdog-5.5-cleanup.patch | 416 +++++++++++++++++++++++++++++++++ watchdog.init | 86 +++++++ watchdog.spec | 130 +++++++++++ 9 files changed, 796 insertions(+) create mode 100644 README.Fedora create mode 100644 README.watchdog.ipmi create mode 100644 import.log create mode 100644 watchdog-5.5-cleanup-nfs.patch create mode 100644 watchdog-5.5-cleanup.patch create mode 100644 watchdog.init create mode 100644 watchdog.spec diff --git a/.cvsignore b/.cvsignore index e69de29..b65cc05 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1 @@ +watchdog-5.5.tar.gz diff --git a/README.Fedora b/README.Fedora new file mode 100644 index 0000000..e51e053 --- /dev/null +++ b/README.Fedora @@ -0,0 +1,34 @@ +This is the watchdog package for Fedora. It implements a userspace +daemon which periodically pings (usually hardware) to tell the +hardware that the machine is alive. If the hardware times out without +receiving a ping, it assumes userspace is dead and reboots the +machine. + +There are several major classes of watchdog available: + + - watchdog hardware implementing the Linux /dev/watchdog API + + * drivers in /lib/modules/$(uname -r)/kernel/drivers/watchdog/ + * http://lxr.linux.no/linux/Documentation/watchdog/watchdog-api.txt + + - softdog + + * software watchdog (just runs inside the kernel) + * implements the Linux /dev/watchdog API + * won't help you if the kernel fails (obvious, right?) + + - IPMI + + * a heavyweight standard for all things server-management + * separate Linux driver + * ipmitool to control it + * see README.watchdog.ipmi for how to use this daemon together + with IPMI + +You can also use watchdogs inside recent QEMU/KVM virtual machines. +When running qemu, specify "-watchdog i6300esb" on the qemu command +line (or use libvirt). Inside the guest, the i6300esb watchdog driver +should automatically load and provide you with a Linux /dev/watchdog- +compatible API. + + - Richard W.M. Jones (rjones@redhat.com) 2009-02-26 diff --git a/README.watchdog.ipmi b/README.watchdog.ipmi new file mode 100644 index 0000000..4a83238 --- /dev/null +++ b/README.watchdog.ipmi @@ -0,0 +1,107 @@ + +Instructions for how to set up the watchdog daemon to work with IPMI's hardware watchdog +---------------------------------------------------------------------------------------- + +First, verify that the ipmitool utility is present on the system to allow +the watchdog timer to be turned off via the command line (which ipmitool). +This will allow the hardware watchdog timer to be turned off gracefully +should it ever become necessary. If ipmitool is not present, install +it or download the latest version from http://ipmitool.sourceforge.net and +build and install it on your system. + +Next, prior to starting up the watchdog daemon, the BMC BIOS should be set +to enable the IPMI/BMC hardware watchdog timer, the OpenIPMI watchdog driver +module should be inserted with the desired configuration/startup settings, +and the watchdog daemon's configuration file should be modified to use /dev/watchdog: + + 1. To setup the IPMI/BMC BIOS to enable the hardware watchdog + timer, see BMC documentation. The main settings in the BMC BIOS + requiring modification to turn on the IPMI watchdog timer are: + + - Set the BMC POST Watchdog to "ENABLED". + - Set the BMC POST Watchdog Timeout to "5 Minutes". + + 2. To insert the OpenIPMI watchdog driver module with the + desired configuration settings, two steps are necessary: + + i.) Configure the OpenIPMI watchdog driver by editing the + /etc/sysconfig/ipmi configuration file: + + - Set "IPMI_WATCHDOG=yes". + - Set desired options via the IPMI_WATCHDOG_OPTIONS + config entry. + + EXAMPLE: 'IPMI_WATCHDOG_OPTIONS="timeout=60 start_now=1 \ + preop=preop_give_data action=power_cycle pretimeout=1" ' + + Execute "modinfo ipmi_watchdog" for more detailed information + on the available ipmi watchdog timer options. + + - Execute "service ipmi start" (the watchdog driver starts + automatically along with the other ipmi drivers). + + IMPORTANT: If "start_now=1" has been set as one of the + configuration options, be sure to start up the watchdog + daemon before the BMC timer expires! + + ii.) Set the OpenIPMI daemon and watchdog to start during bootup: + + - chkconfig ipmi on + - chkconfig watchdog on + + + 3. Configure the watchdog daemon by editing the + /etc/watchdog.conf configuration file: + + - Uncomment the "watchdog-device = /dev/watchdog" line. + - Ensure that "realtime = yes" and "priority = 1" are set and not + commented-out. + - Uncomment the "interval" line, and set the interval to be less + than what you set the timeout option to be in the /etc/sysconfig/ipmi + file (ex "timeout=60" so you might set interval to 50). + + So in the example described herein, the BMC BIOS setting is in + minutes (5), and the "interval" and ipmi_watchdog "timeout" settings + are both in seconds (50 and 60 respectively). Therefore, the BMC + hardware watchdog timer is set to expire and trigger a system power + cycle unless reset by the watchdog daemon within 5 minutes, and the + watchdog daemon will reset the timer every 60 seconds. + + + 4. Start the Watchdog daemon: + + - execute "service watchdog start" + + +IMPORTANT: To gracefully stop/kill the watchdog daemon, be sure +to use "service watchdog stop" (which executes "kill -s SIGTERM ") +and do *not* use "kill -9 ". Using "kill -9 " will cause the +daemon to be shut off without stopping the BMC's watchdog timer, thus +a system reboot will be triggered when the BMC's watchdog timer expires. + +Alternately, or in case the watchdog daemon is killed "ungracefully", +you can stop the BMC timer by executing the following ipmitool utility +command before the watchdog timer expires: + + # ipmitool -v raw 0x06 0x24 0x04 0x01 0x00 0x10 0x00 0x0a + +---------------------------------------------------------------------- + +To test the watchdog after system configuration and setup: + +. Use kill -9 on the watchdog daemon so it doesn't shut down the watchdog daemon + gracefully. Verify that the system gets reset after the BMC timer expires. + +. Use "service watchdog stop" and verify that the watchdog daemon shuts off + the BMC watchdog timer gracefully (the system doesn't get reset). + +. Set the timer on the watchdog daemon to be greater than the time set in + the BMC BIOS for system reset and verify that the system is reset. + +. Set the timer on the daemon to be less than the time set in the + BMC timer and verify that the BMC watchdog is poked regularly and the + system is not reset. + +. Test some of the other actions the BMC can take when the watchdog timer + goes off (see modinfo ipmi_watchdog for some other settings to try). + diff --git a/import.log b/import.log new file mode 100644 index 0000000..53964bb --- /dev/null +++ b/import.log @@ -0,0 +1 @@ +watchdog-5_5-2_fc11:HEAD:watchdog-5.5-2.fc11.src.rpm:1236936935 diff --git a/sources b/sources index e69de29..ee5a4d5 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +f4fbb3465bdc0d0ac27bdd2972f7f469 watchdog-5.5.tar.gz diff --git a/watchdog-5.5-cleanup-nfs.patch b/watchdog-5.5-cleanup-nfs.patch new file mode 100644 index 0000000..a45bd13 --- /dev/null +++ b/watchdog-5.5-cleanup-nfs.patch @@ -0,0 +1,20 @@ +diff -uNrp watchdog-5.3.1.orig/src/nfsmount_xdr.c watchdog-5.3.1/src/nfsmount_xdr.c +--- watchdog-5.3.1.orig/src/nfsmount_xdr.c 2007-05-30 13:00:37.000000000 -0400 ++++ watchdog-5.3.1/src/nfsmount_xdr.c 2007-05-30 13:02:04.000000000 -0400 +@@ -204,14 +204,14 @@ xdr_ppathcnf (XDR *xdrs, ppathcnf *objp) + if (!xdr_short (xdrs, &objp->pc_pipe_buf)) + return FALSE; + +- } else { ++ } /*else { + IXDR_PUT_LONG(buf, objp->pc_link_max); + IXDR_PUT_SHORT(buf, objp->pc_max_canon); + IXDR_PUT_SHORT(buf, objp->pc_max_input); + IXDR_PUT_SHORT(buf, objp->pc_name_max); + IXDR_PUT_SHORT(buf, objp->pc_path_max); + IXDR_PUT_SHORT(buf, objp->pc_pipe_buf); +- } ++ } */ + if (!xdr_u_char (xdrs, &objp->pc_vdisable)) + return FALSE; + if (!xdr_char (xdrs, &objp->pc_xxx)) diff --git a/watchdog-5.5-cleanup.patch b/watchdog-5.5-cleanup.patch new file mode 100644 index 0000000..e582013 --- /dev/null +++ b/watchdog-5.5-cleanup.patch @@ -0,0 +1,416 @@ +diff -ur watchdog-5.5/src/iface.c watchdog-5.5.cleanup/src/iface.c +--- watchdog-5.5/src/iface.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/iface.c 2009-02-26 15:28:24.000000000 +0000 +@@ -66,7 +66,7 @@ + #if USE_SYSLOG + /* do verbose logging */ + if (verbose && logtick && ticker == 1) +- syslog(LOG_INFO, "device %s received %u bytes", dev->name, bytes); ++ syslog(LOG_INFO, "device %s received %lu bytes", dev->name, bytes); + #endif + + if (dev->parameter.iface.bytes == bytes) { +diff -ur watchdog-5.5/src/keep_alive.c watchdog-5.5.cleanup/src/keep_alive.c +--- watchdog-5.5/src/keep_alive.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/keep_alive.c 2009-02-26 15:28:24.000000000 +0000 +@@ -20,7 +20,6 @@ + struct tm *tm; + char tbuf[TS_SIZE + 1]; + char tbufw[TS_SIZE + 1]; +- int i; + + if (hb == NULL) + return (ENOERR); +diff -ur watchdog-5.5/src/lomount.c watchdog-5.5.cleanup/src/lomount.c +--- watchdog-5.5/src/lomount.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/lomount.c 2009-02-26 15:28:24.000000000 +0000 +@@ -195,13 +195,13 @@ + break; + case LO_CRYPT_XOR: + pass = getpass ("Password: "); +- strncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); ++ strncpy ((char *)loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); + loopinfo.lo_encrypt_key[LO_KEY_SIZE - 1] = 0; +- loopinfo.lo_encrypt_key_size = strlen (loopinfo.lo_encrypt_key); ++ loopinfo.lo_encrypt_key_size = (int) strlen ((char *)loopinfo.lo_encrypt_key); + break; + case LO_CRYPT_DES: + pass = getpass ("Password: "); +- strncpy (loopinfo.lo_encrypt_key, pass, 8); ++ strncpy ((char *)loopinfo.lo_encrypt_key, pass, 8); + loopinfo.lo_encrypt_key[8] = 0; + loopinfo.lo_encrypt_key_size = 8; + pass = getpass ("Init (up to 16 hex digits): "); +diff -ur watchdog-5.5/src/mntent.c watchdog-5.5.cleanup/src/mntent.c +--- watchdog-5.5/src/mntent.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/mntent.c 2009-02-26 15:28:24.000000000 +0000 +@@ -21,9 +21,9 @@ + static char need_escaping[] = { ' ', '\t', '\n', '\\' }; + + static char * +-mangle(unsigned char *s) { ++mangle(const char *s) { + char *ss, *sp; +- int n; ++ size_t n; + + n = strlen(s); + ss = sp = xmalloc(4*n+1); +diff -ur watchdog-5.5/src/net.c watchdog-5.5.cleanup/src/net.c +--- watchdog-5.5/src/net.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/net.c 2009-02-26 15:28:24.000000000 +0000 +@@ -57,7 +57,9 @@ + for (i = 0; i < count; i++) { + + struct sockaddr_in from; +- int fromlen, fdmask, j; ++ int fdmask, j; ++ int *fdmask_p; ++ socklen_t fromlen; + struct timeval timeout, dtimeout; + struct icmphdr *icp = (struct icmphdr *) outpack; + +@@ -119,11 +121,11 @@ + break; + #if USE_SYSLOG + if (verbose && logtick && ticker == 1) +- syslog(LOG_ERR, "ping select timeout = %d seconds and %d useconds\n", dtimeout.tv_sec, dtimeout.tv_usec); ++ syslog(LOG_ERR, "ping select timeout = %ld seconds and %ld useconds\n", dtimeout.tv_sec, dtimeout.tv_usec); + #endif /* USE_SYSLOG */ ++ fdmask_p = &fdmask; + +- if (select(sock_fp + 1, (fd_set *) & fdmask, (fd_set *) NULL, +- (fd_set *) NULL, &dtimeout) >= 1) { ++ if (select(sock_fp + 1, (fd_set *) fdmask_p, (fd_set *) NULL, (fd_set *) NULL, &dtimeout) >= 1) { + + /* read reply */ + fromlen = sizeof(from); +diff -ur watchdog-5.5/src/nfsmount.c watchdog-5.5.cleanup/src/nfsmount.c +--- watchdog-5.5/src/nfsmount.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/nfsmount.c 2009-02-26 15:28:24.000000000 +0000 +@@ -55,6 +55,7 @@ + #include + #include "mount_constants.h" + #include "nfs_mount4.h" ++#include + + #define HAVE_inet_aton + +diff -ur watchdog-5.5/src/nfsmount_xdr.c watchdog-5.5.cleanup/src/nfsmount_xdr.c +--- watchdog-5.5/src/nfsmount_xdr.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/nfsmount_xdr.c 2009-02-26 15:28:24.000000000 +0000 +@@ -43,8 +43,6 @@ + bool_t + xdr_fhandle (XDR *xdrs, fhandle objp) + { +- register int32_t *buf; +- + if (!xdr_opaque (xdrs, objp, FHSIZE)) + return FALSE; + return TRUE; +@@ -53,8 +51,6 @@ + bool_t + xdr_fhandle3 (XDR *xdrs, fhandle3 *objp) + { +- register int32_t *buf; +- + if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3)) + return FALSE; + return TRUE; +@@ -63,8 +59,6 @@ + bool_t + xdr_mountstat3 (XDR *xdrs, mountstat3 *objp) + { +- register int32_t *buf; +- + if (!xdr_enum (xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +@@ -73,8 +67,6 @@ + bool_t + xdr_fhstatus (XDR *xdrs, fhstatus *objp) + { +- register int32_t *buf; +- + if (!xdr_u_int (xdrs, &objp->fhs_status)) + return FALSE; + switch (objp->fhs_status) { +@@ -91,8 +83,6 @@ + bool_t + xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp) + { +- register int32_t *buf; +- + if (!xdr_fhandle3 (xdrs, &objp->fhandle)) + return FALSE; + if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0, +@@ -104,8 +94,6 @@ + bool_t + xdr_mountres3 (XDR *xdrs, mountres3 *objp) + { +- register int32_t *buf; +- + if (!xdr_mountstat3 (xdrs, &objp->fhs_status)) + return FALSE; + switch (objp->fhs_status) { +@@ -122,8 +110,6 @@ + bool_t + xdr_dirpath (XDR *xdrs, dirpath *objp) + { +- register int32_t *buf; +- + if (!xdr_string (xdrs, objp, MNTPATHLEN)) + return FALSE; + return TRUE; +@@ -132,8 +118,6 @@ + bool_t + xdr_name (XDR *xdrs, name *objp) + { +- register int32_t *buf; +- + if (!xdr_string (xdrs, objp, MNTNAMLEN)) + return FALSE; + return TRUE; +@@ -142,8 +126,6 @@ + bool_t + xdr_mountlist (XDR *xdrs, mountlist *objp) + { +- register int32_t *buf; +- + if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody)) + return FALSE; + return TRUE; +@@ -152,8 +134,6 @@ + bool_t + xdr_mountbody (XDR *xdrs, mountbody *objp) + { +- register int32_t *buf; +- + if (!xdr_name (xdrs, &objp->ml_hostname)) + return FALSE; + if (!xdr_dirpath (xdrs, &objp->ml_directory)) +@@ -166,8 +146,6 @@ + bool_t + xdr_groups (XDR *xdrs, groups *objp) + { +- register int32_t *buf; +- + if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode)) + return FALSE; + return TRUE; +@@ -176,8 +154,6 @@ + bool_t + xdr_groupnode (XDR *xdrs, groupnode *objp) + { +- register int32_t *buf; +- + if (!xdr_name (xdrs, &objp->gr_name)) + return FALSE; + if (!xdr_groups (xdrs, &objp->gr_next)) +@@ -188,8 +164,6 @@ + bool_t + xdr_exports (XDR *xdrs, exports *objp) + { +- register int32_t *buf; +- + if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode)) + return FALSE; + return TRUE; +@@ -198,8 +172,6 @@ + bool_t + xdr_exportnode (XDR *xdrs, exportnode *objp) + { +- register int32_t *buf; +- + if (!xdr_dirpath (xdrs, &objp->ex_dir)) + return FALSE; + if (!xdr_groups (xdrs, &objp->ex_groups)) +@@ -212,8 +184,7 @@ + bool_t + xdr_ppathcnf (XDR *xdrs, ppathcnf *objp) + { +- register int32_t *buf; +- ++ register int32_t *buf; + int i; + + if (xdrs->x_op == XDR_ENCODE) { +diff -ur watchdog-5.5/src/pidfile.c watchdog-5.5.cleanup/src/pidfile.c +--- watchdog-5.5/src/pidfile.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/pidfile.c 2009-02-26 15:28:24.000000000 +0000 +@@ -8,7 +8,9 @@ + #include + #include "extern.h" + #include "watch_err.h" +- ++#include ++#include ++#include + #if USE_SYSLOG + #include + #endif +diff -ur watchdog-5.5/src/shutdown.c watchdog-5.5.cleanup/src/shutdown.c +--- watchdog-5.5/src/shutdown.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/shutdown.c 2009-02-26 15:28:24.000000000 +0000 +@@ -22,6 +22,10 @@ + #include "watch_err.h" + #include "extern.h" + ++#include ++#include ++#include ++ + #if defined __GLIBC__ + #include "ext2_mnt.h" + #include +@@ -66,7 +70,7 @@ + { + #if USE_SYSLOG + /* Log the closing message */ +- syslog(LOG_INFO, "stopping daemon (%d.%d)", MAJOR_VERSION, MINOR_VERSION); ++ syslog(LOG_INFO, "stopping daemon (%d.%.1f)", MAJOR_VERSION, MINOR_VERSION); + closelog(); + + sleep(5); /* make sure log is written */ +@@ -320,6 +324,7 @@ + void do_shutdown(int errorcode) + { + int i = 0, fd; ++ size_t write_len; + char *seedbck = RANDOM_SEED; + + /* soft-boot the system */ +@@ -438,7 +443,7 @@ + wtmp.ut_pid = 0; + wtmp.ut_type = RUN_LVL; + wtmp.ut_time = t; +- write(fd, (char *) &wtmp, sizeof(wtmp)); ++ write_len = write(fd, (char *) &wtmp, sizeof(wtmp)); + close(fd); + } + +@@ -453,8 +458,9 @@ + if ((fd_bck = creat(seedbck, S_IRUSR | S_IWUSR)) >= 0) { + char buf[512]; + +- if (read(fd_seed, buf, 512) == 512) +- write(fd_bck, buf, 512); ++ if (read(fd_seed, buf, 512) == 512) { ++ write_len= write(fd_bck, buf, 512); ++ } + close(fd_bck); + } + close(fd_seed); +diff -ur watchdog-5.5/src/temp.c watchdog-5.5.cleanup/src/temp.c +--- watchdog-5.5/src/temp.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/temp.c 2009-02-26 15:28:24.000000000 +0000 +@@ -31,7 +31,7 @@ + int err = errno; + + #if USE_SYSLOG +- syslog(LOG_ERR, "read %s gave errno = %d = '%m'", err, tempname); ++ syslog(LOG_ERR, "read %s gave errno = %d = '%m'", tempname, err); + #else /* USE_SYSLOG */ + perror(progname); + #endif /* USE_SYSLOG */ +diff -ur watchdog-5.5/src/test_binary.c watchdog-5.5.cleanup/src/test_binary.c +--- watchdog-5.5/src/test_binary.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/test_binary.c 2009-02-26 15:28:24.000000000 +0000 +@@ -10,6 +10,7 @@ + #include + #include "extern.h" + #include "watch_err.h" ++#include + + #if USE_SYSLOG + #include +@@ -76,7 +77,7 @@ + res = check_processes(timeout); + if (res == ETOOLONG) { + #if USE_SYSLOG +- syslog(LOG_ERR, "test-binary %s exceeded time limit %d", tbinary, timeout); ++ syslog(LOG_ERR, "test-binary %s exceeded time limit %ld", tbinary, timeout); + #endif /* USE_SYSLOG */ + return res; + } +diff -ur watchdog-5.5/src/watchdog.c watchdog-5.5.cleanup/src/watchdog.c +--- watchdog-5.5/src/watchdog.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/watchdog.c 2009-02-26 15:28:24.000000000 +0000 +@@ -23,6 +23,10 @@ + #include + #include + #include ++#include ++#include ++ ++ + #define __USE_GNU + #include + +@@ -72,7 +76,7 @@ + int softboot = FALSE, watchdog = -1, load = -1, mem = -1, temp = -1; + int tint = 10, logtick = 1, ticker = 1, schedprio = 1; + int maxload1 = 0, maxload5 = 0, maxload15 = 0, minpages = 0; +-int maxtemp = 120, hbstamps = 300, lastts, nrts; ++int maxtemp = 120, hbstamps = 300, lastts=0, nrts; + int pingcount = 3; + char *tempname = NULL, *devname = NULL, *admin = "root", *progname; + char *timestamps, *heartbeat; +@@ -85,7 +89,7 @@ + + static void usage(void) + { +- fprintf(stderr, "%s version %d.%d, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION); ++ fprintf(stderr, "%s version %d.%.1f, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION); + #if USE_SYSLOG + fprintf(stderr, "%s [-i [-f]] [-l ] [-v] [-s] [-b] [-m ]\n", progname); + #else /* USE_SYSLOG */ +@@ -618,8 +622,8 @@ + + /* Log the starting message */ + openlog(progname, LOG_PID, LOG_DAEMON); +- syslog(LOG_INFO, "starting daemon (%d.%d):", MAJOR_VERSION, MINOR_VERSION); +- syslog(LOG_INFO, "int=%ds realtime=%s sync=%s soft=%s mla=%d mem=%ld", ++ syslog(LOG_INFO, "starting daemon (%d.%.1f):", MAJOR_VERSION, MINOR_VERSION); ++ syslog(LOG_INFO, "int=%ds realtime=%s sync=%s soft=%s mla=%d mem=%d", + tint, + realtime ? "yes" : "no", + sync_it ? "yes" : "no", +@@ -650,7 +654,7 @@ + for (act = iface; act != NULL; act = act->next) + syslog(LOG_INFO, "interface: %s", act->name); + +- syslog(LOG_INFO, "test=%s(%d) repair=%s alive=%s heartbeat=%s temp=%s to=%s no_act=%s", ++ syslog(LOG_INFO, "test=%s(%ld) repair=%s alive=%s heartbeat=%s temp=%s to=%s no_act=%s", + (tbinary == NULL) ? "none" : tbinary, timeout, + (rbinary == NULL) ? "none" : rbinary, + (devname == NULL) ? "none" : devname, +@@ -692,7 +696,7 @@ + /* Allocate memory for keeping the timestamps in */ + nrts = 0; + lastts = 0; +- timestamps = (unsigned char *) calloc(hbstamps, TS_SIZE); ++ timestamps = (char *) calloc(hbstamps, TS_SIZE); + if ( timestamps == NULL ) { + #if USE_SYSLOG + syslog(LOG_ERR, "cannot allocate memory for timestamps (errno = %d = '%m')", errno); +diff -ur watchdog-5.5/src/wd_keepalive.c watchdog-5.5.cleanup/src/wd_keepalive.c +--- watchdog-5.5/src/wd_keepalive.c 2009-02-25 11:12:59.000000000 +0000 ++++ watchdog-5.5.cleanup/src/wd_keepalive.c 2009-02-26 15:29:18.000000000 +0000 +@@ -24,6 +24,7 @@ + #include + #include + #include ++ + #define __USE_GNU + #include + #include +@@ -271,7 +272,7 @@ + + /* Log the starting message */ + openlog(progname, LOG_PID, LOG_DAEMON); +- sprintf(log, "starting watchdog keepalive daemon (%d.%d):", MAJOR_VERSION, MINOR_VERSION); ++ sprintf(log, "starting watchdog keepalive daemon (%d.%.1f):", MAJOR_VERSION, MINOR_VERSION); + sprintf(log + strlen(log), " int=%d alive=%s realtime=%s", tint, devname, realtime ? "yes" : "no"); + syslog(LOG_INFO, log); + #endif /* USE_SYSLOG */ diff --git a/watchdog.init b/watchdog.init new file mode 100644 index 0000000..7f32bb3 --- /dev/null +++ b/watchdog.init @@ -0,0 +1,86 @@ +#! /bin/sh +# +# chkconfig: - 27 46 +# description: A software watchdog +# +# rc file author: Marc Merlin +# Henning P. Schmiedehausen + +# Source function library. +. /etc/rc.d/init.d/functions + +[ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0 + +VERBOSE="no" +if [ -f /etc/sysconfig/watchdog ]; then + . /etc/sysconfig/watchdog +fi + +RETVAL=0 +prog=watchdog +pidfile=/var/run/watchdog.pid +lockfile=/var/lock/subsys/watchdog + +start() { + + echo -n $"Starting $prog: " + if [ -n "$(pidofproc $prog)" ]; then + echo -n $"$prog: already running" + echo_failure + echo + return 1 + fi + if [ "$VERBOSE" = "yes" ]; then + daemon /usr/sbin/${prog} -v + else + daemon /usr/sbin/${prog} + fi + RETVAL=$? + [ $RETVAL -eq 0 ] && touch $lockfile + [ $RETVAL -eq 0 ] && echo_success + [ $RETVAL -ne 0 ] && echo_failure + echo + return $RETVAL +} + +stop() { + echo -n "Stopping $prog: " + # We are forcing it to _only_ use -TERM as killproc could use + # -KILL which would result in BMC timer not being set properly + # and reboot the box. + killproc $prog -TERM + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile + return $RETVAL +} + +restart() { + stop + sleep 6 + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload|restart) + restart + ;; + condrestart) + if [ -f $lockfile ]; then + restart + fi + ;; + status) + status $prog + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|status|condrestart}" + exit 1 +esac diff --git a/watchdog.spec b/watchdog.spec new file mode 100644 index 0000000..a13730a --- /dev/null +++ b/watchdog.spec @@ -0,0 +1,130 @@ +Summary: Software and/or Hardware watchdog daemon +Name: watchdog +Version: 5.5 +Release: 2%{?dist} +License: GPL+ +Group: System Environment/Daemons + +URL: http://sourceforge.net/projects/watchdog/ +Source0: http://dl.sf.net/watchdog/watchdog-%{version}.tar.gz +Source1: watchdog.init +Source2: README.watchdog.ipmi +Source3: README.Fedora + +Patch0: %{name}-%{version}-cleanup.patch +Patch1: %{name}-%{version}-cleanup-nfs.patch + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +Requires(post): /sbin/chkconfig +Requires(postun): /sbin/chkconfig +Requires(post): /sbin/service +Requires(postun): /sbin/service + + +%description +The watchdog program can be used as a powerful software watchdog daemon +or may be alternately used with a hardware watchdog device such as the +IPMI hardware watchdog driver interface to a resident Baseboard +Management Controller (BMC). watchdog periodically writes to /dev/watchdog; +the interval between writes to /dev/watchdog is configurable through settings +in the watchdog sysconfig file. This configuration file is also used to +set the watchdog to be used as a hardware watchdog instead of its default +software watchdog operation. In either case, if the device is open but not +written to within the configured time period, the watchdog timer expiration +will trigger a machine reboot. When operating as a software watchdog, the +ability to reboot will depend on the state of the machine and interrupts. +When operating as a hardware watchdog, the machine will experience a hard +reset (or whatever action was configured to be taken upon watchdog timer +expiration) initiated by the BMC. + + +%prep +%setup -q -n %{name}-%{version} + +cp %{SOURCE2} . +cp %{SOURCE3} . + +%patch0 -p1 -b .cleanup +%patch1 -p1 -b .cleanup-nfs + +mv README README.orig +iconv -f ISO-8859-1 -t UTF-8 < README.orig > README + + +%build +%configure +make %{?_smp_mflags} + + +%install +rm -Rf ${RPM_BUILD_ROOT} +install -d -m0755 ${RPM_BUILD_ROOT}%{_sysconfdir} +make DESTDIR=${RPM_BUILD_ROOT} install +install -Dp -m0644 %{name}.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/watchdog +install -Dp -m0755 %{SOURCE1} ${RPM_BUILD_ROOT}%{_initrddir}/watchdog + +%clean +rm -Rf ${RPM_BUILD_ROOT} + + +%post +if [ $1 -eq 1 ]; then + /sbin/chkconfig --add %{name} +fi + + +%preun +if [ $1 -eq 0 ]; then + /sbin/service %{name} stop >/dev/null 2>&1 + /sbin/chkconfig --del %{name} +fi + + +%postun +if [ $1 -ge 1 ]; then + /sbin/service %{name} condrestart >/dev/null 2>&1 +fi + + +%files +%defattr(-, root, root, -) +%doc AUTHORS ChangeLog COPYING examples/ IAFA-PACKAGE NEWS README TODO README.watchdog.ipmi README.Fedora +%config(noreplace) %{_sysconfdir}/watchdog.conf +%config(noreplace) %{_sysconfdir}/sysconfig/watchdog +%{_sysconfdir}/rc.d/init.d/watchdog +%{_sbindir}/watchdog +%{_sbindir}/wd_keepalive +%{_mandir}/man5/watchdog.conf.5* +%{_mandir}/man8/watchdog.8* +%{_mandir}/man8/wd_keepalive.8* + + +%changelog +* Thu Mar 5 2009 Richard W.M. Jones - 5.5-2 +- Use '-' in defattr line instead of explicit file mode. + +* Thu Feb 26 2009 Richard W.M. Jones - 5.5-1 +- New upstream version 5.5. +- Prepared the package for Fedora review. + +* Mon Jun 11 2007 Lon Hohberger - 5.3.1-7 +- Rebuild for RHEL5 Update 1 - Resolves: 227401 + +* Wed May 30 2007 Konrad Rzeszutek - 5.3.1-6 +- Fixed the init script file. + +* Tue May 29 2007 Konrad Rzeszutek - 5.3.1-5 +- Fixed a compile warning in nfsmount_xdr file. + +* Wed May 23 2007 Konrad Rzeszutek - 5.3.1-4 +- Fixed rpmlint warnings. + +* Wed May 16 2007 Konrad Rzeszutek - 5.3.1-3 +- Changes to spec, init script and README file per Carol Hebert recommendation. + +* Thu Apr 19 2007 Konrad Rzeszutek - 5.3.1-2 +- Added README.watchdog.ipmi + +* Mon Apr 16 2007 Konrad Rzeszutek - 5.3.1-1 +- Initial copy.