[CalendarServer-changes] [4934] CalendarServer/branches/users/wsanchez/deployment/bin/caldav_watch
source_changes at macosforge.org
source_changes at macosforge.org
Sun Jan 17 14:25:13 PST 2010
Revision: 4934
http://trac.macosforge.org/projects/calendarserver/changeset/4934
Author: sagen at apple.com
Date: 2010-01-17 14:25:09 -0800 (Sun, 17 Jan 2010)
Log Message:
-----------
caldav_watch now creates a datestamp'd directory and stores dtruss and sample output there, along with request inspection history.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/deployment/bin/caldav_watch
Modified: CalendarServer/branches/users/wsanchez/deployment/bin/caldav_watch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/bin/caldav_watch 2010-01-16 02:32:41 UTC (rev 4933)
+++ CalendarServer/branches/users/wsanchez/deployment/bin/caldav_watch 2010-01-17 22:25:09 UTC (rev 4934)
@@ -16,13 +16,13 @@
# limitations under the License.
##
-import sys
+import os, sys
from twisted.internet import reactor
from twisted.protocols.basic import LineReceiver
from twisted.internet.protocol import ClientFactory
from subprocess import Popen, PIPE, STDOUT
-import time
+import time, datetime
INACTIVITY_SECONDS = 60
@@ -45,10 +45,9 @@
print "Error determining PID from ID"
else:
print "Server process for ID %d is %d" % (self.id, pid)
- print "Running dtruss..."
- dtruss(pid)
- print "Running sample..."
- sample(pid)
+ dirname = capture(pid, self.history)
+ print "Data captured to:", dirname
+
self.later = reactor.callLater(INACTIVITY_SECONDS, self.inactivity)
print "--------------------------------------------------------------"
@@ -81,26 +80,39 @@
return int(pid)
return None
-def sample(pid):
- child = Popen(args=['/usr/bin/sample', str(pid)],
+def sample(pid, filename):
+ child = Popen(args=['/usr/bin/sample', str(pid), "-file", filename],
stdout=PIPE, stderr=STDOUT)
output, error = child.communicate()
- print output
-def dtruss(pid):
- filename = "/tmp/auto_dtrace_%d_%f.out" % (pid, time.time())
+def dtruss(pid, filename):
output = open(filename, "w")
try:
child = Popen(args=['/usr/bin/dtruss', '-p', str(pid)],
stdout=output, stderr=STDOUT)
time.sleep(5)
child.terminate()
- print "Dtrace of %d captured to %s" % (pid, filename)
except OSError, e:
print "Couldn't run dtruss:", e
finally:
output.close()
+def capture(pid, history):
+ now = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
+ dirname = os.path.join("/tmp", "caldav_watch_%s_%d" % (now, pid))
+ os.mkdir(dirname)
+ historyname = os.path.join(dirname, "history.out")
+ historyfile = open(historyname, "w")
+ for line in history:
+ line = line + "\n"
+ historyfile.write(line)
+ historyfile.close()
+ samplename = os.path.join(dirname, "sample.out")
+ sample(pid, samplename)
+ dtrussname = os.path.join(dirname, "dtruss.out")
+ dtruss(pid, dtrussname)
+ return dirname
+
def main():
for id in range(0, 75):
port = id + 10000
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100117/e6142044/attachment.html>
More information about the calendarserver-changes
mailing list