Skip to content

Commit

Permalink
add reset porocess for ovs interface metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Mar 9, 2022
1 parent a3618bc commit 47a16c3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/pinger/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (e *Exporter) ovsMetricsUpdate() {
}

func (e *Exporter) exportOvsStatusGauge() {
metricOvsHealthyStatus.Reset()
result := e.getOvsStatus()
for k, v := range result {
if v {
Expand All @@ -124,6 +125,7 @@ func (e *Exporter) exportOvsStatusGauge() {
}

func (e *Exporter) exportOvsInfoGauge() {
metricOvsInfo.Reset()
if err := e.Client.GetSystemInfo(); err != nil {
klog.Errorf("Failed to get System Info")
return
Expand All @@ -134,6 +136,7 @@ func (e *Exporter) exportOvsInfoGauge() {
}

func (e *Exporter) exportOvsLogFileSizeGauge() {
metricLogFileSize.Reset()
components := []string{
"ovsdb-server",
"ovs-vswitchd",
Expand All @@ -150,6 +153,7 @@ func (e *Exporter) exportOvsLogFileSizeGauge() {
}

func (e *Exporter) exportOvsDbFileSizeGauge() {
metricDbFileSize.Reset()
database := "OVS_DB"
fileInfo, err := os.Stat(e.Client.Database.Vswitch.File.Data.Path)
if err != nil {
Expand All @@ -170,6 +174,7 @@ func (e *Exporter) exportOvsDpGauge() {
return
}

resetOvsDatapathMetrics()
for _, datapathName := range datapaths {
err = e.setOvsDpIfMetric(datapathName)
if err != nil {
Expand All @@ -185,6 +190,7 @@ func (e *Exporter) exportOvsInterfaceGauge() {
return
}

resetOvsInterfaceMetrics()
for _, intf := range intfs {
e.setOvsInterfaceMetric(intf)
}
Expand Down
41 changes: 41 additions & 0 deletions pkg/pinger/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,44 @@ func (e *Exporter) setOvsInterfaceStatisticsMetric(intf *ovsdb.OvsInterface) {
}
}
}

func resetOvsDatapathMetrics() {
metricOvsDpFlowsTotal.Reset()
metricOvsDpFlowsLookupHit.Reset()
metricOvsDpFlowsLookupMissed.Reset()
metricOvsDpFlowsLookupLost.Reset()

metricOvsDpMasksHit.Reset()
metricOvsDpMasksTotal.Reset()
metricOvsDpMasksHitRatio.Reset()

metricOvsDp.Reset()
metricOvsDpTotal.Reset()
metricOvsDpIf.Reset()
metricOvsDpIfTotal.Reset()
}

func resetOvsInterfaceMetrics() {
interfaceMain.Reset()
interfaceAdminState.Reset()
interfaceLinkState.Reset()
interfaceMacInUse.Reset()
interfaceMtu.Reset()
interfaceOfPort.Reset()
interfaceIfIndex.Reset()

interfaceStatRxCrcError.Reset()
interfaceStatRxDropped.Reset()
interfaceStatRxFrameError.Reset()
interfaceStatRxMissedError.Reset()
interfaceStatRxOverrunError.Reset()
interfaceStatRxErrorsTotal.Reset()
interfaceStatRxPackets.Reset()
interfaceStatRxBytes.Reset()

interfaceStatTxPackets.Reset()
interfaceStatTxBytes.Reset()
interfaceStatTxDropped.Reset()
interfaceStatTxErrorsTotal.Reset()
interfaceStatCollisions.Reset()
}

0 comments on commit 47a16c3

Please sign in to comment.