Add DHCP statistics
This commit is contained in:
parent
8512afbe6b
commit
10f58a72ea
|
@ -9,6 +9,7 @@ package data
|
||||||
type Statistics struct {
|
type Statistics struct {
|
||||||
NodeID string `json:"node_id"`
|
NodeID string `json:"node_id"`
|
||||||
Clients Clients `json:"clients"`
|
Clients Clients `json:"clients"`
|
||||||
|
DHCP *DHCP `json:"dhcp"`
|
||||||
RootFsUsage float64 `json:"rootfs_usage,omitempty"`
|
RootFsUsage float64 `json:"rootfs_usage,omitempty"`
|
||||||
LoadAverage float64 `json:"loadavg,omitempty"`
|
LoadAverage float64 `json:"loadavg,omitempty"`
|
||||||
Memory Memory `json:"memory,omitempty"`
|
Memory Memory `json:"memory,omitempty"`
|
||||||
|
@ -64,6 +65,22 @@ type Clients struct {
|
||||||
Total uint32 `json:"total"`
|
Total uint32 `json:"total"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DHCP struct
|
||||||
|
type DHCP struct {
|
||||||
|
// Packet counters
|
||||||
|
Decline uint32 `json:"dhcp_decline"`
|
||||||
|
Offer uint32 `json:"dhcp_offer"`
|
||||||
|
Ack uint32 `json:"dhcp_ack"`
|
||||||
|
Nak uint32 `json:"dhcp_nak"`
|
||||||
|
Request uint32 `json:"dhcp_request"`
|
||||||
|
Discover uint32 `json:"dhcp_discover"`
|
||||||
|
Inform uint32 `json:"dhcp_inform"`
|
||||||
|
Release uint32 `json:"dhcp_release"`
|
||||||
|
|
||||||
|
LeasesAllocated uint32 `json:"leases_allocated_4"`
|
||||||
|
LeasesPruned uint32 `json:"leases_pruned_4"`
|
||||||
|
}
|
||||||
|
|
||||||
// Memory struct
|
// Memory struct
|
||||||
type Memory struct {
|
type Memory struct {
|
||||||
Cached int64 `json:"cached"`
|
Cached int64 `json:"cached"`
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
const (
|
const (
|
||||||
MeasurementLink = "link" // Measurement for per-link statistics
|
MeasurementLink = "link" // Measurement for per-link statistics
|
||||||
MeasurementNode = "node" // Measurement for per-node statistics
|
MeasurementNode = "node" // Measurement for per-node statistics
|
||||||
|
MeasurementDHCP = "dhcp" // Measurement for DHCP server statistics
|
||||||
MeasurementGlobal = "global" // Measurement for summarized global statistics
|
MeasurementGlobal = "global" // Measurement for summarized global statistics
|
||||||
CounterMeasurementFirmware = "firmware" // Measurement for firmware statistics
|
CounterMeasurementFirmware = "firmware" // Measurement for firmware statistics
|
||||||
CounterMeasurementModel = "model" // Measurement for model statistics
|
CounterMeasurementModel = "model" // Measurement for model statistics
|
||||||
|
|
|
@ -141,5 +141,30 @@ func (conn *Connection) InsertNode(node *runtime.Node) {
|
||||||
|
|
||||||
conn.addPoint(MeasurementNode, tags, fields, time)
|
conn.addPoint(MeasurementNode, tags, fields, time)
|
||||||
|
|
||||||
|
// Add DHCP statistics
|
||||||
|
if dhcp := stats.DHCP; dhcp != nil {
|
||||||
|
fields := models.Fields{
|
||||||
|
"decline": dhcp.Decline,
|
||||||
|
"offer": dhcp.Offer,
|
||||||
|
"ack": dhcp.Ack,
|
||||||
|
"nak": dhcp.Nak,
|
||||||
|
"request": dhcp.Request,
|
||||||
|
"discover": dhcp.Discover,
|
||||||
|
"inform": dhcp.Inform,
|
||||||
|
"release": dhcp.Release,
|
||||||
|
|
||||||
|
"leases.allocated": dhcp.LeasesAllocated,
|
||||||
|
"leases.pruned": dhcp.LeasesPruned,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
tags.SetString("nodeid", stats.NodeID)
|
||||||
|
if nodeinfo := node.Nodeinfo; nodeinfo != nil {
|
||||||
|
tags.SetString("hostname", nodeinfo.Hostname)
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.addPoint(MeasurementDHCP, tags, fields, time)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue