Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31357

Is there a way to create kernel log messages via Python?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <dreadpiratejeff@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'offline': 0.03; 'messages.': 0.04; 'subject:Python': 0.05; 'bits': 0.07; 'next,': 0.07; 'broke': 0.09; 'itself,': 0.09; 'marking': 0.09; 'mem': 0.09; 'subject:create': 0.09; 'subject:messages': 0.09; 'timestamps': 0.09; 'will,': 0.09; 'affinity': 0.16; 'hits': 0.16; 'mark.': 0.16; 'marker': 0.16; 'oct': 0.16; 'preparing': 0.16; 'subject:log': 0.16; 'syslog': 0.16; 'to:name:python list': 0.16; 'test.': 0.17; 'module': 0.19; 'written': 0.20; 'bit': 0.21; 'parse': 0.22; 'runs': 0.22; "i've": 0.23; 'second': 0.24; 'linux': 0.24; 'machine': 0.24; 'tried': 0.25; 'skip:[ 10': 0.26; 'done.': 0.27; 'first,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'this?': 0.28; 'all.': 0.28; 'cpu': 0.29; 'occurred': 0.29; 'sleep': 0.29; 'points': 0.29; 'starts': 0.29; 'related': 0.30; 'ends': 0.30; 'received:209.85.215.46': 0.30; 'seconds': 0.30; 'code': 0.31; 'point': 0.31; 'problem.': 0.32; 'could': 0.32; 'message.': 0.33; 'certain': 0.33; 'instead,': 0.33; 'problem': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'themselves': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'or,': 0.34; 'done': 0.34; 'so,': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'be.': 0.36; 'test': 0.36; 'does': 0.37; 'uses': 0.37; 'skip:4 10': 0.37; 'rather': 0.37; 'received:209': 0.37; 'mark': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'google': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'networking': 0.60; 'skip:u 10': 0.60; 'most': 0.61; 'real': 0.61; 'first': 0.61; 'between': 0.63; 'services.': 0.63; 'total': 0.65; 'subject:there': 0.65; '"going': 0.84; 'different.': 0.84; 'injecting': 0.84; 'subject:via': 0.84; 'timestamps,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=kQdmXR/1vIk88udIPPg4l3H99Un2BZ/vuX5dlgixEUA=; b=ksMEoeMxtbKupwyHbmrLKNhz7uVGEVyzkOPCp6EH1LIU2e7K40IxGu+MwEgK9aOVW6 0ggrt3iUs3wr15dMWGaj7YjvX7e3wS39shKXIPmp2rY+GVvEuAt9RpRuLa4b9OK2MG5V 985rMV9S4jfu50EnVzR8wt/MhkRrJd1501bFP4FiT4eRkCFBKyDm6Tqwue33X5ky42LA 3mVmUG3Fxv3Uv50Hr5jPjPm37u0YcPZqqWObR1uGkjHEMu+qC1jAsM9wcGNio9G3mQm/ UH9s91VeA5GT1jF0YgnUd6Tpjm+APqViwaqsMeo3k8X4G7bb0PzKhwqD+Sw6kC4LxJJB 380A==
MIME-Version 1.0
From J <dreadpiratejeff@gmail.com>
Date Mon, 15 Oct 2012 23:43:06 -0400
Subject Is there a way to create kernel log messages via Python?
To Python List <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2248.1350359007.27098.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350359007 news.xs4all.nl 6840 [2001:888:2000:d::a6]:40123
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31357

Show key headers only | View raw


Hi...

I have a bit of code that does the following:

uses the syslog module to inject a LOG_INFO message into the syslog on
my linux machine
runs a suspend/resume cycle
uses the syslog module to inkect a LOG_INFO message marking the end of test.

Then I parse everything between the start and stop markers for certain
items that the Linux kernel logs during a suspend and resume cycle.

But my  "resume complete" timing is not as accurate as it could be.
The problem with doing it this way is that while I can find definite
kernel messages that mark various points in the suspend/resume cycle,
the final message when the kernel is done resuming is NOT the point I
actually want to mark.

Instead, the end point I want is the time of the ending marker itself,
as this happens after certain other things are done such as resumption
of networking services.

Here's the problem.  I can't just use syslog timestamps.  The reason
is that the syslog timestamps are only indicative of when messages are
written to syslog via syslogd.  The kernel timestamps are different.
For example, the following bits of log are taken from the time the
test starts until the end of the "going to sleep" kernel messages.
First, note that there's a 5 second difference between the START
marker and the first kernel message.  Next, look at the kernel
timestamps.  The total real time to suspend starts at 421320.380947
and ends at 421322.386355, around 2 seconds later, where the log
messages themselves all state that the events occurred at the same
time.

Oct 15 10:24:19 klaatu sleep_test: ---SLEEP TEST START 1350296656---
Oct 15 10:25:24 klaatu kernel: [421320.380947] PM: Syncing filesystems ... done.
Oct 15 10:25:24 klaatu kernel: [421320.391282] PM: Preparing system
for mem sleep
[SNIP]
Oct 15 10:25:24 klaatu kernel: [421322.282943] Broke affinity for irq 23
Oct 15 10:25:24 klaatu kernel: [421322.386355] CPU 7 is now offline

So, what I REALLY want is to inject my start/stop markers into klogd
rather than syslogd.  This will, I hope, give my markers kernel
timestamps rather than syslog timestamps which are not as accurate.

So does anyone know of a way to do this?  Unfortunately, I've tried
some searching but google doesn't like the term klog, and most of the
hits involved injecting code or other things that are not related at
all.

Or, if there's a better way to get accurate timestamps, what would that be?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Is there a way to create kernel log messages via Python? J <dreadpiratejeff@gmail.com> - 2012-10-15 23:43 -0400
  Re: Is there a way to create kernel log messages via Python? Marco Nawijn <nawijn@gmail.com> - 2012-10-16 03:26 -0700
  Re: Is there a way to create kernel log messages via Python? Marco Nawijn <nawijn@gmail.com> - 2012-10-16 03:26 -0700
  Re: Is there a way to create kernel log messages via Python? Jerry Peters <jerry@example.invalid> - 2012-10-16 20:19 +0000
  Re: Is there a way to create kernel log messages via Python? Andrew Cooper <andrew@nospam.example.com> - 2012-10-17 02:25 +0100

csiph-web