[ADDED] Ability to get the server's HTTP Handler

This will allow applications (for instance NATS Streaming Server)
to add new endpoints to the NATS http server.

Resolves #480
This commit is contained in:
Ivan Kozlovic
2017-04-27 16:33:55 -06:00
parent a94b5e0f4c
commit 09f4b85a66
3 changed files with 32 additions and 2 deletions

View File

@@ -3,18 +3,18 @@
package pse
import (
"errors"
"fmt"
"os"
"os/exec"
)
// ProcUsage returns CPU usage
func ProcUsage(pcpu *float64, rss, vss *int64) error {
pidStr := fmt.Sprintf("%d", os.Getpid())
out, err := exec.Command("ps", "o", "pcpu=,rss=,vsz=", "-p", pidStr).Output()
if err != nil {
*rss, *vss = -1, -1
return errors.New(fmt.Sprintf("ps call failed:%v", err))
return fmt.Errorf("ps call failed:%v", err)
}
fmt.Sscanf(string(out), "%f %d %d", pcpu, rss, vss)
*rss *= 1024 // 1k blocks, want bytes.