Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/awk -f
- BEGIN {
- u = "[[:upper:]]"
- l = "[[:lower:]]"
- d = "[[:digit:]]"
- # w m day t tz y
- # Wed Feb 8 12:02:50 PST 2017
- w = m = u l l
- day = "(" d "|" d d ")"
- t = "[0-2]" d ":[0-5]" d ":[0-5]" d
- tz = "[[:alnum:]+-]+"
- y = d d d d
- # Wed Feb 8 12:02:50 PST 2017
- s = "[[:space:]]+"
- date = w s m s day s t s tz s y
- months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
- for (n = split(months, x) + 1; --n;) month[x[n]] = n - 1
- }
- function dump() {
- if (!totals) return
- totals = 0
- split(ft, tf, /:/)
- hour = tf[1]
- minute = tf[2]
- second = tf[3]
- e = sprintf("gTime(%4u, %2u, %2u, %2u, %2u, %2u)",
- fy, month[fm], fd, hour, minute, second)
- reclaim_data = reclaim_data sprintf("\t\t\t[%s, %u],\n", e, reclaims)
- freed_data = freed_data sprintf("\t\t\t[%s, %u],\n", e, freed)
- }
- $0 ~ "^" date "$" {
- dump()
- # w m d t tz y
- # Wed Feb 8 12:02:50 PST 2017
- split(curdate = $0, f, s)
- fw = f[1]
- fm = f[2]
- fd = f[3]
- ft = f[4]
- ftz = f[5]
- fy = f[6]
- next
- }
- $1 == "Totals" {
- totals = 1
- reclaims = $5
- freed = $7
- }
- END {
- dump()
- print "\t{"
- print "\t\tid: 'reclaims',"
- print "\t\ttype: 'spline',"
- print "\t\tname: 'Reclaims',"
- print "\t\tzIndex: 5,"
- print "\t\taddToNavigator: true,"
- print "\t\tcolor: colors[0],"
- printf "\t\tdata: [\n%s\t\t], // data\n", reclaim_data
- print "\t}, // reclaims"
- print "\t{"
- print "\t\tid: 'freed',"
- print "\t\ttype: 'spline',"
- print "\t\tname: 'Freed',"
- print "\t\tzIndex: 4,"
- print "\t\taddToNavigator: true,"
- print "\t\tcolor: colors[1],"
- printf "\t\tdata: [\n%s\t\t], // data\n", freed_data
- print "\t}, // freed"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement