Add new comment

useful little perl script to insert timestamps into your data stream / pipeline

Submitted by Aleksey Tsalolikhin on Thu, 2008-02-14 19:21.

I wrote this script to insert a timestamp into the pipeline. I call it "teetime" after /usr/bin/tee.

It can make vmstat more informative, for example:

vmstat 1 | teetime


14Feb2008-18:21:51 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
14Feb2008-18:21:51 r b swpd free buff cache si so bi bo in cs us sy id wa
14Feb2008-18:21:51 1 0 160 15796 41996 255964 0 0 0 0 1035 88 0 0 100 0
14Feb2008-18:21:52 0 0 160 15796 41996 255964 0 0 0 208 1049 99 0 0 99 0
14Feb2008-18:21:53 0 0 160 15796 41996 255964 0 0 0 0 1037 93 0 0 100 0
14Feb2008-18:21:54 0 0 160 15796 41996 255964 0 0 0 0 1014 84 0 0 100 0
14Feb2008-18:21:55 0 0 160 15796 41996 255964 0 0 0 8 1035 84 0 0 100 0
14Feb2008-18:21:56 0 0 160 15796 41996 255964 0 0 0 0 1021 85 0 0 100 0

Best,
Aleksey


#!/usr/bin/perl

# insert a timestamp into the data stream

use POSIX strftime;

while ($_ = ) {
print strftime ("%d%b%Y-%H:%M:%S\t",localtime(time()));
print $_;
}

Trackback URL for this post:

http://lopsa.org/trackback/1582

Reply


*

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <hr> <dl> <dt> <dd> <h2> <h3> <h4> <pre> <i> <table> <tr> <th> <td> <img> <div> <p> <br> <blockquote> <font>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • Easily link to terms in various wikis or other websites by typing [prefix:term]. Use the "|" character to create a "piped link," e.g., "[w:public transport|public transportation]" displays as "public transportation." For a full list of available prefixes and the websites to which they point, see interwiki.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Web and e-mail addresses are automatically converted into links.
  • Web and e-mail addresses are automatically converted into links.
  • Lines and paragraphs break automatically.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Easily link to terms in various wikis or other websites by typing [[prefix:term]]. Use the "|" character to create a "piped link," e.g., "[[w:public transport|public transportation]]" displays as "public transportation." For a full list of available prefixes and the websites to which they point, see interwiki.
  • WikiText is converted to HTML (supported WikiText formatting will show in the long tip format).
Verify comment authorship
Captcha Image: you will need to recognize the text in it.
*
Please type in the letters/numbers that are shown in the image above.