Commit 05024eb6 authored by salles's avatar salles

On trace un graphe de l'volution des navigateurs qui reprsentent plus de

1% des visites pour les virtual host intressantsx.

darcs-hash:20060502131438-72cb0-b80a7037b0df4571876bd269fbd557e38e4513db.gz
parent 19bc699b
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# Reprsentation des navigateurs utiliss
import sys, commands, string, re
from time import strftime
from operator import add
# On prend l'argument pour dfinir la table analyser
SITE = sys.argv[0].split('_')[1]
# On traite le fichier de webalizer correspondant
FILE = "/var/www/webalizer/%s/webalizer.current" % SITE
f = open(FILE, 'r')
lines = f.readlines()
f.close()
navigateurs = {}
agent = False
for line in lines :
#print line
if "# -agents-" in line : agent = True
if "# End Of Table - agents" in line : break
if agent :
if line [:2] == "0 " : navigateurs[nom]=int(line[2:])
else : nom = line.strip()
total = reduce(add, navigateurs.values())
usage = {}
for nav in navigateurs.keys() :
pourcentage = navigateurs[nav]*100/total
if pourcentage > 1 :
usage[nav] = pourcentage
reste = 100 - reduce(add, usage.values())
try :
arg = sys.argv[1]
except :
arg = ''
if arg == "config" :
print 'host_name web'
print 'graph_category %s' % SITE
print 'graph_title http://%s.crans.org' % SITE
print 'graph_args --base 1000 --lower-limit 0'
print 'graph_vlabel % des visites'
for key in usage.keys() :
nom = key
for char in [' ','_','-','/','\\',':',';','.'] :
nom = nom.replace(char, '')
print '%s.label %s' % (nom, key)
if usage.keys().index(key) == 0 :
print '%s.draw AREA' % nom
else :
print '%s.draw STACK' % nom
print 'reste.label Autres'
print 'reste.draw STACK'
else :
for key in usage.keys() :
nom = key
for char in [' ','_','-','/','\\',':',';','.'] :
nom = nom.replace(char, '')
print '%s.value %s' % (nom, usage[key])
print 'reste.value %s' % reste
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment