mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
new: exporting hardware resources usage from api.rest
This commit is contained in:
parent
973c88fd31
commit
ee809b6083
1 changed files with 26 additions and 4 deletions
|
@ -35,11 +35,21 @@ type ifaceJSON struct {
|
||||||
Addresses []addrJSON `json:"addresses"`
|
Addresses []addrJSON `json:"addresses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type resourcesJSON struct {
|
||||||
|
NumCPU int `json:"cpus"`
|
||||||
|
MaxCPU int `json:"max_cpus"`
|
||||||
|
NumGoroutine int `json:"goroutines"`
|
||||||
|
Alloc uint64 `json:"alloc"`
|
||||||
|
Sys uint64 `json:"sys"`
|
||||||
|
NumGC uint32 `json:"gcs"`
|
||||||
|
}
|
||||||
|
|
||||||
type SessionJSON struct {
|
type SessionJSON struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
OS string `json:"os"`
|
OS string `json:"os"`
|
||||||
Arch string `json:"arch"`
|
Arch string `json:"arch"`
|
||||||
GoVersion string `json:"goversion"`
|
GoVersion string `json:"goversion"`
|
||||||
|
Resources resourcesJSON `json:"resources"`
|
||||||
Interfaces []ifaceJSON `json:"interfaces"`
|
Interfaces []ifaceJSON `json:"interfaces"`
|
||||||
Options core.Options `json:"options"`
|
Options core.Options `json:"options"`
|
||||||
Interface *network.Endpoint `json:"interface"`
|
Interface *network.Endpoint `json:"interface"`
|
||||||
|
@ -59,11 +69,23 @@ type SessionJSON struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) MarshalJSON() ([]byte, error) {
|
func (s *Session) MarshalJSON() ([]byte, error) {
|
||||||
|
var m runtime.MemStats
|
||||||
|
|
||||||
|
runtime.ReadMemStats(&m)
|
||||||
|
|
||||||
doc := SessionJSON{
|
doc := SessionJSON{
|
||||||
Version: core.Version,
|
Version: core.Version,
|
||||||
OS: runtime.GOOS,
|
OS: runtime.GOOS,
|
||||||
Arch: runtime.GOARCH,
|
Arch: runtime.GOARCH,
|
||||||
GoVersion: runtime.Version(),
|
GoVersion: runtime.Version(),
|
||||||
|
Resources: resourcesJSON{
|
||||||
|
NumCPU: runtime.NumCPU(),
|
||||||
|
MaxCPU: runtime.GOMAXPROCS(0),
|
||||||
|
NumGoroutine: runtime.NumGoroutine(),
|
||||||
|
Alloc: m.Alloc,
|
||||||
|
Sys: m.Sys,
|
||||||
|
NumGC: m.NumGC,
|
||||||
|
},
|
||||||
Interfaces: make([]ifaceJSON, 0),
|
Interfaces: make([]ifaceJSON, 0),
|
||||||
Options: s.Options,
|
Options: s.Options,
|
||||||
Interface: s.Interface,
|
Interface: s.Interface,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue