Permalink
Browse files

Merge branch 'master' of github.com:kachayev/gearoscope

  • Loading branch information...
2 parents 67f5c5d + e2409db commit d8e524642f8e0b3affb4f2028c3ed0562075e448 @jurka jurka committed Jul 31, 2011
Showing with 13 additions and 33 deletions.
  1. +10 −0 gearoscope/apps/monitor/reader.py
  2. +0 −30 gearoscope/apps/monitor/sonar.example.conf
  3. +3 −3 gearoscope/data/sonar.conf
@@ -1,8 +1,15 @@
class Reader(object):
+ '''Read log file, created by sonar daemon'''
def __init__(self, path):
self.path = path
def tail(self, size, verbosity='info'):
+ '''
+ Return to client list of special Entry objects (one per each line in log)
+
+ Method will reverse lines order as unix util `tail` done
+ It also can filter entiries by verbosity level (will return higher)
+ '''
with open(self.path) as log:
lines = [MonitorEntry.extract(line) for line in log.readlines()[::-1]]
@@ -12,6 +19,8 @@ def tail(self, size, verbosity='info'):
return lines[:max(size,len(lines))]
class MonitorEntry(object):
+ '''One line from log representation'''
+
__slots__=('time', 'sender', 'level', 'code', 'message')
LEVELS = ['debug', 'info', 'error', 'critical']
@@ -25,6 +34,7 @@ def __init__(self, time, sender, level, message):
@staticmethod
def extract(line):
+ '''Will cat from left side of line Time, Sender and Level marks'''
parts = line.strip().split()
return MonitorEntry(' '.join(parts[:2]), parts[2], parts[3], ' '.join(parts[4:]))
@@ -1,30 +0,0 @@
-[sonard]
-user = root
-log_buffer_file = sonar.log
-
-[pool:stat]
-## type = queue
-count = 3
-timeout = 0
-prototype = sonar.agents.process.ProcessStatAgent
-
-[logger:buffer]
-maxsize = 100kb
-rotation_maxbytes = 2mb
-rotation_backups = 5
-format = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s"
-
-[server:local]
-host= 127.0.0.1
-is_default = True
-
-[supervisor:local]
-server = local
-port = 9001
-names = multiple,reverse,sum
-## groups =
-
-[gearman:local]
-server = local
-port = 4730
-
@@ -14,8 +14,8 @@ rotation_backups = 5
format = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s"
[server:localhost]
-host = localhost
-password =
+host = 127.0.0.1
+password =
user = root
[gearman:localhost]
@@ -24,6 +24,6 @@ server = localhost
[supervisor:localhost]
names = multiple
-port = 8999
+port = 9001
server = localhost

0 comments on commit d8e5246

Please sign in to comment.