Skip to content

Commit

Permalink
ovs: allow user to disable ovs metrics via config
Browse files Browse the repository at this point in the history
  • Loading branch information
masco committed Jan 31, 2019
1 parent 723e8e4 commit e848c87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/spf13/pflag"
"github.com/spf13/viper"

// Viper remote client need to be internally initialized
_ "github.com/spf13/viper/remote"

Expand Down Expand Up @@ -143,6 +144,7 @@ func init() {
cfg.SetDefault("ovs.ovsdb", "unix:///var/run/openvswitch/db.sock")
cfg.SetDefault("ovs.oflow.enable", false)
cfg.SetDefault("ovs.oflow.openflow_versions", []string{"OpenFlow10"})
cfg.SetDefault("ovs.enable_stats", false)

cfg.SetDefault("sflow.port_min", 6345)
cfg.SetDefault("sflow.port_max", 6355)
Expand Down
1 change: 1 addition & 0 deletions etc/skydive.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ ovs:
# at least locally
# % sudo ovs-appctl -t ovsdb-server ovsdb-server/add-remote ptcp:6400:127.0.0.1
# ovsdb: unix:///var/run/openvswitch/db.sock
# enable_stats: false

oflow:
# Enable the parsing of openflow rules (disabled by default)
Expand Down
13 changes: 9 additions & 4 deletions topology/probes/ovsdb/ovsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Probe struct {
portToIntf map[string]*graph.Node
portToBridge map[string]*graph.Node
cancel context.CancelFunc
enableStats bool
}

func isOvsInterfaceType(t string) bool {
Expand Down Expand Up @@ -402,7 +403,7 @@ func (o *Probe) OnOvsInterfaceAdd(monitor *ovsdb.OvsMonitor, uuid string, row *l
}
}

if field, ok := row.New.Fields["statistics"]; ok {
if field, ok := row.New.Fields["statistics"]; ok && o.enableStats {
now := time.Now()

statistics := field.(libovsdb.OvsMap)
Expand Down Expand Up @@ -626,10 +627,12 @@ func (o *Probe) Stop() {
}

// NewProbe creates a new graph OVS database probe
func NewProbe(g *graph.Graph, n *graph.Node, p string, t string) *Probe {
func NewProbe(g *graph.Graph, n *graph.Node, p string, t string, enableStats bool) *Probe {
mon := ovsdb.NewOvsMonitor(p, t)
mon.ExcludeColumn("*", "statistics")
mon.IncludeColumn("Interface", "statistics")
if enableStats {
mon.IncludeColumn("Interface", "statistics")
}

ctx, cancel := context.WithCancel(context.Background())
o := &Probe{
Expand All @@ -643,6 +646,7 @@ func NewProbe(g *graph.Graph, n *graph.Node, p string, t string) *Probe {
OvsMon: mon,
OvsOfProbe: NewOvsOfProbe(ctx, g, n, mon.Target),
cancel: cancel,
enableStats: enableStats,
}

return o
Expand Down Expand Up @@ -672,6 +676,7 @@ func NewProbeFromConfig(g *graph.Graph, n *graph.Node) *Probe {
protocol = "tcp"
target = fmt.Sprintf("%s:%d", sa.Addr, sa.Port)
}
enableStats := config.GetBool("ovs.enable_stats")

return NewProbe(g, n, protocol, target)
return NewProbe(g, n, protocol, target, enableStats)
}

0 comments on commit e848c87

Please sign in to comment.