Skip to content

Commit

Permalink
refactored multiline output, was pretty ugly
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmittag committed Jun 24, 2022
1 parent cf76034 commit 101e1fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
55 changes: 25 additions & 30 deletions l0la.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,40 @@ import (
"fmt"
"github.com/gosuri/uilive"
. "github.com/logrusorgru/aurora"
"io"
"time"
)

const Version = "v0.1.1"

func Watch(pid int) {
l01 := uilive.New()
l01.RefreshInterval = time.Hour * 24 * 30
l01.Start()
l02 := l01.Newline()
l03 := l01.Newline()
l04 := l01.Newline()
l05 := l01.Newline()
l06 := l01.Newline()
l07 := l01.Newline()
l08 := l01.Newline()
l09 := l01.Newline()
l10 := l01.Newline()
l11 := l01.Newline()
l12 := l01.Newline()
l13 := l01.Newline()
defer l01.Stop()
lines := make([]io.Writer, 0)
l0 := uilive.New()
l0.RefreshInterval = time.Hour * 24 * 30
l0.Start()
defer l0.Stop()
lines = append(lines, l0)

for i := 0; i < 13; i++ {
lines = append(lines, lines[0].(*uilive.Writer).Newline())
}

pad := 26
for {
fmt.Fprint(l01, Logo()+"\n")
fmt.Fprintf(l02, "watching pid: %v\n", pid)
fmt.Fprintf(l03, "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n")
fmt.Fprintf(l04, "┃ TCP conns ┃ %s ┃\n", Red(LPad(pad, FGroup(Conngrep(pid)))))
fmt.Fprintf(l05, "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(l06, "┃ Open files ┃ %s ┃\n", Yellow(LPad(pad, FGroup(Filegrep(pid)))))
fmt.Fprintf(l07, "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(l08, "┃ Threads ┃ %s ┃\n", Blue(LPad(pad, FGroup(Threadgrep(pid)))))
fmt.Fprintf(l09, "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(l10, "┃ RSS bytes ┃ %s ┃\n", Gray(8, LPad(pad, FGroup(Memgrep(pid)))))
fmt.Fprintf(l11, "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(l12, "┃ CPU percent ┃ %s ┃\n", Magenta(LPad(pad, Cpugrep(pid))))
fmt.Fprintf(l13, "┗━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n")
l01.Flush()
fmt.Fprint(lines[0], Logo()+"\n")
fmt.Fprintf(lines[0], "watching pid: %v\n", pid)
fmt.Fprintf(lines[0], "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n")
fmt.Fprintf(lines[0], "┃ TCP conns ┃ %s ┃\n", Red(LPad(pad, FGroup(Conngrep(pid)))))
fmt.Fprintf(lines[0], "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(lines[0], "┃ Open files ┃ %s ┃\n", Yellow(LPad(pad, FGroup(Filegrep(pid)))))
fmt.Fprintf(lines[0], "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(lines[0], "┃ Threads ┃ %s ┃\n", Blue(LPad(pad, FGroup(Threadgrep(pid)))))
fmt.Fprintf(lines[0], "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(lines[0], "┃ RSS bytes ┃ %s ┃\n", Gray(8, LPad(pad, FGroup(Memgrep(pid)))))
fmt.Fprintf(lines[0], "┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n")
fmt.Fprintf(lines[0], "┃ CPU percent ┃ %s ┃\n", Magenta(LPad(pad, Cpugrep(pid))))
fmt.Fprintf(lines[0], "┗━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n")
l0.Flush()
time.Sleep(time.Millisecond * 500)
}
}
Expand Down

0 comments on commit 101e1fa

Please sign in to comment.