#!/bin/sh # # A crude ascii reporting tools, convert pmie to column output # # The pmie rules need to be of the form: # load_1 = kernel.all.load #'1 minute'; # idle = kernel.all.cpu.idle; # column_name=some other expression; # ... # EOL = hinv.ncpu; // some metric that is singular, guaranteed to be # // present and the value is not of interest # # The EOL is literal and magic ... see below ... and marks the end of a # the line for output formatting. # # With timestamps (pmie -e or pmie output from a PCP archive), lines look like # metric (Tue Feb 13 05:01:19 2001): value # load_1 (Tue Dec 23 12:20:45 2003): 0.24 # the first sed step in the filter sorts this out. # # First e-mailed to Patrick Aland and pcp@xxxxxxxxxxx # on Wed, 24 Jan 2001. # sed \ -e '/^[^ ][^ ]* ([A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [12][0-9][0-9][0-9]): /{ s/ (/|/ s/): /|/ }' \ -e '/^\([^ ][^ ]*\):/s//\1||/' \ | awk -F\| ' NF == 0 { next } NF == 3 && stamp == "" { stamp = $2 } state == 0 && $1 == "EOL" { print ""; ncol = i; state = 1 } state == 0 { if (i == 0 && stamp != "") printf "%24s ","" printf " %7.7s",$1 } $1 == "EOL" { if (stamp != "") printf "%24s ",stamp for (i = 0; i < ncol; i++) { if (v[i] == "?") # no value printf " %7.7s","?" else if (v[i]+0 == v[i]) # number printf " %7.2f",v[i] else # string printf " %7.7s",v[i] v[i] = "?" } print "" i = 0 stamp = "" next } { v[i++] = $NF }'