Parse reset status from daisydog output

Instead of parsing the kernel logs (which is fragile and may change
between platforms and/or kernel versions), just use the output of
daisydog -c to check the reset status.

BUG=chrome-os-partner:28558
TEST=Watchdog events are now reported on Nyan

Change-Id: I38aaa42cafc99f58aeeb74b26d78dfdec96d27d6
Reviewed-on: https://chromium-review.googlesource.com/198271
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
diff --git a/daisydog.conf b/daisydog.conf
index dba1ea2..6f1bede 100644
--- a/daisydog.conf
+++ b/daisydog.conf
@@ -9,19 +9,14 @@
 stop on stopping boot-services
 respawn
 
-pre-start script
-  # Depending on kernel output strings is fragile. :/
-  # Could monitor daisydog output instead?
-  # Only better since this conf file is part of daisydog ebuild.
-  #
-  # First message (Watchdog timed out) is from 3.4 kernel
-  # Second message (Last reset was...) is from 3.8 kernel
+env wdt_cmd="/sbin/minijail0 -u watchdog -g watchdog -- /usr/sbin/daisydog"
 
-  MSG1="Watchdog timed out"
-  MSG2="Last reset was system watchdog timer reset"
-  if dmesg | fgrep -q -e "${MSG1}" -e "${MSG2}" ; then
+pre-start script
+  # Run in "check" mode to determine if the last reset was because
+  # of a watchdog timeout.
+  if ${wdt_cmd} -c | grep -Fq "watchdog-timeout"; then
     metrics_client -v HwWatchdogReboot
   fi
 end script
 
-exec chrt -r 99 /sbin/minijail0 -u watchdog -g watchdog -- /usr/sbin/daisydog
+exec chrt -r 99 ${wdt_cmd}