From 6c34ebb23c8e730186ac473ca0dd8aa599b66c40 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 30 Dec 2011 13:01:55 -0600
Subject: xymon: fix check for myth_mtc and add support for myth_orphan check.
 refs: #806

---
 abs/core/xymon/PKGBUILD              |  6 +--
 abs/core/xymon/hobbit-myth-orphan.sh | 86 +++++++++++++++++-------------------
 abs/core/xymon/hobbit_myth_data.py   |  2 +-
 3 files changed, 44 insertions(+), 50 deletions(-)

diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD
index 5a41fd9..d8b4b33 100644
--- a/abs/core/xymon/PKGBUILD
+++ b/abs/core/xymon/PKGBUILD
@@ -1,7 +1,7 @@
 pkgbase=xymon
 pkgname=(xymonserver xymonclient)
 pkgver=4.3.5
-pkgrel=30
+pkgrel=31
 pkgdesc="Hobbit is a system for monitoring servers and networks. "
 license="GPL"
 arch=('i686' 'x86_64')
@@ -119,7 +119,7 @@ md5sums=('31923ec126fe1c264fceb459d2175161'
          '650b523d879f32c1bad3b4a9e10e7c93'
          '093648dabb0d1da0fdcc37b327737f43'
          'cac3478de106d875ddbdaa377d26692d'
-         '6eb6ecdf33454f35b6c2409b863c816f'
+         '0f70e76a164f648f0a4a01110137cb20'
          'f6921f0413215ae174e81306be80d37f'
          'be02f5d21373f97224ffa4727ec9718a'
          'd210c43fb9ee9ad6cd7648e0c2e0efea'
@@ -128,7 +128,7 @@ md5sums=('31923ec126fe1c264fceb459d2175161'
          '0757294eec13771f8e63da23cf066796'
          '622f400fd098cbc43c203e3210a6694e'
          'd06c4327cc69aeead3fa05f39660f33e'
-         '129353c8ad92e89c691382a98dd5ce77'
+         'eb502ce1be9b658be74911b53832caa8'
          'f6ff1fb4bacee930007b877424619b30'
          'e06147db25d75cf246886137a4ea164a'
          '98e9242ae346f729b14cb195786571f2'
diff --git a/abs/core/xymon/hobbit-myth-orphan.sh b/abs/core/xymon/hobbit-myth-orphan.sh
index f9f7d54..5cba136 100644
--- a/abs/core/xymon/hobbit-myth-orphan.sh
+++ b/abs/core/xymon/hobbit-myth-orphan.sh
@@ -1,53 +1,47 @@
 #!/bin/bash
 TMPFILE=/tmp/oprhan.result
-/usr/local/bin/myth.find_orphans.pl > $TMPFILE
-
-
-   COLUMN=orphan    # Name of the column
-   COLOR=green      # By default, everything is OK
-
-   # Do whatever you need to test for something
-   # As an example, go red if /tmp/badstuff exists.
-
-thumbs=`grep -A 4 "Summary:" $TMPFILE  |tail -n 1  |  cut  -d" "   -f3 `
-if [ !  x$thumbs  = x0 ]
-then
-    MSG="$thumbs orphaned thumbnails with no corresponding recording"
-    COLOR='yellow'
-fi
-
-missing=`grep -A 2 "Summary:" $TMPFILE  |tail -n 1 | cut -d, -f2 | cut  -d" "  -f2 `
-if [ !  x$missing  = x0 ]
-then
-	COLOR='red'
-MSG="${MSG}
-   `grep -A 2 "Summary:" $TMPFILE  |tail -n 1 ` "
-fi
-
-unkown=`grep -A 5 "Summary:" $TMPFILE  |tail -n 1  |  cut  -d" "   -f3 `
-if [ !  x$unkown  = x0 ]
-then
-	COLOR='red'
-MSG="${MSG}
-`grep -A 5 "Summary:" $TMPFILE  |tail -n 1  `"
-fi
-
-
-MSG="${MSG}
-	
-
-	`cat $TMPFILE`
-	"
-
-   # Tell Hobbit about it
-   $BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`
-/usr/local/bin/myth.find_orphans.pl
-
+MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/find_orphans.py --printonly > $TMPFILE
+
+
+COLUMN=orphan    # Name of the column
+COLOR=green      # By default, everything is OK
+MSG="All OK"
+
+
+
+
+#yellow
+for i in "Orphaned video files" "Orphaned snapshots" "Database backups" "Other files"
+do
+   grep -q  "$i" $TMPFILE
+   status=$?
+   if [ $status -eq 0 ]
+   then
+       COLOR="yellow"
+       MSG="Problems found"
+   fi
+done
+
+#red
+for i in "Recordings with missing files" "Zero byte recordings"
+do
+   grep -q  "$i" $TMPFILE
+   status=$?
+   if [ $status -eq 0 ]
+   then
+       COLOR="red"
+       MSG="Problems found"
+   fi
+done
+
+MSG="
+    ${MSG}
+    `cat $TMPFILE` "
+# Tell Hobbit about it
+$BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`
    ${MSG}
-
    " 
-
-   exit 0
+exit 0
 
 
 
diff --git a/abs/core/xymon/hobbit_myth_data.py b/abs/core/xymon/hobbit_myth_data.py
index 840c293..1acca67 100644
--- a/abs/core/xymon/hobbit_myth_data.py
+++ b/abs/core/xymon/hobbit_myth_data.py
@@ -34,7 +34,7 @@ def check_mtc():
         for i in mtc:
            line=i
         infile.close()
-    if line.strip() == "Finished":
+    if line.split()[0] == "Finished":
         return True
     else:
         return False
-- 
cgit v0.12