Skip to content

Commit

Permalink
add link status of PF interfacesto InterfaceStat metric
Browse files Browse the repository at this point in the history
  • Loading branch information
vlorinc committed Oct 3, 2024
1 parent 70007cd commit c2a5471
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cli/dpservice-exporter/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ func Update(conn net.Conn, hostname string, log *logrus.Logger) error {
if err != nil {
return err
}
// set link status only for PF interfaces
// if interface name doesn't contain "representor" it is PF interface
if !strings.Contains(ethdevInfo.Value.Name, "representor") {
var ethdevLinkStatus EthdevLinkStatus
err = queryTelemetry(conn, log, fmt.Sprintf("/ethdev/link_status,%d", id), &ethdevLinkStatus)
if err != nil {
return err
}
var linkStatus float64
if strings.ToLower(ethdevLinkStatus.Value.Status) == "up" {
linkStatus = float64(1)
} else if strings.ToLower(ethdevLinkStatus.Value.Status) == "down" {
linkStatus = float64(0)
} else {
// if there is problem getting the link status skip this update
continue
}
InterfaceStat.With(prometheus.Labels{"interface": ethdevInfo.Value.Name, "stat_name": "link_status"}).Set(linkStatus)
}

var ethdevXstats EthdevXstats
err = queryTelemetry(conn, log, fmt.Sprintf("/ethdev/xstats,%d", id), &ethdevXstats)
Expand Down
8 changes: 8 additions & 0 deletions cli/dpservice-exporter/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ type EthdevInfo struct {
} `json:"/ethdev/info"`
}

type EthdevLinkStatus struct {
Value struct {
Duplex string `json:"duplex,omitempty"`
Speed int `json:"speed,omitempty"`
Status string `json:"status,omitempty"`
} `json:"/ethdev/link_status"`
}

type EthdevXstats struct {
Value map[string]float64 `json:"/ethdev/xstats"`
}
Expand Down

0 comments on commit c2a5471

Please sign in to comment.