[CalendarServer-changes] [577]
CalendarServer/branches/caladmin-tool/caladmin
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 22 16:18:55 PST 2006
Revision: 577
http://trac.macosforge.org/projects/calendarserver/changeset/577
Author: dreid at apple.com
Date: 2006-11-22 16:18:55 -0800 (Wed, 22 Nov 2006)
Log Message:
-----------
reporters for logs
Modified Paths:
--------------
CalendarServer/branches/caladmin-tool/caladmin/formatters.py
CalendarServer/branches/caladmin-tool/caladmin/logs.py
CalendarServer/branches/caladmin-tool/caladmin/util.py
Modified: CalendarServer/branches/caladmin-tool/caladmin/formatters.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/formatters.py 2006-11-23 00:15:55 UTC (rev 576)
+++ CalendarServer/branches/caladmin-tool/caladmin/formatters.py 2006-11-23 00:18:55 UTC (rev 577)
@@ -123,7 +123,8 @@
self.writeList(self.options['fieldnames'],
[report['data']])
-
+ report_logs = report_stats
+
registerFormatter(CsvFormatter)
import plistlib
@@ -146,4 +147,6 @@
plistlib.writePlist(plist, self.dest)
+ report_logs = report_stats
+
registerFormatter(PlistFormatter)
Modified: CalendarServer/branches/caladmin-tool/caladmin/logs.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/logs.py 2006-11-23 00:15:55 UTC (rev 576)
+++ CalendarServer/branches/caladmin-tool/caladmin/logs.py 2006-11-23 00:18:55 UTC (rev 577)
@@ -26,17 +26,19 @@
import plistlib
+from caladmin import util
+
statsTemplate = plistlib.Dict(
- BytesOut=0,
- Requests=plistlib.Dict(
+ bytesOut=0,
+ requestCounts=plistlib.Dict(
PROPFIND=0,
),
- Invitations=plistlib.Dict(
+ invitations=plistlib.Dict(
day=0,
week=0,
month=0,
),
- UserAgents=plistlib.Dict(),
+ userAgents=plistlib.Dict(),
)
@@ -50,30 +52,37 @@
self._data = statsTemplate
self.save()
+ def getBytes(self):
+ return self._data.bytesOut
+
def addBytes(self, bytes):
- self._data.BytesOut += bytes
+ self._data.bytesOut += bytes
def addRequest(self, request):
- if request in self._data.Requests:
- self._data.Requests[request] += 1
+ if request in self._data.requestCounts:
+ self._data.requestCounts[request] += 1
else:
- self._data.Requests[request] = 1
+ self._data.requestCounts[request] = 1
+
+ def getRequests(self):
+ return self._data.requestCounts
def addUserAgent(self, useragent):
- if useragent in self._data.UserAgents:
- self._data.UserAgents[useragent] += 1
+ if useragent in self._data.userAgents:
+ self._data.userAgents[useragent] += 1
else:
- self._data.UserAgents[useragent] = 1
+ self._data.userAgents[useragent] = 1
+ def getUserAgents(self):
+ return self._data.userAgents
+
def save(self):
plistlib.writePlist(self._data, self.fp.path)
-
NORMAL = 1
INDATE = 2
INSTRING = 3
-
def parseCLFLine(line):
state = NORMAL
elements = []
@@ -127,12 +136,22 @@
else:
pline = parseCLFLine(line)
- print pline
-
self.stats.addBytes(int(pline[6]))
self.stats.addRequest(pline[4].split(' ')[0])
if len(pline) > 7:
self.stats.addUserAgent(pline[8])
+
+ self.stats.save()
- self.stats.save()
+ report = {
+ 'type': 'logs',
+ 'data': {
+ 'bytesOut': util.prepareByteValue(self.config,
+ self.stats.getBytes()),
+ 'requestCounts': self.stats.getRequests(),
+ 'userAgents': self.stats.getUserAgents(),
+ }
+ }
+
+ return report
Modified: CalendarServer/branches/caladmin-tool/caladmin/util.py
===================================================================
--- CalendarServer/branches/caladmin-tool/caladmin/util.py 2006-11-23 00:15:55 UTC (rev 576)
+++ CalendarServer/branches/caladmin-tool/caladmin/util.py 2006-11-23 00:18:55 UTC (rev 577)
@@ -23,9 +23,9 @@
from twisted.web import microdom
from twistedcaldav import ical
-
+
def prepareByteValue(config, value):
- if config['human']:
+ if config.get('human', None):
KB = value/1024.0
if KB < 1:
return '%d' % (value,)
@@ -40,17 +40,17 @@
return '%5.2fGB' % (GB,)
- elif config['gigabytes']:
+ elif config.get('gigabytes', None):
G = value/1024.0/1024.0/1024.0
return '%5.2fGB' % (G,)
- elif config['megabytes']:
+ elif config.get('megabytes', None):
M = value/1024.0/1024.0
return '%5.2fMB' % (M,)
- elif config['kilobytes']:
+ elif config.get('kilobytes', None):
K = value/1024.0
return '%5.2fKB' % (K,)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061122/ff1a9a3f/attachment.html
More information about the calendarserver-changes
mailing list