Skip to content

Commit

Permalink
Added basic support for processes reading headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders Brander committed Sep 26, 2016
1 parent 6bd5983 commit 589e35d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,19 @@ MAINLOOP:
fmt.Printf("\033[45m \033[0m")
case Idle:
fmt.Printf("\033[42m \033[0m")
case ReadingHeaders:
fmt.Printf("\033[43m \033[0m")
default:
fmt.Printf("\033[41m \033[0m")
}

dur := time.Microsecond * time.Duration(pro.RequestDuration)
dur := time.Duration(0)

requestDuration, err := pro.RequestDuration.Int64()
if err != nil {
dur = time.Microsecond * time.Duration(requestDuration)
}

up := time.Second * time.Duration(pro.StartSince)

// Print running processes in bold.
Expand Down
38 changes: 22 additions & 16 deletions process.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
package main

import "time"
import (
"encoding/json"
"time"
)

type (
process struct {
Pid int `json:"pid"`
LastRequestCPU float64 `json:"last request cpu"`
LastRequestMemory int `json:"last request memory"`
State string `json:"state"`
User string `json:"user"`
ContentLength int `json:"content length"`
RequestURI string `json:"request uri"`
RequestDuration int `json:"request duration"`
Requests int `json:"requests"`
StartSince int `json:"start since"`
StartTime time.Time `json:"start time_FIXME"`
Script string `json:"script"`
RequestMethod string `json:"request method"`
Pid int `json:"pid"`
LastRequestCPU float64 `json:"last request cpu"`
LastRequestMemory int `json:"last request memory"`
State string `json:"state"`
User string `json:"user"`
ContentLength int `json:"content length"`
RequestURI string `json:"request uri"`
// RequestDuration will be bigger than 2^64 when the PHP process is
// reading headers, we have to use json.Number here.
RequestDuration json.Number `json:"request duration"`
Requests int `json:"requests"`
StartSince int `json:"start since"`
StartTime time.Time `json:"start time_FIXME"`
Script string `json:"script"`
RequestMethod string `json:"request method"`
}
)

// Process states.
const (
Running = "Running"
Idle = "Idle"
Running = "Running"
Idle = "Idle"
ReadingHeaders = "Reading headers"
)

0 comments on commit 589e35d

Please sign in to comment.