timestap watchdog output
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 16 Mar 2010 21:36:45 +0000 (21:36 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 16 Mar 2010 21:36:45 +0000 (21:36 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@187 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/lxc/lxc-watchdog.sh

index 7618217..ec16319 100755 (executable)
@@ -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"
 
 }