- Timestamp:
- 04/07/05 15:28:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/togad.py
r49 r50 23 23 # 7 = daemon threading 24 24 # 25 DEBUG_LEVEL = 925 DEBUG_LEVEL = 7 26 26 27 27 # Where is the gmetad.conf located … … 378 378 # 379 379 #STORE_INTERVAL = random.randint( 360, 640 ) 380 STORE_INTERVAL = 16380 STORE_INTERVAL = random.randint( 90, 120 ) 381 381 382 382 storethread = threading.Thread( None, self.storeThread, 'storemetricthread' ) … … 526 526 self.gatherLastUpdates() 527 527 528 def isBlocking( self ):529 530 return self.block531 532 528 def gatherLastUpdates( self ): 533 529 "Populate the lastStored list, containing timestamps of all last updates" 534 535 self.block = 1536 530 537 531 cluster_dir = '%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster ) … … 643 637 if metric['time'] <= self.lastStored[ host ][ metric['name'] ]: 644 638 645 # Allready wrote a value with this timestamp, skip tnx639 # This is old 646 640 return 0 647 641 648 else: 642 return 1 643 644 def memLastUpdate( self, host, metriclist ): 645 646 last_update_time = 0 647 648 for metric in metriclist: 649 650 if metric['time'] > last_update_time: 651 652 last_update_time = metric['time'] 653 654 if not self.lastStored.has_key( host ): 649 655 self.lastStored[ host ] = { } 650 656 651 self.lastStored[ host ][ metric['name'] ] = metric['time'] 652 653 return 1 657 if last_update_time > self.lastStored[ host ][ metric['name'] ]: 658 self.lastStored[ host ][ metric['name'] ] = last_update_time 654 659 655 660 def storeMetrics( self ): … … 659 664 for metricname, mymetric in mymetrics.items(): 660 665 661 #mytime = self.makeTimeSerial() 662 #serial = mymetric['time'] 663 #correct_serial = self.checkNewRrdPeriod( hostname, mytime ) 664 666 # Atomic: Don't want other threads messing around now 667 # 665 668 self.slot.acquire() 666 669 … … 670 673 self.myMetrics[ hostname ][ metricname ] = [ ] 671 674 672 self.slot.release() 675 self.slot.release() # Atomic end 676 677 update_rets = [ ] 673 678 674 679 for period, pmetric in metric_serial_table.items(): … … 684 689 debug_msg( 9, 'metric update failed' ) 685 690 686 sys.exit(1) 691 update_rets.append( update_ret ) 692 693 if not (1) in update_rets: 694 695 self.memLastUpdate( hostname, mymetric ) 687 696 688 697 def makeTimeSerial( self ): … … 694 703 return mytime 695 704 696 def makeRrdPath( self, host, metricname =None, timeserial=None):705 def makeRrdPath( self, host, metricname, timeserial ): 697 706 """ 698 707 Make a RRD location/path and filename … … 701 710 """ 702 711 703 if not timeserial: 704 rrd_dir = '%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host ) 705 else: 706 rrd_dir = '%s/%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host, timeserial ) 707 if metricname: 708 rrd_file = '%s/%s.rrd' %( rrd_dir, metricname ) 709 else: 710 rrd_file = None 712 rrd_dir = '%s/%s/%s/%s' %( check_dir(ARCHIVE_PATH), self.cluster, host, timeserial ) 713 rrd_file = '%s/%s.rrd' %( rrd_dir, metricname ) 711 714 712 715 return rrd_dir, rrd_file … … 770 773 # This one should get it's own new period 771 774 period = metric['time'] 775 self.timeserials[ host ].append( period ) 772 776 773 777 if not metric_serial_table.has_key( period ): … … 780 784 781 785 return metric_serial_table 782 783 def checkNewRrdPeriod( self, host, current_timeserial ):784 """785 Check if current timeserial belongs to recent time period786 or should become a new period (and file).787 788 Returns the serial of the correct time period789 """790 791 last_timeserial = int( self.getLastRrdTimeSerial( host ) )792 debug_msg( 9, 'last timeserial of %s is %s' %( host, last_timeserial ) )793 794 if not last_timeserial:795 serial = current_timeserial796 else:797 798 archive_secs = ARCHIVE_HOURS_PER_RRD * (60 * 60)799 800 if (current_timeserial - last_timeserial) > archive_secs:801 serial = current_timeserial802 else:803 serial = last_timeserial804 805 return serial806 807 def getFirstTime( self, host, metricname ):808 "Get the first time of a metric we know of"809 810 first_time = 0811 812 for metric in self.myMetrics[ host ][ metricname ]:813 814 if not first_time or metric['time'] <= first_time:815 816 first_time = metric['time']817 818 return first_time819 786 820 787 def createCheck( self, host, metricname, timeserial ):
Note: See TracChangeset
for help on using the changeset viewer.