Changeset 18 for trunk/daemon/togad.py
- Timestamp:
- 03/23/05 14:27:48 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/togad.py
r17 r18 102 102 103 103 if name == 'HOST' and self.clusterName in ARCHIVE_SOURCES: 104 self.storeMetrics( self.hostName ) 104 105 # Determine time here, so all use same time in this run 106 mytime = self.rrd.makeTimeSerial() 107 108 self.storeMetrics( self.hostName, mytime ) 105 109 106 110 #if name == 'METRIC': 107 111 108 def storeMetrics( self, hostname ):112 def storeMetrics( self, hostname, timeserial ): 109 113 110 114 for metric in self.metrics: 111 115 if metric['type'] not in UNSUPPORTED_ARCHIVE_TYPES: 112 116 113 self.rrd.createCheck( hostname, metric )114 self.rrd.update( hostname, metric )117 self.rrd.createCheck( hostname, metric, timeserial ) 118 self.rrd.update( hostname, metric, timeserial ) 115 119 debug_msg( 9, 'stored metric %s for %s: %s' %( hostname, metric['name'], metric['val'] ) ) 116 120 sys.exit(1) … … 266 270 def __init__( self, cluster ): 267 271 self.cluster = cluster 268 269 272 self.gmetad_conf = GangliaConfigParser( GMETAD_CONF ) 270 273 … … 282 285 283 286 rrd_dir = '%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host ) 284 rrd_file = '%s/%s $%s.rrd' %( rrd_dir, metric['name'], timeserial )287 rrd_file = '%s/%s.%s.rrd' %( rrd_dir, metric['name'], timeserial ) 285 288 286 289 return rrd_dir, rrd_file … … 297 300 for file in files: 298 301 299 myre = re.match( '(\S+ )\$(\d+).rrd', file )302 myre = re.match( '(\S+?).(\d+).rrd', file ) 300 303 301 304 if not myre: … … 311 314 312 315 if newest_timeserial: 313 return timeserial316 return newest_timeserial 314 317 else: 315 318 return 0 316 319 317 def checkNewRrdPeriod( self, host, metric ): 318 319 cur_timeserial = int( self.makeTimeSerial() ) 320 def checkNewRrdPeriod( self, host, metric, current_timeserial ): 321 320 322 last_timeserial = int( self.getLastRrdTimeSerial( host, metric ) ) 323 debug_msg( 8, 'last timeserial on %s of %s is %s' %( metric['name'], host, last_timeserial ) ) 321 324 322 325 if not last_timeserial: 323 return 0, 0 324 325 archive_secs = ARCHIVE_HOURS_PER_RRD * (60 * 60) 326 327 if (cur_timeserial - last_timeserial) >= archive_secs: 328 return 1, last_timeserial 326 serial = current_timeserial 329 327 else: 330 return 0, last_timeserial 331 332 def createCheck( self, host, metric ): 328 329 archive_secs = ARCHIVE_HOURS_PER_RRD * (60 * 60) 330 331 if (current_timeserial - last_timeserial) >= archive_secs: 332 serial = current_timeserial 333 else: 334 serial = last_timeserial 335 336 return serial 337 338 def createCheck( self, host, metric, current_timeserial ): 333 339 "Check if an .rrd allready exists for this metric, create if not" 334 340 335 need_new, last_timeserial = self.checkNewRrdPeriod( host, metric ) 336 337 if need_new or not last_timeserial: 338 timeserial = self.makeTimeSerial() 339 else: 340 timeserial = last_timeserial 341 timeserial = self.checkNewRrdPeriod( host, metric, current_timeserial ) 342 debug_msg( 8, 'rrdcreate: using timeserial %s for %s/%s' %( timeserial, host, metric['name'] ) ) 341 343 342 344 rrd_dir, rrd_file = self.makeRrdPath( host, metric, timeserial ) … … 364 366 debug_msg( 9, 'created rrd %s' %( str(rrd_file) ) ) 365 367 366 def update( self, host, metric ): 367 368 rrd_dir = '%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host ) 369 rrd_file = '%s/%s.rrd' %( rrd_dir, metric['name'] ) 368 def update( self, host, metric, current_timeserial ): 369 370 timeserial = self.checkNewRrdPeriod( host, metric, current_timeserial ) 371 debug_msg( 8, 'rrdupdate: using timeserial %s for %s/%s' %( timeserial, host, metric['name'] ) ) 372 373 rrd_dir, rrd_file = self.makeRrdPath( host, metric, timeserial ) 370 374 371 375 timestamp = metric['time']
Note: See TracChangeset
for help on using the changeset viewer.