incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r769866 - in /incubator/tashi/trunk: etc/TashiDefaults.cfg src/tashi/ganglialoghandler.py
Date Wed, 29 Apr 2009 18:33:11 GMT
Author: mryan3
Date: Wed Apr 29 18:33:10 2009
New Revision: 769866

URL: http://svn.apache.org/viewvc?rev=769866&view=rev
Log:
Simplified the ganglia log handler by:
Adding expiration times to the ganglia metrics instead of using rolling windows
Assuming that hosts will have host routes added if they are necessary (instead of specifying
the interface to be used in Tashi config files)


Modified:
    incubator/tashi/trunk/etc/TashiDefaults.cfg
    incubator/tashi/trunk/src/tashi/ganglialoghandler.py

Modified: incubator/tashi/trunk/etc/TashiDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/etc/TashiDefaults.cfg?rev=769866&r1=769865&r2=769866&view=diff
==============================================================================
--- incubator/tashi/trunk/etc/TashiDefaults.cfg (original)
+++ incubator/tashi/trunk/etc/TashiDefaults.cfg Wed Apr 29 18:33:10 2009
@@ -137,7 +137,7 @@
 class = tashi.GangliaLogHandler
 level = NOTSET
 formatter = standardFormatter
-args = (60, 2, 'default')
+args = (60, 3600)
 
 [formatter_standardFormatter]
 format=%(asctime)s [%(name)s:%(levelname)s] %(message)s

Modified: incubator/tashi/trunk/src/tashi/ganglialoghandler.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/ganglialoghandler.py?rev=769866&r1=769865&r2=769866&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/ganglialoghandler.py (original)
+++ incubator/tashi/trunk/src/tashi/ganglialoghandler.py Wed Apr 29 18:33:10 2009
@@ -25,41 +25,34 @@
 logging.tashi = tashi
 
 class GangliaLogHandler(logging.Handler):
-	def __init__(self, windowSize, windows, interface):
+	def __init__(self, dmax, retry):
 		logging.Handler.__init__(self)
-		self.msgIndex = 0
-		self.windowIndex = 0
-		self.lastRollover = time.time()
+		self.dmax = dmax
+		self.retry = retry
 		self.name = os.path.basename(sys.argv[0])
-		self.windowSize = windowSize
-		self.windows = windows
-		self.interface = interface.lower()
+		self.msgIndex = 0
 		self.disable = False
+		self.disableAt = 0.0
 	
 	def emit(self, record):
+		now = time.time()
 		if (self.disable):
-			return
+			if (now - self.disableAt > self.retry):
+				disable = False
+			else:
+				return
 		try:
-			now = time.time()
 			msg = self.format(record)
-			if (now > self.lastRollover + self.windowSize):
-				self.lastRollover = now
-				self.msgIndex = 0
-				self.windowIndex = self.windowIndex + 1
-				if (self.windowIndex >= self.windows):
-					self.windowIndex = 0
-			metricName = "tashi_log_%s_%d_%d" % (self.name, self.windowIndex, self.msgIndex)
-			metricValue = msg.replace("'", '"')
+			metricName = "tashi_log_%s_%d_%d" % (self.name, self.msgIndex, int(now*1000))
+			metricValue = msg.replace('"', "'")
 			metricType = "string"
-			if (self.interface == "default"):
-				(stdin, stdout) = os.popen4("gmetric -n '%s' -v '%s' -t '%s'" % (metricName, metricValue,
metricType))
-			else:
-				(stdin, stdout) = os.popen4("gmetric -n '%s' -v '%s' -t '%s' -i '%s'" % (metricName,
metricValue, metricType, self.interface))
+			(stdin, stdout) = os.popen4('gmetric -n "%s" -v "%s" -t "%s" -d "%d"' % (metricName, metricValue,
metricType, self.dmax))
 			stdin.close()
 			res = stdout.read()
 			if (res != ""):
 				print "Failed to exec gmetric, disabling: %s" % (res)
 				self.disable = True
+				self.disableAt = now
 			stdout.close()
 			self.msgIndex = self.msgIndex + 1
 		except Exception, e:



Mime
View raw message