def do_main(args): """ It looks like it is possible to get an incomplet coverage of the set of time steps if you only get rate and brw_stats data for one OST. I should fix this in the base modules. """ fsrc = LMTConfig.process_configuration(args) sie = Timestamp.calc_sie(args.time) beginTimestamp = Timestamp.Timestamp(sie - 5) endTimestamp = Timestamp.Timestamp(sie) beginTimestamp.no_later_than(fsrc['conn']) endTimestamp.no_earlier_than(fsrc['conn']) if beginTimestamp.ts_id >= endTimestamp.ts_id: print "observation: failed to get time stamp range for %s" % args.time exit(1) Steps = TimeSteps.TimeSteps() Steps.getTimeSteps(beginTimestamp, endTimestamp, fsrc['conn']) bulk = Bulk.Bulk(fsrc['name']) bulk.getOSSs(fsrc['conn']) bulk.setSteps(Steps) bulk.getData() # FIXME # I am not handling masked values in the CPU data # Should be an easy fix bulk.getCPU() brwfs = BrwFS.BrwFS(fsrc['name']) brwfs.getOSSs(fsrc['conn']) # we'll query for all of them even when we only want one # because it make the processing more uniform brwfs.getBrwStats(fsrc['conn'], stat=args.stat) brwfs.getData(beginTimestamp, endTimestamp, stat=args.stat) return(bulk, brwfs)
def do_main(args): """ args.begin - (string) Gives the date in yyyy-mm-dd hh:mm:ss format. It will fill in todays year, month and day if left out. hh:mm:ss will default to 00:00:00 as portions are left out. end - (string) As above giving the end of the data to be gathered. file - (string) The h5lmt file to query plot - (string) The name of the file to which the graph should be saved. 'noplot' is allowed if you just want a report. verbose - (boolean) Turn on debugging output version - (boolean) print the version string and exit the ops versus time. """ fsFile = h5py.File(args.file, 'r') b_sie = Timestamp.calc_sie(args.begin) e_sie = Timestamp.calc_sie(args.end) return(b_sie, e_sie, fsFile)
def doMain(args): fsFile = h5py.File(args.file, 'r') fsStepsGroup = fsFile['FSStepsGroup'] fsStepsDataSet = fsStepsGroup['FSStepsDataSet'] day=fsStepsDataSet.attrs['day'] if args.begin is None: begin_str = "%s 00:00:00" % day else: begin_str = "%s %s" % (day, args.begin) if args.end is None: midnight_before = datetime.datetime.strptime(day, "%Y-%m-%d") midnight_after = midnight_before + datetime.timedelta(days=1) end_str = midnight_after.strftime("%Y-%m-%d 00:00:00") else: end_str = "%s %s" % (day, args.end) b_sie = Timestamp.calc_sie(begin_str) e_sie = Timestamp.calc_sie(end_str) return(b_sie, e_sie, fsFile)
def do_main(args): """ args.both - Add together the read and write rates for calculation config - (file) The lmtrc config file telling how to get to the DB cpu - (boolean) Do the CPU utilization calculations (always set this true) fs - (string) The dbname entry in the config file for the file system of interest. index - (int) The index of the file system of interest in the config file oss - (string) The hostname of the OSS to be analyzed. read - Caclulate for the read data rate seconds - (int) The length of time over which to average the observations. threshold - (int) Sound the alarm if the average exceeds this value. default - 40: GiB for rates, or pct. CPU utilization verbose - (boolean) Turn on debugging output version - (boolean) print the version string and exit write - Calculate for the write data rate """ fsrc = LMTConfig.process_configuration(args) bulk = Bulk.Bulk(fsrc['dbname']) if args.verbose == True: bulk.debug() bulk.getOSSs(fsrc['conn']) now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # Now we want to generate the begin/end pair for this day end_sie = Timestamp.calc_sie(now) # This will be upset by savings time changes begin_sie = end_sie - args.seconds args.begin = Timestamp.format_timestamp(begin_sie) args.end = Timestamp.format_timestamp(end_sie) (beginTimestamp, endTimestamp) = Timestamp.process_timestamps(args, fsrc) Steps = TimeSteps.TimeSteps() Steps.getTimeSteps(beginTimestamp, endTimestamp, fsrc['conn']) bulk.setSteps(Steps) if (bulk.Steps == None) or (bulk.Steps.steps() == 0): print "pyalarm.do_main(): Warning - No steps from FS %s" % bulk.name return(None) bulk.getData() if args.cpu == True: bulk.getCPU() return(bulk)
cursor = fsrc['conn'].cursor(MySQLdb.cursors.DictCursor) query = "select TS_ID,TIMESTAMP from TIMESTAMP_INFO where TIMESTAMP >= '" query += beginTimestamp.timestr query += "' and TIMESTAMP <= '" query += endTimestamp.timestr query += "'" cursor.execute (query) rows = cursor.fetchall() except MySQLdb.Error, e: cursor.close() print "Counter: Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) Series = Counter.Counter("random", "none") Steps = TimeSteps.TimeSteps() for row in rows: Steps.examine(row['TIMESTAMP'], Timestamp.calc_sie(row['TIMESTAMP']), row['TS_ID']) cursor.close() Steps.register() Series.setSteps(Steps) count = Steps.steps() data = np.random.random_sample(count) counter = 0 for i in range(count): try: sie = Steps.getSie(index=i) except: print "Counter: Out of range index" sys.exit(1) counter += data[i] if data[i] > 0.97: counter = 0
def do_main(args): """ args.begin - (string) Gives the date in yyyy-mm-dd hh:mm:ss format. It will fill in todays year, month and day if left out. hh:mm:ss will default to 00:00:00 as portions are left out. config - (file) The lmtrc config file telling how to get to the DB end - (string) As above giving the end of the data to be gathered. fs - (string) The dbname entry in the config file for the file system of interest. index - (int) The index of the file system of interest in the config file plot - (string) The name of the file to which the graph should be saved. 'noplot' is allowed if you just want a report. progress - Print the name of each OST as you work through the list report - (boolean) Print out summary info about the analyzed operations read - Plot read data rate stat - Show histograms only for this statistic verbose - (boolean) Turn on debugging output version - (boolean) print the version string and exit write - Plot the write rate """ # do_main will: # - process_configuration # - get the oss in question # - get the OSTs on it # - Process timestamps # - get the data # - return the oss bins = None if args.stat == "BRW_IOSIZE": bins = np.array([4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) fsrc = LMTConfig.process_configuration(args) sie = Timestamp.calc_sie(args.begin) beginTimestamp = Timestamp.Timestamp(sie) endTimestamp = Timestamp.Timestamp(sie + 5) beginTimestamp.no_later_than(fsrc['conn']) endTimestamp.no_earlier_than(fsrc['conn']) if beginTimestamp.ts_id >= endTimestamp.ts_id: print "observation: failed to get time stamp range for %s" % args.time exit(1) brwBegin = BrwFS.BrwFS(fsrc['dbname']) brwBegin.getOSSs(fsrc['conn']) if args.verbose == True: brwBegin.debug() brwBegin.debug(module="BrwFS") #oss.debug(module="Timestamp") Steps = TimeSteps.TimeSteps() Steps.getTimeSteps(beginTimestamp, endTimestamp, fsrc['conn']) brwBegin.setSteps(Steps) brwBegin.getBrwStats(conn=fsrc['conn'], stat=args.stat, bins=bins) brwBegin.getDataSlice(stat=args.stat) if (brwBegin.Bins is None) or (len(brwBegin.Bins) == 0): print "test_BrwFS: Warning - No HistBins objects from OSS %s" % oss.name return if (brwBegin.Steps is None) or (brwBegin.Steps.steps() == 0): print "test_BrwFS: Warning - No steps from OSS %s" % oss.name return sie = Timestamp.calc_sie(args.end) beginTimestamp = Timestamp.Timestamp(sie) endTimestamp = Timestamp.Timestamp(sie + 5) beginTimestamp.no_later_than(fsrc['conn']) endTimestamp.no_earlier_than(fsrc['conn']) if beginTimestamp.ts_id >= endTimestamp.ts_id: print "observation: failed to get time stamp range for %s" % args.time return(None) brwEnd = BrwFS.BrwFS(fsrc['dbname']) brwEnd.getOSSs(fsrc['conn']) if args.verbose == True: brwEnd.debug() brwEnd.debug(module="BrwFS") #oss.debug(module="Timestamp") Steps = TimeSteps.TimeSteps() Steps.getTimeSteps(beginTimestamp, endTimestamp, fsrc['conn']) brwEnd.setSteps(Steps) brwEnd.getBrwStats(conn=fsrc['conn'], stat=args.stat, bins=bins) brwEnd.getDataSlice(stat=args.stat) if (brwEnd.Bins is None) or (len(brwEnd.Bins) == 0): print "test_BrwFS: Warning - No HistBins objects from OSS %s" % oss.name return if (brwEnd.Steps is None) or (brwEnd.Steps.steps() == 0): print "test_BrwFS: Warning - No steps from OSS %s" % oss.name return return(brwBegin, brwEnd)
def doMain(args): fsFile = h5py.File(args.file, 'r') b_sie = Timestamp.calc_sie(args.begin) e_sie = Timestamp.calc_sie(args.end) return(b_sie, e_sie, fsFile)
-e <end> Ending time stamp -f <fs> The dbname for this filesystem in the lmtrc -h A help message -i <index> Index of the file system entry in the the config file -v Print debug messages -V Print the version and exit Rudimentary test for the TimeSteps module. """ args = process_args(main=True) fsrc = LMTConfig.process_configuration(args) if args.end == None: endTimestamp = Timestamp.Timestamp() else: endTimestamp = Timestamp.Timestamp(Timestamp.calc_sie(args.end)) if args.verbose == True: endTimestamp.debug() endTimestamp.no_later_than(fsrc['conn']) if args.begin == None: beginTimestamp = Timestamp.Timestamp(endTimestamp.sie - 600) else: beginTimestamp = Timestamp.Timestamp(Timestamp.calc_sie(args.begin)) if args.verbose == True: beginTimestamp.debug() beginTimestamp.no_earlier_than(fsrc['conn']) try: cursor = fsrc['conn'].cursor(MySQLdb.cursors.DictCursor) query = "select TS_ID,TIMESTAMP from TIMESTAMP_INFO where TIMESTAMP >= '" query += beginTimestamp.timestr query += "' and TIMESTAMP <= '"