Bill Peck wrote:
Hello,
Here are some simple patches to update anamon.py to support watching any
file and it also updates the pre_anamon snippet to report on bootup.
This plays into our bigger goal of making a lab in a box spin of
cobbler+fedora for install testing. This is step one, step two is to
cut a hole in the box.
_______________________________________________
cobbler mailing list
cobbler(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler
Correction, Step one would be to actually attach the patches! :-)
From 127bc95f8fb227bcf73542fb62aa688d1d07dd00 Mon Sep 17 00:00:00 2001
From: Bill Peck <bpeck(a)redhat.com>
Date: Sat, 10 Jan 2009 10:38:39 -0500
Subject: [PATCH] Allows anamon to be more flexible and monitor any files that you pass to
it.
This will be used for reporting files after boot.
---
aux/anamon.py | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/aux/anamon.py b/aux/anamon.py
index cf82d98..d65175b 100644
--- a/aux/anamon.py
+++ b/aux/anamon.py
@@ -175,15 +175,24 @@ def anamon_loop():
watchlist = [alog, slog, dump, scrlog, mod, llog, kcfg]
waitlist = [ilog, ilog2, ulog, ulog2]
+ if watchfiles:
+ watchlist = []
+ for watchfile in watchfiles:
+ if os.path.exists(watchfile):
+ watchfilebase = os.path.basename(watchfile)
+ watchlog = WatchedFile(watchfile, watchfilebase)
+ watchlist.append(watchlog)
+
while 1:
time.sleep(5)
- for watch in waitlist:
- if alog.seen("step installpackages$") or (sysimage.stable() and
watch.exists()):
- print "Adding %s to watch list" % watch.alias
- watchlist.append(watch)
- waitlist.remove(watch)
-
+ if not watchfiles:
+ for watch in waitlist:
+ if alog.seen("step installpackages$") or (sysimage.stable() and
watch.exists()):
+ print "Adding %s to watch list" % watch.alias
+ watchlist.append(watch)
+ waitlist.remove(watch)
+
for wf in watchlist:
wf.update()
@@ -193,6 +202,7 @@ server = ""
port = "80"
daemon = 1
debug = lambda x,**y: None
+watchfiles = []
n = 0
while n < len(sys.argv):
@@ -200,6 +210,9 @@ while n < len(sys.argv):
if arg == '--name':
n = n+1
name = sys.argv[n]
+ elif arg == '--watchfile':
+ n = n+1
+ watchfiles.append(sys.argv[n])
elif arg == '--server':
n = n+1
server = sys.argv[n]
--
1.6.0.6
From b35ff30f2d995dfd3cde03983d72ab916ecf5c1f Mon Sep 17 00:00:00 2001
From: Bill Peck <bpeck(a)redhat.com>
Date: Sat, 10 Jan 2009 11:00:54 -0500
Subject: [PATCH] Allow anamon to exit after one loop.
update anamon snippet to report boot.log on bootup.
---
aux/anamon.py | 5 +++++
snippets/pre_anamon | 15 +++++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/aux/anamon.py b/aux/anamon.py
index d65175b..cd1d4ef 100644
--- a/aux/anamon.py
+++ b/aux/anamon.py
@@ -195,6 +195,8 @@ def anamon_loop():
for wf in watchlist:
wf.update()
+ if exit:
+ break
# process args
name = ""
@@ -203,6 +205,7 @@ port = "80"
daemon = 1
debug = lambda x,**y: None
watchfiles = []
+exit = False
n = 0
while n < len(sys.argv):
@@ -213,6 +216,8 @@ while n < len(sys.argv):
elif arg == '--watchfile':
n = n+1
watchfiles.append(sys.argv[n])
+ elif arg == '--exit':
+ exit = True
elif arg == '--server':
n = n+1
server = sys.argv[n]
diff --git a/snippets/pre_anamon b/snippets/pre_anamon
index 2e16209..a6d60a0 100644
--- a/snippets/pre_anamon
+++ b/snippets/pre_anamon
@@ -2,4 +2,19 @@
cd /tmp
wget "http://$server/cobbler/aux/anamon.py"
python anamon.py --name "$name" --server "$server" --port
"$http_port"
+
+cat << __EOT__ > /etc/rc.anamon
+cd /tmp || exit 1
+wget "http://$server/cobbler/aux/anamon.py"
+./anamon.py --watchfile /var/log/boot.log --name "$name" --server
"$server" --port "$http_port" --exit --fg
+chmod a-x /etc/rc.anamon
+__EOT__
+
+chmod 755 /etc/rc.anamon
+
+cat << __EOT__ >> /etc/rc.local
+if [ -x "/etc/rc.anamon" ]; then
+ /etc/rc.anamon
+fi
+__EOT__
#end if
--
1.6.0.6