From ef7919b17c638b4c1a259a8ea1e38f783266beb0 Mon Sep 17 00:00:00 2001
From: Per Cederqvist <ceder@lysator.liu.se>
Date: Mon, 30 Oct 2006 18:23:42 +0000
Subject: [PATCH] Print status.

* lysrdiff-status: New file.  Print some status information about the
  backup system.
---
 ChangeLog       |  7 +++++++
 lysrdiff-status | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100755 lysrdiff-status

diff --git a/ChangeLog b/ChangeLog
index 8a0ad4e..1d135a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-10-30  Per Cederqvist  <ceder@sedesopim.lysator.liu.se>
+
+	Print status.
+
+	* lysrdiff-status: New file.  Print some status information about
+	the backup system.
+
 2006-10-25  Per Cederqvist  <ceder@sedesopim.lysator.liu.se>
 	
 	Randomize new jobs.
diff --git a/lysrdiff-status b/lysrdiff-status
new file mode 100755
index 0000000..00039be
--- /dev/null
+++ b/lysrdiff-status
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+df -hl /lysrdiff/*/perm/lysrdiff
+echo
+
+statecache=/tmp/cached-state
+
+for part in /lysrdiff/*/perm/lysrdiff
+do
+  partno=`echo $part|sed 's%/lysrdiff/\([0-9]*\)/perm/lysrdiff%\1%'`
+  find $part/state -type f -printf "  %TY-%Tm-%Td %TH:%TM:%TS $partno %P\n" \
+      | sort > $statecache.$partno.$$
+  mv -f $statecache.$partno.$$ $statecache-$partno
+  echo -n $partno':'
+  echo -n ' 'Tasks: `wc -l < $part/tasks`
+  echo -n ' 'Fresh: `find $part/state -name \*-start -ctime 0 -print|wc -l`
+  echo -n ' '1day: `find $part/state -name \*-start -ctime 1 -print|wc -l`
+  echo -n ' 'Stale: `find $part/state -name \*-start -ctime +1 -print|wc -l`
+  echo -n ' 'Tot: `ls $part/state/*-end|wc -l`
+  echo ' 'Err: `ls $part/state/*-fail 2>/dev/null|wc -l`
+done
+echo
+
+echo Failures:
+echo
+grep -h -- '-fail$' $statecache-* | sort
+echo
+echo Top 5 most stale backups:
+echo
+grep -h -- '-start$' $statecache-* | sort | head -5
+echo
+echo All unfinished backup attempts:
+echo
+grep -h -- '-attempt$' $statecache-* | sort | head -5
-- 
GitLab