From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2153 Path: news.gmane.org!not-for-mail From: Mike Buland Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: [magic sv logging] Date: Fri, 21 Sep 2012 09:32:43 -0600 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec5186a527e334704ca37f3e1 X-Trace: ger.gmane.org 1348241565 20448 80.91.229.3 (21 Sep 2012 15:32:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Sep 2012 15:32:45 +0000 (UTC) To: supervision@list.skarnet.org Original-X-From: supervision-return-2387-gcsg-supervision=m.gmane.org@list.skarnet.org Fri Sep 21 17:32:50 2012 Return-path: Envelope-to: gcsg-supervision@plane.gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TF5Dl-00076f-UO for gcsg-supervision@plane.gmane.org; Fri, 21 Sep 2012 17:32:50 +0200 Original-Received: (qmail 11042 invoked by uid 76); 21 Sep 2012 14:34:04 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 11033 invoked from network); 21 Sep 2012 14:34:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=v4yfXRry5cVL8nIOzoaEXe+JAY8HQnkCA7wkvlBODjY=; b=tV/aDaeaV7D3cMJp16UD+9ZvnKpMmxfHIdkxOGdjyPGqkHUQiJYWbvgMcPPntPgleH SOpr4QT1QwEieMhRCKpmDO/tb/yy4C+evg2Drm1zjlrBoE+A6i+v5O3Jxcsf5YyXK1yd g6mm8gRd52FR8SR8GXP2RClcKUF9/TG+lXBZzPAFTbxKfeo9JHENYFuaQV8Au4kGlWUv q4ZKRAd9G+i5vN5qkiDpiddWpX83dZPYPtQmeiVTAHgANlnvdQaytkY71tL8+DWfK9mz wTS7pHPjMtegdX+tzgX+KDxSC/VF56EzCmXh/WU+WXTiH/4fvAyd8hc6Ue9blqDYOQPe LEDA== In-Reply-To: Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2153 Archived-At: --bcaec5186a527e334704ca37f3e1 Content-Type: text/plain; charset=ISO-8859-1 You haven't missed anything, well, it's more like "tail --follow=name ' but instead of piping the output of tail into another program for processing, this just does all the work in python. Not only was it fun to write, but I like the fact that I don't need to chain more programs together. --Mike On Fri, Sep 21, 2012 at 9:29 AM, Lorenzo Beretta wrote: > On 21/09/2012 04:25, Mike Buland wrote: > >> I took a different approach and monitored the log output of svlogd, since >> I >> wanted the logs anyway. This is some code that well help you with that, >> anyway: >> >> import os >> import time >> import stat >> >> fIn = open("current", "r") >> sid = os.stat("current")[stat.ST_**INO] >> >> while True: >> try: >> sidNew = os.stat("current")[stat.ST_**INO] >> if sidNew != sid: >> fIn.close() >> fIn = open("current", "r") >> sid = sidNew >> except: >> time.sleep( 1 ) >> continue >> >> while True: >> l = fIn.readline() >> if l is None or l == '': >> break >> # do something interesting with your line here >> time.sleep( 1 ) >> >> This will read everything from current, and when current moves, it will >> read what's left, open the new current, and read all of it. I use it to >> monitor apache log output, and it hasn't failed me yet. >> >> --Mike >> > > Unless I missed something, it looks as if you're reimplementing the '-F' > flag in tail :) > > > --bcaec5186a527e334704ca37f3e1--