Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ovn monitor #3903

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ require (
github.com/evanphx/json-patch/v5 v5.9.0
github.com/go-logr/stdr v1.2.2
github.com/google/uuid v1.6.0
github.com/greenpau/ovsdb v1.0.3
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.0
github.com/k8snetworkplumbingwg/sriovnet v1.2.0
github.com/kubeovn/go-iptables v0.0.0-20230322103850-8619a8ab3dca
github.com/kubeovn/gonetworkmanager/v2 v2.0.0-20230905082151-e28c4d73a589
github.com/kubeovn/ovsdb v0.0.0-20240410091831-5dd26006c475
github.com/mdlayher/arp v0.0.0-20220512170110-6706a2966875
github.com/moby/sys/mountinfo v0.7.1
github.com/onsi/ginkgo/v2 v2.17.1
Expand Down Expand Up @@ -285,7 +285,6 @@ require (

replace (
github.com/alauda/felix => github.com/kubeovn/felix v0.0.0-20220325073257-c8a0f705d139
github.com/greenpau/ovsdb => github.com/kubeovn/ovsdb v0.0.0-20221213053943-9372db56919f
github.com/mdlayher/arp => github.com/kubeovn/arp v0.0.0-20240218024213-d9612a263f68
github.com/openshift/client-go => github.com/openshift/client-go v0.0.1
github.com/ovn-org/libovsdb => github.com/kubeovn/libovsdb v0.0.0-20240218023647-f0bc3ce57fcd
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1665,8 +1665,8 @@ github.com/kubeovn/libovsdb v0.0.0-20240218023647-f0bc3ce57fcd h1:GhgvSBFKEkVNgD
github.com/kubeovn/libovsdb v0.0.0-20240218023647-f0bc3ce57fcd/go.mod h1:pTnlGt1JZrncr6pJn/Fhnp3FFTMQRaTVxiSKBLVGa5s=
github.com/kubeovn/netlink v0.0.0-20240218024530-d3ada5dae96f h1:3hH6U+CRilak3SxAX9YykAXxxAY25GTEJANLlJNE2jU=
github.com/kubeovn/netlink v0.0.0-20240218024530-d3ada5dae96f/go.mod h1:KjTlcXwJZNXDSeBgPMWF8yKVqYrIP1cpe5HfyfEi4Ls=
github.com/kubeovn/ovsdb v0.0.0-20221213053943-9372db56919f h1:nm0ZlQesCje/A5D0LyWfaSUM8/0ro9PVpwd8hVbLBeM=
github.com/kubeovn/ovsdb v0.0.0-20221213053943-9372db56919f/go.mod h1:LAd0qoeAAm/QyZcpxN2BnpndM2/dhZt+/kokPvcxKcE=
github.com/kubeovn/ovsdb v0.0.0-20240410091831-5dd26006c475 h1:KZba2Kj9TXCUdUSqOR3eiy4VvkkIyhDVImYmYs6GQWU=
github.com/kubeovn/ovsdb v0.0.0-20240410091831-5dd26006c475/go.mod h1:LAd0qoeAAm/QyZcpxN2BnpndM2/dhZt+/kokPvcxKcE=
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 h1:nHHjmvjitIiyPlUHk/ofpgvBcNcawJLtf4PYHORLjAA=
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys=
github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
Expand Down
10 changes: 8 additions & 2 deletions pkg/ovnmonitor/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/greenpau/ovsdb"
"github.com/kubeovn/ovsdb"
"k8s.io/klog/v2"

"github.com/kubeovn/kube-ovn/pkg/util"
Expand Down Expand Up @@ -174,6 +174,12 @@ func (e *Exporter) exportOvnStatusGauge() {
for k, v := range result {
metricOvnHealthyStatus.WithLabelValues(e.Client.System.Hostname, k).Set(float64(v))
}

metricOvnHealthyStatusContent.Reset()
statusResult := e.getOvnStatusContent()
for k, v := range statusResult {
metricOvnHealthyStatusContent.WithLabelValues(e.Client.System.Hostname, k, v).Set(float64(1))
}
}

func (e *Exporter) exportOvnLogFileSizeGauge() {
Expand Down Expand Up @@ -223,7 +229,7 @@ func (e *Exporter) exportOvnChassisGauge() {
e.IncrementErrorCounter()
} else {
for _, vtep := range vteps {
metricChassisInfo.WithLabelValues(e.Client.System.Hostname, vtep.UUID, vtep.Name, vtep.IPAddress.String()).Set(1)
metricChassisInfo.WithLabelValues(vtep.Hostname, vtep.UUID, vtep.Name, vtep.IPAddress.String()).Set(1)
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/ovnmonitor/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ var (
"component",
})

metricOvnHealthyStatusContent = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: metricNamespace,
Name: "ovn_status_content",
Help: "OVN Health Status. The values are always 1. While the value of status label is the really status report.",
},
[]string{
"hostname",
"component",
"status",
})

metricRequestErrorNums = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: metricNamespace,
Expand Down Expand Up @@ -465,6 +477,7 @@ var (
func registerOvnMetrics() {
// ovn status metrics
prometheus.MustRegister(metricOvnHealthyStatus)
prometheus.MustRegister(metricOvnHealthyStatusContent)
prometheus.MustRegister(metricRequestErrorNums)
prometheus.MustRegister(metricLogFileSize)
prometheus.MustRegister(metricDBFileSize)
Expand Down
32 changes: 31 additions & 1 deletion pkg/ovnmonitor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"sync/atomic"

"github.com/greenpau/ovsdb"
"github.com/kubeovn/ovsdb"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -71,6 +71,36 @@ func (e *Exporter) getOvnStatus() map[string]int {
return result
}

func (e *Exporter) getOvnStatusContent() map[string]string {
result := map[string]string{"ovsdb-server-northbound": "", "ovsdb-server-southbound": ""}

// get ovn-northbound status
cmdstr := "ovs-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound"
cmd := exec.Command("sh", "-c", cmdstr)
output, err := cmd.CombinedOutput()
if err != nil {
klog.Errorf("get ovn-northbound status failed, err %v", err)
}
if strings.Contains(string(output), "Servers:") {
servers := strings.Split(string(output), "Servers:")[1]
result["ovsdb-server-northbound"] = servers
}

// get ovn-southbound status
cmdstr = "ovs-appctl -t /var/run/ovn/ovnsb_db.ctl cluster/status OVN_Southbound"
cmd = exec.Command("sh", "-c", cmdstr)
output, err = cmd.CombinedOutput()
if err != nil {
klog.Errorf("get ovn-southbound status failed, err %v", err)
}
if strings.Contains(string(output), "Servers:") {
servers := strings.Split(string(output), "Servers:")[1]
result["ovsdb-server-southbound"] = servers
}

return result
}

func getClusterEnableState(dbName string) (bool, error) {
cmdstr := fmt.Sprintf("ovsdb-tool db-is-clustered %s", dbName)
cmd := exec.Command("sh", "-c", cmdstr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pinger/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"
"time"

"github.com/greenpau/ovsdb"
"github.com/kubeovn/ovsdb"
"k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/pinger/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync/atomic"

"github.com/greenpau/ovsdb"
"github.com/kubeovn/ovsdb"
"k8s.io/klog/v2"
)

Expand Down
Loading