stats.py revision 1772:a3a83e812a5e
1#!/usr/bin/env python 2 3# Copyright (c) 2003-2004 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer; 10# redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution; 13# neither the name of the copyright holders nor the names of its 14# contributors may be used to endorse or promote products derived from 15# this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29from __future__ import division 30import re, sys, math 31 32 33def usage(): 34 print '''\ 35Usage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p] 36 [-s <system>] [-r <runs> ] [-T <samples>] [-u <username>] 37 <command> [command args] 38 39 commands extra parameters description 40 ----------- ------------------ --------------------------------------- 41 bins [regex] List bins (only matching regex) 42 formula <formula> Evaluated formula specified 43 formulas [regex] List formulas (only matching regex) 44 runs none List all runs in database 45 samples none List samples present in database 46 stability <pairnum> <stats> Calculated statistical info about stats 47 stat <regex> Show stat data (only matching regex) 48 stats [regex] List all stats (only matching regex) 49 50 database <command> Where command is drop, init, or clean 51 52''' % sys.argv[0] 53 sys.exit(1) 54 55def getopts(list, flags): 56 import getopt 57 try: 58 opts, args = getopt.getopt(list, flags) 59 except getopt.GetoptError: 60 usage() 61 62 return opts, args 63 64def printval(name, value, invert = False): 65 if invert and value != 0.0: 66 value = 1 / value 67 68 if value == (1e300*1e300): 69 return 70 71 if printval.mode == 'G': 72 print '%s: %g' % (name, value) 73 elif printval.mode != 'F' and value > 1e6: 74 print '%s: %0.5e' % (name, value) 75 else: 76 print '%s: %f' % (name, value) 77 78printval.mode = 'G' 79 80def unique(list): 81 set = {} 82 map(set.__setitem__, list, []) 83 return set.keys() 84 85#benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ] 86 87def graphdata(runs, options, tag, label, value): 88 import info 89 90 bench_system = { 91 'm' : 'client', 92 's' : 'client', 93 'snt' : 'client', 94 'nb1' : 'server', 95 'nb2' : 'server', 96 'nt1' : 'server', 97 'nt2' : 'server', 98 'w1' : 'server', 99 'w2' : 'server', 100 'w3' : 'server', 101 'w4' : 'server', 102 'w1s' : 'server', 103 'w2s' : 'server', 104 'w3s' : 'server', 105 'ns' : 'natbox', 106 'nm' : 'natbox', 107 'nw1' : 'natbox', 108 'nw2' : 'natbox', 109 'nw3' : 'natbox' 110 } 111 112 system_configs = { 113 's1' : 'Uni 4GHz', 114 'm1' : 'Uni 6GHz', 115 'f1' : 'Uni 8GHz', 116 'q1' : 'Uni 10GHz', 117 's2' : 'Dual 4GHz', 118 'm2' : 'Dual 6GHz', 119 's4' : 'Quad 4GHz', 120 'm4' : 'Quad 6GHz' } 121 122 configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 123 benchmarks = [ 'm', 'snt', 'w2', 'nm', 'nw2' ] 124 caches = [ '0', '2', '4' ] 125 126 names = [] 127 for bench in benchmarks: 128 if bench_system[bench] != options.system: 129 continue 130 131 for cache in caches: 132 names.append([bench, cache]) 133 134 for bench,cache in names: 135 base = '%s.%s' % (bench, cache) 136 fname = 'data/uni.%s.%s.dat' % (tag, base) 137 f = open(fname, 'w') 138 print >>f, '#set TITLE = ' 139 print >>f, '#set ylbl = %s' % label 140 #print >>f, '#set sublabels = %s' % ' '.join(configs) 141 print >>f, '#set sublabels = ste hte htd ocm occ ocs' 142 143 for speed in ('s1', 'm1', 'f1', 'q1'): 144 label = system_configs[speed] 145 print >>f, '"%s"' % label, 146 for conf in configs: 147 name = '%s.%s.%s.%s' % (conf, bench, cache, speed) 148 run = info.source.allRunNames[name] 149 info.display_run = run.run; 150 val = float(value) 151 if val == 1e300*1e300: 152 print >>f, 0.0, 153 else: 154 print >>f, "%f" % val, 155 print >>f 156 f.close() 157 158 configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 159 benchmarks = [ 'w2'] 160 caches = [ '0', '2', '4' ] 161 162 names = [] 163 for bench in benchmarks: 164 if bench_system[bench] != options.system: 165 continue 166 167 for cache in caches: 168 names.append([bench, cache]) 169 170 for bench,cache in names: 171 base = '%s.%s' % (bench, cache) 172 fname = 'data/mp.%s.%s.dat' % (tag, base) 173 f = open(fname, 'w') 174 print >>f, '#set TITLE = ' 175 print >>f, '#set ylbl = %s' % label 176 #print >>f, '#set sublabels = %s' % ' '.join(configs) 177 print >>f, '#set sublabels = ste hte htd ocm occ ocs' 178 179 for speed in ('s2', 'm2', 's4', 'm4'): 180 label = system_configs[speed] 181 print >>f, '"%s"' % label, 182 for conf in configs: 183 name = '%s.%s.%s.%s' % (conf, bench, cache, speed) 184 run = info.source.allRunNames[name] 185 info.display_run = run.run; 186 val = float(value) 187 if val == 1e300*1e300: 188 print >>f, 0.0, 189 else: 190 print >>f, "%f" % val, 191 print >>f 192 f.close() 193 194def printdata(runs, value, invert = False): 195 import info 196 for run in runs: 197 info.display_run = run.run; 198 val = float(value) 199 printval(run.name, val) 200 201class CommandException(Exception): 202 pass 203 204def commands(options, command, args): 205 if command == 'database': 206 if len(args) == 0: raise CommandException 207 208 import dbinit 209 mydb = dbinit.MyDB(options) 210 211 if args[0] == 'drop': 212 if len(args) > 2: raise CommandException 213 mydb.admin() 214 mydb.drop() 215 if len(args) == 2 and args[1] == 'init': 216 mydb.create() 217 mydb.connect() 218 mydb.populate() 219 mydb.close() 220 return 221 222 if args[0] == 'init': 223 if len(args) > 1: raise CommandException 224 mydb.admin() 225 mydb.create() 226 mydb.connect() 227 mydb.populate() 228 mydb.close() 229 return 230 231 if args[0] == 'clean': 232 if len(args) > 1: raise CommandException 233 mydb.connect() 234 mydb.clean() 235 return 236 237 raise CommandException 238 239 import db, info 240 info.source = db.Database() 241 info.source.host = options.host 242 info.source.db = options.db 243 info.source.passwd = options.passwd 244 info.source.user = options.user 245 info.source.connect() 246 info.source.update_dict(globals()) 247 248 if type(options.get) is str: 249 info.source.get = options.get 250 251 if options.runs is None: 252 runs = info.source.allRuns 253 else: 254 rx = re.compile(options.runs) 255 runs = [] 256 for run in info.source.allRuns: 257 if rx.match(run.name): 258 runs.append(run) 259 260 info.display_run = runs[0].run 261 262 if command == 'runs': 263 user = None 264 opts, args = getopts(args, '-u') 265 if len(args): 266 raise CommandException 267 for o,a in opts: 268 if o == '-u': 269 user = a 270 info.source.listRuns(user) 271 return 272 273 if command == 'stability': 274 if len(args) < 2: 275 raise CommandException 276 277 try: 278 merge = int(args[0]) 279 except ValueError: 280 usage() 281 stats = info.source.getStat(args[1]) 282 info.source.get = "sum" 283 284 285 #loop through all the stats selected 286 for stat in stats: 287 288 print "%s:" % stat.name 289 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \ 290 ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP", "CV") 291 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \ 292 ("--------------------", "------------", 293 "------------", "----", "-----", "-----", "-----", "----------") 294 #loop through all the selected runs 295 for run in runs: 296 info.display_run = run.run; 297 runTicks = info.source.retTicks([ run ]) 298 #throw away the first one, it's 0 299 runTicks.pop(0) 300 info.globalTicks = runTicks 301 avg = 0 302 stdev = 0 303 numoutsideavg = 0 304 numoutside1std = 0 305 numoutside2std = 0 306 pairRunTicks = [] 307 if float(stat) == 1e300*1e300: 308 continue 309 for t in range(0, len(runTicks)-(merge-1), merge): 310 tempPair = [] 311 for p in range(0,merge): 312 tempPair.append(runTicks[t+p]) 313 pairRunTicks.append(tempPair) 314 #loop through all the various ticks for each run 315 for tick in pairRunTicks: 316 info.globalTicks = tick 317 avg += float(stat) 318 avg /= len(pairRunTicks) 319 for tick in pairRunTicks: 320 info.globalTicks = tick 321 val = float(stat) 322 stdev += pow((val-avg),2) 323 stdev = math.sqrt(stdev / len(pairRunTicks)) 324 for tick in pairRunTicks: 325 info.globalTicks = tick 326 val = float(stat) 327 if (val < (avg * .9)) or (val > (avg * 1.1)): 328 numoutsideavg += 1 329 if (val < (avg - stdev)) or (val > (avg + stdev)): 330 numoutside1std += 1 331 if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))): 332 numoutside2std += 1 333 if avg > 1000: 334 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \ 335 (run.name, "%.1f" % avg, "%.1f" % stdev, 336 "%d" % numoutsideavg, "%d" % numoutside1std, 337 "%d" % numoutside2std, "%d" % len(pairRunTicks), 338 "%.3f" % (stdev/avg*100)) 339 elif avg > 100: 340 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \ 341 (run.name, "%.1f" % avg, "%.1f" % stdev, 342 "%d" % numoutsideavg, "%d" % numoutside1std, 343 "%d" % numoutside2std, "%d" % len(pairRunTicks), 344 "%.5f" % (stdev/avg*100)) 345 else: 346 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \ 347 (run.name, "%.5f" % avg, "%.5f" % stdev, 348 "%d" % numoutsideavg, "%d" % numoutside1std, 349 "%d" % numoutside2std, "%d" % len(pairRunTicks), 350 "%.7f" % (stdev/avg*100)) 351 return 352 353 if command == 'stats': 354 if len(args) == 0: 355 info.source.listStats() 356 elif len(args) == 1: 357 info.source.listStats(args[0]) 358 else: 359 raise CommandException 360 361 return 362 363 if command == 'stat': 364 if len(args) != 1: 365 raise CommandException 366 367 stats = info.source.getStat(args[0]) 368 for stat in stats: 369 if options.graph: 370 graphdata(runs, options, stat.name, stat.name, stat) 371 else: 372 if options.ticks: 373 print 'only displaying sample %s' % options.ticks 374 info.globalTicks = [ int(x) for x in options.ticks.split() ] 375 376 if options.binned: 377 print 'kernel ticks' 378 stat.bins = 'kernel' 379 printdata(runs, stat) 380 381 print 'idle ticks' 382 stat.bins = 'idle' 383 printdata(runs, stat) 384 385 print 'user ticks' 386 stat.bins = 'user' 387 printdata(runs, stat) 388 389 print 'interrupt ticks' 390 stat.bins = 'interrupt' 391 printdata(runs, stat) 392 393 print 'total ticks' 394 395 stat.bins = None 396 print stat.name 397 printdata(runs, stat) 398 return 399 400 if command == 'formula': 401 if len(args) != 1: 402 raise CommandException 403 404 stats = eval(args[0]) 405 for stat in stats: 406 if options.graph: 407 graphdata(runs, options, stat.name, stat.name, stat) 408 else: 409 if options.binned: 410 print 'kernel ticks' 411 stat.bins = 'kernel' 412 printdata(runs, stat) 413 414 print 'idle ticks' 415 stat.bins = 'idle' 416 printdata(runs, stat) 417 418 print 'user ticks' 419 stat.bins = 'user' 420 printdata(runs, stat) 421 422 print 'interrupt ticks' 423 stat.bins = 'interrupt' 424 printdata(runs, stat) 425 426 print 'total ticks' 427 428 stat.bins = None 429 print args[0] 430 printdata(runs, stat) 431 return 432 433 if command == 'bins': 434 if len(args) == 0: 435 info.source.listBins() 436 elif len(args) == 1: 437 info.source.listBins(args[0]) 438 else: 439 raise CommandException 440 441 return 442 443 if command == 'formulas': 444 if len(args) == 0: 445 info.source.listFormulas() 446 elif len(args) == 1: 447 info.source.listFormulas(args[0]) 448 else: 449 raise CommandException 450 451 return 452 453 if command == 'samples': 454 if len(args): 455 raise CommandException 456 457 info.source.listTicks(runs) 458 return 459 460 if len(args): 461 raise CommandException 462 463 system = info.source.__dict__[options.system] 464 465 if command == 'usertime': 466 import copy 467 kernel = copy.copy(system.full0.numCycles) 468 kernel.bins = 'kernel' 469 470 user = copy.copy(system.full0.numCycles) 471 user.bins = 'user' 472 473 if options.graph: 474 graphdata(runs, options, 'usertime', 'User Fraction', 475 user / system.full0.numCycles) 476 else: 477 printdata(runs, user / system.full0.numCycles) 478 return 479 480 if command == 'ticks': 481 if options.binned: 482 print 'kernel ticks' 483 system.full0.numCycles.bins = 'kernel' 484 printdata(runs, system.full0.numCycles) 485 486 print 'idle ticks' 487 system.full0.numCycles.bins = 'idle' 488 printdata(runs, system.full0.numCycles) 489 490 print 'user ticks' 491 system.full0.numCycles.bins = 'user' 492 printdata(runs, system.full0.numCycles) 493 494 print 'total ticks' 495 496 system.full0.numCycles.bins = None 497 printdata(runs, system.full0.numCycles) 498 return 499 500 if command == 'packets': 501 packets = system.tsunami.etherdev0.rxPackets 502 if options.graph: 503 graphdata(runs, options, 'packets', 'Packets', packets) 504 else: 505 printdata(runs, packets) 506 return 507 508 if command == 'ppt' or command == 'tpp': 509 ppt = system.tsunami.etherdev0.rxPackets / sim_ticks 510 printdata(runs, ppt, command == 'tpp') 511 return 512 513 if command == 'pps': 514 pps = system.tsunami.etherdev0.rxPackets / sim_seconds 515 if options.graph: 516 graphdata(runs, options, 'pps', 'Packets/s', pps) 517 else: 518 printdata(runs, pps) 519 return 520 521 if command == 'bpt' or command == 'tpb': 522 bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes 523 bpt = bytes / sim_ticks * 8 524 if options.graph: 525 graphdata(runs, options, 'bpt', 'bps / Hz', bpt) 526 else: 527 printdata(runs, bpt, command == 'tpb') 528 return 529 530 if command == 'bptb' or command == 'tpbb': 531 bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes 532 533 print 'kernel stats' 534 bytes.bins = 'kernel' 535 printdata(runs, bytes / ticks) 536 537 print 'idle stats' 538 bytes.bins = 'idle' 539 printdata(runs, bytes / ticks) 540 541 print 'user stats' 542 bytes.bins = 'user' 543 printdata(runs, bytes / ticks) 544 545 return 546 547 if command == 'bytes': 548 stat = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes 549 550 if options.binned: 551 print '%s kernel stats' % stat.name 552 stat.bins = 'kernel' 553 printdata(runs, stat) 554 555 print '%s idle stats' % stat.name 556 stat.bins = 'idle' 557 printdata(runs, stat) 558 559 print '%s user stats' % stat.name 560 stat.bins = 'user' 561 printdata(runs, stat) 562 563 print '%s total stats' % stat.name 564 stat.bins = None 565 566 printdata(runs, stat) 567 return 568 569 if command == 'rxbps': 570 gbps = system.tsunami.etherdev0.rxBandwidth / 1e9 571 if options.graph: 572 graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)', gbps) 573 else: 574 printdata(runs, gbps) 575 return 576 577 if command == 'txbps': 578 gbps = system.tsunami.etherdev0.txBandwidth / 1e9 579 if options.graph: 580 graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)', gbps) 581 else: 582 printdata(runs, gbps) 583 return 584 585 if command == 'bps': 586 rxbps = system.tsunami.etherdev0.rxBandwidth 587 txbps = system.tsunami.etherdev0.txBandwidth 588 gbps = (rxbps + txbps) / 1e9 589 if options.graph: 590 graphdata(runs, options, 'bps', 'Bandwidth (Gbps)', gbps) 591 else: 592 printdata(runs, gbps) 593 return 594 595 if command == 'misses': 596 stat = system.l2.overall_mshr_misses 597 if options.binned: 598 print '%s kernel stats' % stat.name 599 stat.bins = 'kernel' 600 printdata(runs, stat) 601 602 print '%s idle stats' % stat.name 603 stat.bins = 'idle' 604 printdata(runs, stat) 605 606 print '%s user stats' % stat.name 607 stat.bins = 'user' 608 printdata(runs, stat) 609 610 print '%s total stats' % stat.name 611 612 stat.bins = None 613 if options.graph: 614 graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat) 615 else: 616 printdata(runs, stat) 617 return 618 619 if command == 'mpkb': 620 misses = system.l2.overall_mshr_misses 621 rxbytes = system.tsunami.etherdev0.rxBytes 622 txbytes = system.tsunami.etherdev0.txBytes 623 624 if options.binned: 625 print 'mpkb kernel stats' 626 misses.bins = 'kernel' 627 mpkb = misses / ((rxbytes + txbytes) / 1024) 628 printdata(runs, mpkb) 629 630 print 'mpkb idle stats' 631 misses.bins = 'idle' 632 mpkb = misses / ((rxbytes + txbytes) / 1024) 633 printdata(runs, mpkb) 634 635 print 'mpkb user stats' 636 misses.bins = 'user' 637 mpkb = misses / ((rxbytes + txbytes) / 1024) 638 printdata(runs, mpkb) 639 640 print 'mpkb total stats' 641 642 mpkb = misses / ((rxbytes + txbytes) / 1024) 643 misses.bins = None 644 if options.graph: 645 graphdata(runs, options, 'mpkb', 'Misses / KB', mpkb) 646 else: 647 printdata(runs, mpkb) 648 return 649 650 if command == 'ipkb': 651 interrupts = system.full0.kern.faults[4] 652 rxbytes = system.tsunami.etherdev0.rxBytes 653 txbytes = system.tsunami.etherdev0.txBytes 654 655 if options.binned: 656 print 'ipkb kernel stats' 657 interrupts.bins = 'kernel' 658 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 659 printdata(runs, ipkb) 660 661 print 'ipkb idle stats' 662 interrupts.bins = 'idle' 663 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 664 printdata(runs, ipkb) 665 666 print 'ipkb user stats' 667 interrupts.bins = 'user' 668 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 669 printdata(runs, ipkb) 670 671 print 'ipkb total stats' 672 673 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 674 interrupts.bins = None 675 if options.graph: 676 graphdata(runs, options, 'ipkb', 'Interrupts / KB', ipkb) 677 else: 678 printdata(runs, ipkb) 679 return 680 681 if command == 'execute': 682 printdata(runs, system.full0.ISSUE__count) 683 return 684 685 if command == 'commit': 686 printdata(runs, system.full0.COM__count) 687 return 688 689 if command == 'fetch': 690 printdata(runs, system.full0.FETCH__count) 691 return 692 693 if command == 'bpp': 694 ed = system.tsunami.etherdev0 695 bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets) 696 if options.graph: 697 graphdata(runs, options, 'bpp', 'Bytes / Packet', bpp) 698 else: 699 printdata(runs, bpp) 700 return 701 702 if command == 'rxbpp': 703 bpp = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.rxPackets 704 if options.graph: 705 graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet', bpp) 706 else: 707 printdata(runs, bpp) 708 return 709 710 if command == 'txbpp': 711 bpp = system.tsunami.etherdev0.txBytes / system.tsunami.etherdev0.txPackets 712 if options.graph: 713 graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet', bpp) 714 else: 715 printdata(runs, bpp) 716 return 717 718 if command == 'rtp': 719 rtp = system.tsunami.etherdev0.rxPackets / system.tsunami.etherdev0.txPackets 720 if options.graph: 721 graphdata(runs, options, 'rtp', 'rxPackets / txPackets', rtp) 722 else: 723 printdata(runs, rtp) 724 return 725 726 if command == 'rtb': 727 rtb = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.txBytes 728 if options.graph: 729 graphdata(runs, options, 'rtb', 'rxBytes / txBytes', rtb) 730 else: 731 printdata(runs, rtb) 732 return 733 734 raise CommandException 735 736 737class Options: pass 738 739if __name__ == '__main__': 740 import getpass 741 742 options = Options() 743 options.host = 'zizzer.pool' 744 options.db = None 745 options.passwd = '' 746 options.user = getpass.getuser() 747 options.runs = None 748 options.system = 'client' 749 options.get = None 750 options.binned = False 751 options.graph = False 752 options.ticks = False 753 754 opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:') 755 for o,a in opts: 756 if o == '-B': 757 options.binned = True 758 if o == '-E': 759 printval.mode = 'E' 760 if o == '-F': 761 printval.mode = 'F' 762 if o == '-G': 763 options.graph = True; 764 if o == '-d': 765 options.db = a 766 if o == '-g': 767 options.get = a 768 if o == '-h': 769 options.host = a 770 if o == '-p': 771 options.passwd = getpass.getpass() 772 if o == '-r': 773 options.runs = a 774 if o == '-u': 775 options.user = a 776 if o == '-s': 777 options.system = a 778 if o == '-T': 779 options.ticks = a 780 781 if len(args) == 0: 782 usage() 783 784 command = args[0] 785 args = args[1:] 786 787 try: 788 commands(options, command, args) 789 except CommandException: 790 usage() 791