- Timestamp:
- Mar 13, 2012, 10:08:18 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/metrics.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/metrics.py
r33351 r33494 10 10 from czardb import CzarDb 11 11 from gpc1db import Gpc1Db 12 from plot import Plot 12 13 13 14 ''' … … 27 28 self.czarDb = CzarDb(self.logger, self.config) 28 29 self.gpc1Db = Gpc1Db(self.logger, self.config) 30 self.plot = Plot(self.logger, self.config, self.ippToPspsDb) 29 31 30 32 ''' … … 43 45 44 46 self.logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 45 self.logger.info("|Type| batches per hour | last 24 hours | per day this week | total detections| last published |")47 self.logger.info("|Type| batches per hour | last 24 hours | per day this week | detections/batch | last published |") 46 48 self.logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 47 49 rateP2 = self.printStats("P2") … … 73 75 74 76 self.checkClientStatus() 77 78 # create a density plot of pending stuff for czartool 79 self.plot.createDensityPlot("P2", True) 80 self.plot.createDensityPlot("ST", True) 81 75 82 if not self.waitForPollTime(): break 76 83 … … 89 96 90 97 # get a master list of IDs in DVO for this batch type 91 #allIDs = self.gpc1Db.getIDsInThisDVODbForThisStage(self.config.dvoLabel, batchType, self.config.minRa, self.config.maxRa, self.config.minDec, self.config.maxDec) 92 allIDs = self.gpc1Db.getIDsInThisDVODbForThisStage(self.config.dvoLabel, batchType) 98 rows = self.gpc1Db.getItemsInThisDVODbForThisStage(self.config.dvoLabel, 99 batchType, 100 self.config.minRa, 101 self.config.maxRa, 102 self.config.minDec, 103 self.config.maxDec) 104 105 # we only want to IDs 106 allIDs = [] 107 for row in rows: 108 try: allIDs.append(row[0]) 109 except: pass 110 111 #allIDs = self.ippToPspsDb.getPendingIdsForThisConfig(self.config.name) 112 93 113 prevList = allIDs 94 114 numEverything = len(allIDs) … … 97 117 98 118 tempFilename = batchType + '.dat' 99 DATFILE = open(tempFilename,'w')100 print >> DATFILE, "DVO", numEverything, 0, 0101 119 for stage in stages: 102 120 … … 114 132 # for n in fail: print n 115 133 116 str = "\033[1;34m%5s\033[1;m \033[1;32m%5s\033[1;m \033[1;31m%5s\033[1;m " % (self.getIntAsString(numPending), self.getIntAsString(numSuccess), self.getIntAsString(numFail)) 134 str = "\033[1;34m%5s\033[1;m \033[1;32m%5s\033[1;m \033[1;31m%5s\033[1;m " % ( 135 self.getIntAsString(numPending), 136 self.getIntAsString(numSuccess), 137 self.getIntAsString(numFail)) 117 138 sys.stdout.write("|%-19s" % str) 118 139 119 140 prevList = success 120 print >> DATFILE, stage, numSuccess, numFail, numPending121 141 122 142 self.czarDb.insertStats(stage, self.config.dvoLabel, batchType, numPending, numSuccess, numFail) … … 125 145 126 146 sys.stdout.write("|\n") 127 DATFILE.close()128 147 129 148 return numPendingProcessed … … 137 156 for i in range(0, colCount): sys.stdout.write("+-------------------") 138 157 sys.stdout.write("+\n") 139 158 159 ''' 160 Safe divide function 161 ''' 162 def divide(self, num, denom): 163 if denom == 0: return 0 164 else: return num / denom 165 140 166 ''' 141 167 Prints various timing stats for this batch type … … 143 169 def printStats(self, batchType): 144 170 145 rate = self.ippToPspsDb.countBatchesInLastPeriod(batchType, self.config.epoch, self.config.dvoLabel, "1 HOUR") / 1.0 146 171 rate = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "1 HOUR") / 1.0 172 173 174 batchesInLast24Hours = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "24 HOUR") 175 detectionsInLast24Hours = self.ippToPspsDb.getTotalDetectionsPublished(batchType, self.config.epoch, self.config.dvoLabel, "24 HOUR") 176 147 177 self.logger.info("| %2s | %16.1f | %13d | %17.1f | %16d | %14s |" % 148 178 (batchType, 149 179 rate, 150 self.ippToPspsDb.countBatchesInLastPeriod(batchType, self.config.epoch, self.config.dvoLabel, "24 HOUR"),151 self.ippToPspsDb.countBatches InLastPeriod(batchType, self.config.epoch, self.config.dvoLabel, "1 WEEK") / 7.0,152 self. ippToPspsDb.getTotalDetectionsPublished(batchType, self.config.epoch, self.config.dvoLabel),180 batchesInLast24Hours, 181 self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "1 WEEK") / 7.0, 182 self.divide(detectionsInLast24Hours, batchesInLast24Hours), 153 183 self.ippToPspsDb.getTimeOfLastBatchPublished(batchType, self.config.epoch, self.config.dvoLabel))) 154 184 … … 160 190 ''' 161 191 def printUsage(self): 162 super(Metrics, self).printUsage() 163 print " [hours]" 192 super(Metrics, self).printUsage("[<hours>]") 164 193 165 194
Note:
See TracChangeset
for help on using the changeset viewer.
