From: Dobrica Pavlinusic Date: Tue, 16 Mar 2010 21:36:45 +0000 (+0000) Subject: timestap watchdog output X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=d130ee8a7bac75db7560f4c78098ba6faed1e136;p=sysadmin-cookbook timestap watchdog output git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@187 191e9f34-6774-4a6d-acfc-7664dacd4a2a --- diff --git a/recepies/lxc/lxc-watchdog.sh b/recepies/lxc/lxc-watchdog.sh index 7618217..ec16319 100755 --- a/recepies/lxc/lxc-watchdog.sh +++ b/recepies/lxc/lxc-watchdog.sh @@ -105,6 +105,10 @@ lxc_start() { fi } +lxc_log() { + echo `date +%Y-%m-%dT%H:%M:%S` $* +} + lxc_watchdog() { name=$1 rootfs=$(lxc_rootfs $1) @@ -116,20 +120,20 @@ while true; do if [ "$tasks" -eq 1 ]; then runlevel="$(runlevel ${vps_utmp})" - echo `date +%Y-%m-%dT%H:%M:%S` "$name runlevel $runlevel" + lxc_log "$name runlevel $runlevel" case $runlevel in N*) # nothing for new boot state ;; ??0) - echo "$name halt" + lxc_log "$name halt" lxc-stop -n "${name}" lxc-wait -n ${name} -s STOPPED break ;; ??6) - echo "$name reboot"; + lxc_log "$name reboot"; lxc-stop -n ${name} lxc-wait -n ${name} -s STOPPED lxc-start -d -n ${name} -o /tmp/${name}.log @@ -141,14 +145,14 @@ while true; do ;; esac else - echo "# $name $tasks tasks" + lxc_log "$name $tasks tasks" fi # time of 5 minutes on it JUST IN CASE... inotifywait -qqt 300 ${vps_utmp} done -echo "${name} exited" +lxc_log "$name exited" }