diff options
Diffstat (limited to 'steuermann')
-rw-r--r-- | steuermann/config.py | 5 | ||||
-rw-r--r-- | steuermann/hosts.ini | 44 | ||||
-rw-r--r-- | steuermann/report.py | 81 | ||||
-rw-r--r-- | steuermann/run.py | 21 | ||||
-rw-r--r-- | steuermann/run_all.py | 12 |
5 files changed, 133 insertions, 30 deletions
diff --git a/steuermann/config.py b/steuermann/config.py new file mode 100644 index 0000000..c422dc2 --- /dev/null +++ b/steuermann/config.py @@ -0,0 +1,5 @@ +def open_db() : + import sqlite3 + return sqlite3.connect('/ssbwebv1/data2/steuermann/steuermann.sb') + +logdir = '/ssbwebv1/data2/steuermann/logs' diff --git a/steuermann/hosts.ini b/steuermann/hosts.ini index 61231df..c64e2aa 100644 --- a/steuermann/hosts.ini +++ b/steuermann/hosts.ini @@ -12,21 +12,41 @@ ; %(cmd)s - ; %(foo)s - if you include a foo= line ; -[arzach] -workdir=/arzach/data1/sienkiew +[linux:csh] +hostname=no_such_machine +run=[ 'ssh', '-q', '%(hostname)s', 'source .steuermann.%(hostname)s; cd %(workdir)s; hostname; %(script)s ' ] +workdir=/tmp -[thor] -workdir=/thor/data2/sienkiew -[herbert] -workdir=/herbert/data1/sienkiew +[rhe4-32] +hostname=herbert +like=linux:csh -[jwcalibdev] -workdir=/data1/sienkiew/ur_work +[rhe4-64] +hostname=thor +like=linux:csh + +[rhe5-64] +hostname=arzach +like=linux:csh + +[leopard] +hostname=bond +like=linux:csh + +[snow-leopard] +hostname=cadeau +like=linux:csh + + +[arzach] +hostname=arzach +like=linux:csh + +[thor] +hostname=thor +like=linux:csh -; There is a section [ALL] that is used with every machine name -[ALL] -run=[ 'ssh', '-q', '%(host)s', 'cd %(workdir)s; %(script)s' ] [host_a] run=[ 'sleep', '3' ] @@ -41,3 +61,5 @@ run=[ 'sleep', '3' ] run=[ 'sleep', '3' ] +; There is a section [ALL] that is used with every machine name +[ALL] diff --git a/steuermann/report.py b/steuermann/report.py index e1df5ce..e1d2971 100644 --- a/steuermann/report.py +++ b/steuermann/report.py @@ -5,10 +5,58 @@ Generate reports from the database import time import sys -import sqlite3 import pandokia.text_table as text_table import StringIO +# this will be reset by the cgi main program if we are in a real cgi +cginame = 'arf.cgi' + +# + +def info_callback_status( db, run, tablename, host, cmd ) : + c = db.cursor() + c.execute("SELECT status FROM status WHERE run = ? AND host = ? AND tablename = ? AND cmd = ?",( + run, host, tablename, cmd ) ) + status, = c.fetchone() + return status + +# + +def info_callback_gui( db, run, tablename, host, cmd ) : + c = db.cursor() + c.execute("SELECT status, start_time, end_time FROM status WHERE run = ? AND host = ? AND tablename = ? AND cmd = ?",( + run, host, tablename, cmd ) ) + x = c.fetchone() + if x is None : + return '' + status, start_time, end_time = x + if start_time is None : + start_time = '' + if end_time is None : + end_time = '' + + # t_result = '%s %s %s'%(status, start_time, end_time ) + t_result = status + + if status != '0' and status != 'N' : + status = '<font color=red>%s</font>'%status + + if status != 'N' and status != 'P' : + link = "<a href='%s?action=log&name=%s/%s:%s/%s'>*</a>"%(cginame, run, host, tablename, cmd ) + else : + link = '' + + # h_result = '%s %s %s %s'%(link, status, start_time, end_time) + h_result = '%s %s'%(link, status ) + + return ( t_result, h_result ) + +# + +def info_callback_debug_table_cell( db, run, tablename, cmd, host ) : + return '%s %s %s %s' % ( run, host, tablename, cmd ) + +# def get_table_list( db, run_name ) : c = db.cursor() @@ -17,39 +65,46 @@ def get_table_list( db, run_name ) : # table_list contains ( depth, tablename ) return table_list -def get_table( db, run_name, tablename, info_callback ) : +def get_table( db, run_name, tablename, info_callback, showdepth=0 ) : t = text_table.text_table() + t.set_html_table_attributes('border=1') - row = 0 - t.define_column('-') # the command name in column 0 + t.define_column('-',html=' ',showname='-') # the command name in column 0 + + if showdepth : + t.define_column('depth') c = db.cursor() c.execute("select distinct host from status where tablename = ? and run = ? order by host asc",(tablename, run_name)) for host, in c : t.define_column(host) - t.set_value(row, host, host) - c.execute("""select cmd, host, depth, status, start_time, end_time, notes from status where tablename = ? and run = ? order by depth, cmd asc """, ( tablename, run_name ) ) + row = -1 prev_cmd = None for x in c : cmd, host, depth, status, start_time, end_time, notes = x if cmd != prev_cmd : row = row + 1 t.set_value(row, 0, cmd) + t.set_value(row, 'depth', depth) prev_cmd = cmd - t.set_value( row, host, info_callback( tablename, cmd, host, status ) ) + + info = info_callback( db, run_name, tablename, host, cmd ) + if isinstance(info, tuple) : + t.set_value( row, host, text=info[0], html=info[1] ) + else : + t.set_value( row, host, info) t.pad() return t -def info_callback_status( tablename, cmd, host, status ) : - return status +# def report_text( db, run_name, info_callback = info_callback_status ) : @@ -68,6 +123,8 @@ def report_text( db, run_name, info_callback = info_callback_status ) : return s.getvalue() +# + def report_html( db, run_name, info_callback = info_callback_status, hlevel=1 ) : s = StringIO.StringIO() s.write('<h%d>%s</h%d>\n'%(hlevel,run_name,hlevel)) @@ -78,13 +135,15 @@ def report_html( db, run_name, info_callback = info_callback_status, hlevel=1 ) for depth, tablename in table_list : s.write('<h%d>%s</h%d>\n'%(hlevel,tablename,hlevel)) - t = get_table( db, run_name, tablename, info_callback ) + t = get_table( db, run_name, tablename, info_callback, showdepth=1 ) s.write(t.get_html()) return s.getvalue() +# def main() : - db = sqlite3.connect('sr.db') + import steuermann.config + db = steuermann.config.open_db() print report_html( db, 'arf2011-08-30 16:52:23.928381' ) if __name__ == '__main__' : diff --git a/steuermann/run.py b/steuermann/run.py index 6526e1a..f3e86b3 100644 --- a/steuermann/run.py +++ b/steuermann/run.py @@ -32,14 +32,15 @@ class runner(object): host_info = { } # dir where we write our logs - logdir = 'logs' + logdir = '' ##### # - def __init__( self, nodes ) : + def __init__( self, nodes, logdir ) : self.node_index = nodes self.load_host_info() + self.logdir = logdir ##### # start a process @@ -85,7 +86,7 @@ class runner(object): pass # create a name for the log file, but do not use / in the name - logfile_name = "%s/%s.log"%( logdir, node.name.replace('/','+') ) + logfile_name = "%s/%s.log"%( logdir, node.name.replace('/','.') ) # open the log file, write initial notes logfile=open(logfile_name,"w") @@ -197,8 +198,22 @@ class runner(object): if x == 'ALL' : continue + # start with a dict that contains what is in ALL d = all_dict.copy() + + # get what there is to know about host x self._host_get_names(cfg, x, d) + + # if it is like some other host, start over using ALL, then + # the LIKE host, then our own information + if 'like' in d : + like = d['like'] + d = all_dict.copy() + self._host_get_names(cfg, like, d) + self._host_get_names(cfg, x, d) + del d['like'] + + print x,d self.host_info[x] = d del cfg diff --git a/steuermann/run_all.py b/steuermann/run_all.py index 59797cb..d94cafa 100644 --- a/steuermann/run_all.py +++ b/steuermann/run_all.py @@ -5,7 +5,6 @@ run everything in a set of command files import time import sys -import sqlite3 import os.path import datetime @@ -13,6 +12,8 @@ import run import report import nodes +import steuermann.config + try : import readline @@ -39,8 +40,8 @@ def main() : di_nodes = nodes.read_file_list( sys.argv[2:] ) xnodes = di_nodes.node_index - run_name = 'arf' + str(datetime.datetime.now()) - db = sqlite3.connect('sr.db') + run_name = str(datetime.datetime.now()).replace(' ','_') + db = steuermann.config.open_db() register_database(db, run_name, xnodes) n = sys.argv[1] @@ -113,7 +114,7 @@ pre node show what must come before a node def run_interactive( xnodes, run_name, db) : - runner = run.runner( xnodes ) + runner = run.runner( xnodes, steuermann.config.logdir ) for x in xnodes : xnodes[x].finished = 0 @@ -329,6 +330,7 @@ def run_step( runner, xnodes, run_name, db ) : if not who_exited : break + print "SOMETHING EXITED",who_exited # yes, something exited - no sleep, and keep running no_sleep = 1 keep_running = 1 @@ -340,7 +342,7 @@ def run_step( runner, xnodes, run_name, db ) : db.execute("UPDATE status SET end_time = ?, status = ? WHERE ( run = ? AND host = ? AND tablename = ? AND cmd = ? )", ( str(datetime.datetime.now()), who_exited[1], run_name, x_host, x_table, x_cmd ) ) - + db.commit() runner.display_procs() |