diff --git a/extensions/stats/grapher.py b/extensions/stats/grapher.py
index c1889b40e..3761456c9 100644
--- a/extensions/stats/grapher.py
+++ b/extensions/stats/grapher.py
@@ -61,10 +61,10 @@ class Grapher(object):
def process(self, target, suffix, start, end, tpl=traffic_avg_template):
rrdfile = "%s/%s.rrd" % (self.rrd_rootdir, target)
if not os.path.exists(rrdfile):
- print "[graph] no rrd file detected"
+ print "[graph] no rrd file %s detected" %rrdfile
return
ext = "png"
- path = "%s/%s_%s_%s_%s.%s" % (self.img_rootdir, tpl['name'],
+ path = "%s/%s_%s_%s_%s.%s" % (self.img_rootdir, tpl['name'],
target, tpl['cf'], suffix, ext)
start = str(start)
end = str(end)
@@ -74,7 +74,7 @@ class Grapher(object):
defs += ['DEF:%s=%s:%s:%s' % (v, rrdfile, v, tpl['cf']),
'CDEF:%spm=%s,60,*' % (v, v)]
type = d.has_key("type") and d["type"] or "LINE"
- lines += ["%s:%spm%s:%s" % (type, v, d["color"],
+ lines += ["%s:%spm%s:%s" % (type, v, d["color"],
d["legend"].encode("utf-8"))]
params = defs + lines
rrdtool.graph(str(path),
@@ -89,6 +89,11 @@ class Grapher(object):
"--units-exponent", "0",
*params)
+ if not os.path.exists(path):
+ print "[graph] Impossible to create %s graph" %path
+ else:
+ print "[graph] %s graph created" %path
+
def make_defaults(self, target, tpl=traffic_avg_template):
end = "%d" % int(time.mktime(time.localtime()))
self.process(target, "day", "-1day", end, tpl)
diff --git a/extensions/stats/logparser.py b/extensions/stats/logparser.py
index e2c449822..a3953de81 100755
--- a/extensions/stats/logparser.py
+++ b/extensions/stats/logparser.py
@@ -5,7 +5,7 @@ import sys
import os
import re
import rrdtool
-import string
+import string, pdb
from optparse import OptionParser
from mailng.lib import getoption
from mailng.admin.models import Domain
@@ -61,7 +61,8 @@ class LogParser(object):
try:
self.f = open(logfile)
except IOError, errno:
- print "%s" % errno
+ if self.debug:
+ print "%s" % errno
sys.exit(1)
self.workdir = workdir
self.year = year
@@ -72,6 +73,8 @@ class LogParser(object):
self.last_month = None
if not self.year:
self.year = time.localtime().tm_year
+ if self.debug:
+ print "[rrd] Dealing with year %s" %self.year
self.data = {}
domains = Domain.objects.all()
self.domains = []
@@ -134,7 +137,8 @@ class LogParser(object):
m = t - (t % rrdstep)
if not os.path.exists(fname):
self.lupdates[fname] = self.init_rrd(fname, m)
- print "[rrd] create new RRD file"
+ if self.debug:
+ print "[rrd] create new RRD file %s" %fname
else:
if not self.lupdates.has_key(fname):
self.lupdates[fname] = rrdtool.last(fname)
@@ -227,10 +231,12 @@ class LogParser(object):
m = re.search("to=<([^>]*)>.*status=(\S+)", line_log)
if m:
if not self.workdict.has_key(line_id):
- print "Inconsistent mail (%s: %s), skipping" % (line_id, m.group(1))
+ if self.debug:
+ print "Inconsistent mail (%s: %s), skipping" % (line_id, m.group(1))
continue
if not m.group(2) in variables:
- print "Unsupported status %s, skipping" % m.group(2)
+ if self.debug:
+ print "Unsupported status %s, skipping" % m.group(2)
continue
addrfrom = re.match("([^@]+)@(.+)", self.workdict[line_id]['from'])
@@ -258,6 +264,8 @@ class LogParser(object):
# Sort everything by time
G = grapher.Grapher()
for dom, data in self.data.iteritems():
+ if self.debug:
+ print "[rrd] dealing with domain %s" %dom
sortedData = {}
sortedData = [ (i, data[i]) for i in sorted(data.keys()) ]
for t, dict in sortedData:
diff --git a/extensions/stats/templates/adminindex.html b/extensions/stats/templates/adminindex.html
index 815ae4907..2e7a6f1ce 100644
--- a/extensions/stats/templates/adminindex.html
+++ b/extensions/stats/templates/adminindex.html
@@ -1,9 +1,8 @@
-{% extends "layout.html" %}
+{% extends "nlayout.html" %}
{% load i18n %}
{% load stats_extra %}
{% block html_head %}
-