Changeset 20 for trunk/daemon/togad.py
- Timestamp:
- 03/23/05 15:40:45 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/togad.py
r19 r20 105 105 # Determine time here, so all use same time in this run 106 106 mytime = self.rrd.makeTimeSerial() 107 108 self.storeMetrics( self.hostName, mytime ) 107 correct_serial = self.rrd.checkNewRrdPeriod( self.hostName, mytime ) 108 109 self.storeMetrics( self.hostName, correct_serial ) 109 110 110 111 #if name == 'METRIC': … … 282 283 return mytime 283 284 284 def makeRrdPath( self, host, metric, timeserial='notime' ): 285 286 rrd_dir = '%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host ) 287 rrd_file = '%s/%s.%s.rrd' %( rrd_dir, metric['name'], timeserial ) 285 def makeRrdPath( self, host, metric=None, timeserial=None ): 286 287 if not timeserial: 288 rrd_dir = '%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host ) 289 else: 290 rrd_dir = '%s/%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host, timeserial ) 291 if metric: 292 rrd_file = '%s/%s.rrd' %( rrd_dir, metric['name'] ) 293 else: 294 rrd_file = None 288 295 289 296 return rrd_dir, rrd_file 290 297 291 def getLastRrdTimeSerial( self, host , metric):292 293 rrd_dir, rrd_file = self.makeRrdPath( host , metric)298 def getLastRrdTimeSerial( self, host ): 299 300 rrd_dir, rrd_file = self.makeRrdPath( host ) 294 301 295 302 newest_timeserial = 0 … … 298 305 for root, dirs, files in os.walk( rrd_dir ): 299 306 300 for file in files: 301 302 myre = re.match( '(\S+?).(\d+).rrd', file ) 303 304 if not myre: 305 continue 306 307 mymetric = myre.group(1) 308 309 if mymetric == metric['name']: 310 311 timeserial = myre.group(2) 307 for dir in dirs: 308 309 valid_dir = 1 310 311 for letter in dir: 312 if letter not in string.digits: 313 valid_dir = 0 314 315 if valid_dir: 316 timeserial = dir 312 317 if timeserial > newest_timeserial: 313 318 newest_timeserial = timeserial … … 318 323 return 0 319 324 320 def checkNewRrdPeriod( self, host, metric,current_timeserial ):321 322 last_timeserial = int( self.getLastRrdTimeSerial( host , metric) )323 debug_msg( 8, 'last timeserial o n %s of %s is %s' %( metric['name'],host, last_timeserial ) )325 def checkNewRrdPeriod( self, host, current_timeserial ): 326 327 last_timeserial = int( self.getLastRrdTimeSerial( host ) ) 328 debug_msg( 8, 'last timeserial of %s is %s' %( host, last_timeserial ) ) 324 329 325 330 if not last_timeserial: … … 336 341 return serial 337 342 338 def createCheck( self, host, metric, current_timeserial ):343 def createCheck( self, host, metric, timeserial ): 339 344 "Check if an .rrd allready exists for this metric, create if not" 340 345 341 timeserial = self.checkNewRrdPeriod( host, metric, current_timeserial )342 346 debug_msg( 8, 'rrdcreate: using timeserial %s for %s/%s' %( timeserial, host, metric['name'] ) ) 343 347 … … 366 370 debug_msg( 9, 'created rrd %s' %( str(rrd_file) ) ) 367 371 368 def update( self, host, metric, current_timeserial ): 369 370 timeserial = self.checkNewRrdPeriod( host, metric, current_timeserial ) 372 def update( self, host, metric, timeserial ): 373 371 374 debug_msg( 8, 'rrdupdate: using timeserial %s for %s/%s' %( timeserial, host, metric['name'] ) ) 372 375
Note: See TracChangeset
for help on using the changeset viewer.