Skip to content

Commit

Permalink
[TASK] add procstat
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed May 5, 2018
1 parent 10f58a7 commit 8417340
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
19 changes: 17 additions & 2 deletions data/statistics.go
Expand Up @@ -30,8 +30,23 @@ type Statistics struct {
MgmtTx *Traffic `json:"mgmt_tx"`
MgmtRx *Traffic `json:"mgmt_rx"`
} `json:"traffic,omitempty"`
Switch map[string]*SwitchPort `json:"switch,omitempty"`
Wireless WirelessStatistics `json:"wireless,omitempty"`
Switch map[string]*SwitchPort `json:"switch,omitempty"`
Wireless WirelessStatistics `json:"wireless,omitempty"`
ProcStats *struct {
CPU struct {
User uint64 `json:"user"`
Nice uint64 `json:"nice"`
System uint64 `json:"system"`
Idle uint64 `json:"idle"`
IOWait uint64 `json:"iowait"`
IRQ uint64 `json:"irq"`
SoftIRQ uint64 `json:"softirq"`
} `json:"cpu"`
Intr uint64 `json:"intr"`
CTXT uint64 `json:"ctxt"`
SoftIRQ uint64 `json:"softirq"`
Processes uint64 `json:"processes"`
} `json:"stat,omitempty"`
}

// MeshVPNPeerLink struct
Expand Down
13 changes: 13 additions & 0 deletions database/influxdb/node.go
Expand Up @@ -106,6 +106,19 @@ func (conn *Connection) InsertNode(node *runtime.Node) {
// total is the sum of all protocols
fields["neighbours.total"] = batadv + lldp
}
if procstat := stats.ProcStats; procstat != nil {
fields["stat.cpu.user"] = procstat.CPU.User
fields["stat.cpu.nice"] = procstat.CPU.Nice
fields["stat.cpu.system"] = procstat.CPU.System
fields["stat.cpu.idle"] = procstat.CPU.Idle
fields["stat.cpu.iowait"] = procstat.CPU.IOWait
fields["stat.cpu.irq"] = procstat.CPU.IRQ
fields["stat.cpu.softirq"] = procstat.CPU.SoftIRQ
fields["stat.intr"] = procstat.Intr
fields["stat.ctxt"] = procstat.CTXT
fields["stat.softirq"] = procstat.SoftIRQ
fields["stat.processes"] = procstat.Processes
}

if t := stats.Traffic.Rx; t != nil {
fields["traffic.rx.bytes"] = int64(t.Bytes)
Expand Down

0 comments on commit 8417340

Please sign in to comment.