Skip to content

Commit

Permalink
makes peak assessment optional
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hausenblas <[email protected]>
  • Loading branch information
mhausenblas committed Feb 15, 2020
1 parent d655491 commit c6dc02b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ $ rsg --target test/test --api-path /ping --api-port 8080
You can also specify a file explicitly and suppress the status updates, like so:

```sh
$ go run main.go --target test/test \
--api-path /ping --api-port 8080 \
--export-findings ./results.json 2>/dev/null
$ rsg --target test/test \
--api-path /ping --api-port 8080 \
--export-findings ./results.json 2>/dev/null
```

Then, you could pull out specific results, say, using `jq`:
Expand Down
31 changes: 17 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func main() {
peakf = make(chan Findings, 1)
icmd = exec.Command(*target)
pcmd = exec.Command(*target)
ifs := Findings{}
pfs := Findings{}

// Perform idle state assessment:
go assessidle()
Expand All @@ -65,28 +67,29 @@ func main() {
log.Fatalf("Can't stop process: %v\n", err)
}
}
ifs := <-idlef
ifs = <-idlef
log.Printf("Found idle state resource usage. MEMORY: %vkB CPU: %vms (user)/%vms (sys)",
ifs.MemoryMaxRSS/1000,
ifs.CPUuser/1000,
ifs.CPUsys/1000)

// Perform peak state assessment:
go assesspeak(*apiport, *apipath, peakhammerpause)
<-time.After(psampletime)
log.Printf("Peak state assessment of %v completed\n", *target)
if pcmd.Process != nil {
err := pcmd.Process.Signal(os.Interrupt)
if err != nil {
log.Fatalf("Can't stop process: %v\n", err)
if *apipath != "" && *apiport != "" {
go assesspeak(*apiport, *apipath, peakhammerpause)
<-time.After(psampletime)
log.Printf("Peak state assessment of %v completed\n", *target)
if pcmd.Process != nil {
err := pcmd.Process.Signal(os.Interrupt)
if err != nil {
log.Fatalf("Can't stop process: %v\n", err)
}
}
pfs = <-peakf
log.Printf("Found peak state resource usage. MEMORY: %vkB CPU: %vms (user)/%vms (sys)",
pfs.MemoryMaxRSS/1000,
pfs.CPUuser/1000,
pfs.CPUsys/1000)
}
pfs := <-peakf
log.Printf("Found peak state resource usage. MEMORY: %vkB CPU: %vms (user)/%vms (sys)",
pfs.MemoryMaxRSS/1000,
pfs.CPUuser/1000,
pfs.CPUsys/1000)

// Handle export of findings:
export(ifs, pfs, *exportfile)
}
Expand Down

0 comments on commit c6dc02b

Please sign in to comment.