[Python-es] Monitor Apache (archivo error.log)

Alvaro Manrique sanreikaj.foros en gmail.com
Jue Feb 16 16:53:38 CET 2012


Gracias por tu crítica Vicente, excelente código
El 16/02/2012 05:40, "Txema Vicente" <txema en nabla.net> escribió:

> Buenas. Criticando constructivamente, no puedo evitar sugerir:
>
> #!/usr/bin/python
>
> FILE = "/var/log/apache2/error.log"
>
> import os
> import sys
> import time
>
> if len(sys.argv)>1:
>    FILE = sys.argv[1]
>
> size = 0
> pos = 0
> print "Monitor", FILE
> while True:
>    s = os.path.getsize(FILE)
>    if s > size:
>    with open(FILE, "r") as f:
>            f.seek(pos)
>            for line in f.xreadlines():
>                print line,
>            pos = f.tell()
>        size = s
>    time.sleep(3)
>
> El 15/02/2012 23:24, Alvaro Manrique escribió:
>
>> Buenas Tardes Lista;
>>
>>    Abro este nuevo post solo para publicar este pequeño script, encargado
>> de mostrar en consola
>> los cambios en el archivo error.log de apache ejecutandose en Ubuntu.
>>
>>  ______________________________**_________________
> Python-es mailing list
> Python-es en python.org
> http://mail.python.org/**mailman/listinfo/python-es<http://mail.python.org/mailman/listinfo/python-es>
> FAQ: http://python-es-faq.wikidot.**com/<http://python-es-faq.wikidot.com/>
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20120216/2f39b148/attachment.html>


Más información sobre la lista de distribución Python-es