Whamcloud - gitweb
Update based on lustre-iokit-20051107.tar.gz from the customer download area.
[fs/lustre-release.git] / lustre-iokit / obdsurvey / lustre_obdsurvey.py
1 #!/usr/bin/python2
2 """
3 Run the application with "--help" for documentation of how to run 
4 it as an application.
5
6 Copyright (c) 2005 Scali AS. All Rights Reserved.
7 """
8
9 import logging
10 import string
11 import lustre_obdsurveylib
12 try:
13     import optparse
14 except ImportError:
15     # Compability with older python-distributions:
16     import optik as optparse
17
18
19
20 def main():
21     parser = optparse.OptionParser(version="%prog 1.0", usage="%prog <--diskio | --network | --networkdiskio> <targetlist>")
22     parser.add_option("--pagesize", type="int", default=4, help="Set the pagesize (KB)")
23     parser.add_option("--size", type="int", default=100, help="Set the dataset-size (MB)")
24     parser.add_option("--minrecordsize", type="int", default=1024, help="Minimum record size (KB)")
25     parser.add_option("--maxrecordsize", type="int", default=1024, help="Maximum record size (KB)")
26     parser.add_option("--minthreads", type="int", default=1, help="Minimum number of threads")
27     parser.add_option("--maxthreads", type="int", default=16, help="Maximum number of threads")
28     parser.add_option("--diskio", action="store_const", const="diskio", dest="mode", 
29         help="Test local IO-performance on a set of OSTs. List OSTs as a space-seperated list of node:ostname.")
30     parser.add_option("--networkio", action="store_const", const="networkio", dest="mode",
31         help="Test network-performance. List network-connections as a space-seperated list of server:client pairs.")
32     parser.add_option("--networkdiskio", action="store_const", const="networkdiskio", dest="mode",
33         help="Test IO-performance over network. Assumes existing OSC-devices. List OSCs as a space-seperated list of"
34             "node:oscname pairs.")
35     (options, args) = parser.parse_args()
36     args = map(lambda arg: tuple(string.split(arg, ":")), args)
37     # Set up lustre-devices according to mode:
38     clients = []
39     if options.mode == "diskio":
40         for node, device in args:
41             obdfilter = lustre_obdsurveylib.ExistingOBDFilter(node, device)
42             echo_client = lustre_obdsurveylib.EchoClient(node, device+"_client", obdfilter)
43             clients.append(echo_client)
44     elif options.mode == "networkio":
45         for servername, clientname in args:
46             obdecho = lustre_obdsurveylib.OBDEcho(servername, "test_obdecho")
47             osc = lustre_obdsurveylib.OSC(clientname, "test_osc", obdecho)
48             echo_client = lustre_obdsurveylib.EchoClient(clientname, "test_client", osc)
49             clients.append(echo_client)
50     elif options.mode == "networkdiskio":
51         for clientname, oscname in args:
52             osc = lustre_obdsurveylib.ExistingOSC(clientname, oscname)
53             echo_client = lustre_obdsurveylib.EchoClient(clientname, oscname+"_client", osc)
54             clients.append(echo_client)
55     else:
56         parser.error("You need to specify either --diskio, --networkio or --networkdiskio")
57     rsz = options.minrecordsize
58     while rsz <= options.maxrecordsize:
59         threads = options.minthreads
60         while threads <= options.maxthreads:
61             results = lustre_obdsurveylib.ParallelTestBRW(clients, threads, options.size, ('w', 'r'), rsz, options.pagesize)
62             print "ost %2d sz %7dK rsz %4d thr %2d" % (len(clients), results[0].getTotalSize(), rsz, threads),
63             for result in results:
64                 try:
65                     result.verifyExitCodes()
66                 except:
67                     print "%30s" % "ERROR",
68                 else:
69                     print "%s %8.2f [%8.2f,%8.2f]" % (result.getTestType(), result.getTotalBandwidth(), result.getMinBandwidth(), result.getMaxBandwidth()), 
70             print
71             threads *= 2
72         rsz *= 2
73         
74     
75 if __name__ == '__main__':
76     log = logging.getLogger()
77     log.addHandler(logging.StreamHandler())
78     log.setLevel(logging.INFO)
79     main()