summaryrefslogtreecommitdiff
path: root/job-times
diff options
context:
space:
mode:
Diffstat (limited to 'job-times')
-rwxr-xr-xjob-times26
1 files changed, 26 insertions, 0 deletions
diff --git a/job-times b/job-times
new file mode 100755
index 0000000..7cd4b35
--- /dev/null
+++ b/job-times
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import cliapp
+import time
+
+class ListJobTimes(cliapp.Application):
+
+ def process_input_line(self, filename, line):
+ words = line.split()
+ if len(words) < 6 or words[2] != 'INFO':
+ pass
+ elif words[3] == 'Starting' and words[4] == 'job':
+ self.started = self.parse_time(words[0], words[1])
+ self.jobid = words[5]
+ elif words[3] == 'Finished' and words[4] == 'job':
+ ended = self.parse_time(words[0], words[1])
+ self.output.write('%.1f %s\n' % (ended - self.started, self.jobid))
+ self.started = None
+ self.jobid = None
+
+ def parse_time(self, dt, tm):
+ t = time.strptime('%s %s' % (dt, tm), '%Y-%m-%d %H:%M:%S')
+ return time.mktime(t)
+
+ListJobTimes().run()
+