mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
add pidcount,io to mock collector
This commit is contained in:
5
Makefile
5
Makefile
@@ -1,7 +1,8 @@
|
|||||||
NAME=ctop
|
NAME=ctop
|
||||||
VERSION=$(shell cat VERSION)
|
VERSION=$(shell cat VERSION)
|
||||||
BUILD=$(shell git rev-parse --short HEAD)
|
BUILD=$(shell git rev-parse --short HEAD)
|
||||||
LD_FLAGS="-w -X main.version=$(VERSION) -X main.build=$(BUILD) -extldflags=-Wl,--allow-multiple-definition"
|
EXT_LD_FLAGS="-Wl,--allow-multiple-definition"
|
||||||
|
LD_FLAGS="-w -X main.version=$(VERSION) -X main.build=$(BUILD) -extldflags=$(EXT_LD_FLAGS)"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build/ release/
|
rm -rf build/ release/
|
||||||
@@ -11,7 +12,7 @@ build:
|
|||||||
CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o ctop
|
CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o ctop
|
||||||
|
|
||||||
build-dev:
|
build-dev:
|
||||||
go build -ldflags "-w -X main.version=$(VERSION)-dev -X main.build=$(BUILD)"
|
go build -ldflags "-w -X main.version=$(VERSION)-dev -X main.build=$(BUILD) -extldflags=$(EXT_LD_FLAGS)"
|
||||||
|
|
||||||
build-all:
|
build-all:
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ func (c *Mock) run() {
|
|||||||
rand.Seed(int64(time.Now().Nanosecond()))
|
rand.Seed(int64(time.Now().Nanosecond()))
|
||||||
defer close(c.stream)
|
defer close(c.stream)
|
||||||
|
|
||||||
|
// set to random static value, once
|
||||||
|
c.Pids = rand.Intn(12)
|
||||||
|
c.IOBytesRead = rand.Int63n(8098) * c.aggression
|
||||||
|
c.IOBytesWrite = rand.Int63n(8098) * c.aggression
|
||||||
|
|
||||||
for {
|
for {
|
||||||
c.CPUUtil += rand.Intn(2) * int(c.aggression)
|
c.CPUUtil += rand.Intn(2) * int(c.aggression)
|
||||||
if c.CPUUtil >= 100 {
|
if c.CPUUtil >= 100 {
|
||||||
|
|||||||
12
main.go
12
main.go
@@ -77,12 +77,6 @@ func main() {
|
|||||||
config.Toggle("sortReversed")
|
config.Toggle("sortReversed")
|
||||||
}
|
}
|
||||||
|
|
||||||
defer Shutdown()
|
|
||||||
// init grid, cursor, header
|
|
||||||
cursor = NewGridCursor(*connectorFlag)
|
|
||||||
cGrid = compact.NewCompactGrid()
|
|
||||||
header = widgets.NewCTopHeader()
|
|
||||||
|
|
||||||
// init ui
|
// init ui
|
||||||
if *invertFlag {
|
if *invertFlag {
|
||||||
InvertColorMap()
|
InvertColorMap()
|
||||||
@@ -92,6 +86,12 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer Shutdown()
|
||||||
|
// init grid, cursor, header
|
||||||
|
cursor = NewGridCursor(*connectorFlag)
|
||||||
|
cGrid = compact.NewCompactGrid()
|
||||||
|
header = widgets.NewCTopHeader()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
exit := Display()
|
exit := Display()
|
||||||
if exit {
|
if exit {
|
||||||
|
|||||||
Reference in New Issue
Block a user