changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/memory

changeset 7243: 34f64dcbbc25
parent: e4280fafd33c
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 awk '
3 function human(name, n) {
4  printf "%-15s", name
5  if(n >= 1000000000) printf "%.3g GB\n", n / 1073741824
6  else if(n >= 1000000) printf "%.3g MB\n", n / 1048576
7  else if(n >= 1000) printf "%.3g KB\n", n / 1024
8  else printf "%d B\n", n
9 }
10 $2 == "memory" { human("total", $1) }
11 $2 == "pagesize" { pagesize = $1 }
12 $2 == "kernel" && NF == 2 { human("total kernel", $1 * pagesize) }
13 $2 == "user" { split($1, a, "/"); human("total user", a[2] * pagesize); print ""; human("used user", a[1] * pagesize) }
14 $2 == "kernel" && $3 == "malloc" { split($1, a, "/"); human("used kernel", a[1]) }
15 $2 == "kernel" && $3 == "draw" { split($1, a, "/"); human("used draw", a[1]) }
16 ' < /dev/swap