Skip to content

Commit 10279ad

Browse files
author
Jeremiah Roth
committed
More useful help; disable broken -once
1 parent 56b5913 commit 10279ad

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# uptop
1+
# uptop [![Build Status](https://travis-ci.org/rothwerx/uptop.svg?branch=master)](https://travis-ci.org/rothwerx/uptop)
22
> Top-like tool for displaying per-process USS (unique set size) and PSS (proportional set size) memory usage
33
44
Standard Linux memory observation tools will show you the resident set size (RSS or RES) and virtual memory size (VMSIZE or VIRT) for each process, but neither are useful for giving you actual memory usage. RSS is more useful than VMSIZE as a general measurement, but RSS still includes the full memory consumed by each shared library. Here's a simplistic example: if you have 10 processes that each use 20kB of memory, and they all use the library foo.so which consumes 10kB of memory, each process will report 30kB memory usage even though foo.so only takes 10kB total.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/rothwerx/uptop
22

33
require (
44
github.com/cjbassi/drawille-go v0.1.0 // indirect
5-
github.com/gizak/termui v0.0.0-20190214045005-bb0b559103cb // indirect
5+
github.com/gizak/termui v0.0.0-20190214045005-bb0b559103cb
66
github.com/mattn/go-runewidth v0.0.4 // indirect
77
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
88
)

main.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
// Program version
24-
const version = "0.2"
24+
const version = "0.3"
2525

2626
// UID->username map cache
2727
var ucache = make(map[uint32]string)
@@ -197,15 +197,16 @@ func processIt(fpath string) (*Process, bool) {
197197
return nil, false
198198
}
199199

200+
// Fix this
200201
// Print header and then the contents of each Process
201-
func printProcesses(a []*Process) {
202-
fmt.Printf("%6s %-16s %-14s %5s %5s %5s %5s %-80s",
203-
"PID", "Name", "User", "Swap", "USS", "PSS", "RSS", "Command")
204-
for _, p := range a {
205-
fmt.Printf("%6d %-16s %-14s %5d %5d %5d %5d %-80s",
206-
p.PID, p.Name, p.User, p.Swap, p.USS, p.PSS, p.RSS, p.Command)
207-
}
208-
}
202+
// func printProcesses(a []*Process) {
203+
// fmt.Printf("%6s %-16s %-14s %5s %5s %5s %5s %-80s",
204+
// "PID", "Name", "User", "Swap", "USS", "PSS", "RSS", "Command")
205+
// for _, p := range a {
206+
// fmt.Printf("%6d %-16s %-14s %5d %5d %5d %5d %-80s",
207+
// p.PID, p.Name, p.User, p.Swap, p.USS, p.PSS, p.RSS, p.Command)
208+
// }
209+
// }
209210

210211
// Formats the processes for the termui table
211212
func tableFormat(a []*Process) [][]string {
@@ -288,18 +289,23 @@ func runTermui() {
288289
}
289290

290291
func main() {
292+
flag.Usage = func() {
293+
fmt.Fprintf(os.Stderr, "Once running, hit n, r, p, s, or u to sort by Name, RSS, PSS, SwapPSS, or USS. RSS is default.\n")
294+
flag.PrintDefaults()
295+
os.Exit(0)
296+
}
291297
wantVersion := flag.Bool("version", false, "Print the version")
292-
wantOnce := flag.Bool("once", false, "Print table once and exit")
293-
flag.StringVar(&sortKey, "sort", "rss", "Sort by name, rss, pss, swap, or uss")
298+
// wantOnce := flag.Bool("once", false, "Print table once and exit")
299+
flag.StringVar(&sortKey, "sort", "rss", "Start sorted by name, rss, pss, swap, or uss")
294300
flag.Parse()
295301
if *wantVersion {
296302
fmt.Println(version)
297303
os.Exit(0)
298304
}
299-
if *wantOnce {
300-
procs := GetProcesses("/proc")
301-
printProcesses(procs)
302-
os.Exit(0)
303-
}
305+
// if *wantOnce {
306+
// procs := GetProcesses("/proc")
307+
// printProcesses(procs)
308+
// os.Exit(0)
309+
// }
304310
runTermui()
305311
}

0 commit comments

Comments
 (0)