Skip to content

Commit

Permalink
feat: Harvest auto-support should include instance count in the colle…
Browse files Browse the repository at this point in the history
…ctor section
  • Loading branch information
cgrinds committed Aug 30, 2023
1 parent 4c81750 commit f613d1a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 34 deletions.
23 changes: 12 additions & 11 deletions cmd/collectors/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func (r *Rest) CollectAutoSupport(p *collector.Payload) {
exporterTypes = append(exporterTypes, exporter.GetClass())
}

var counters = make([]string, 0)
var counters = make([]string, 0, len(r.Prop.Counters))
for k := range r.Prop.Counters {
counters = append(counters, k)
}
Expand All @@ -598,6 +598,16 @@ func (r *Rest) CollectAutoSupport(p *collector.Payload) {
}

// Add collector information
md := r.GetMetadata()
info := collector.InstanceInfo{
Count: md.LazyValueInt64("instances", "data"),
DataPoints: md.LazyValueInt64("metrics", "data"),
PollTime: md.LazyValueInt64("poll_time", "data"),
APITime: md.LazyValueInt64("api_time", "data"),
ParseTime: md.LazyValueInt64("parse_time", "data"),
PluginTime: md.LazyValueInt64("plugin_time", "data"),
}

p.AddCollectorAsup(collector.AsupCollector{
Name: r.Name,
Query: r.Prop.Query,
Expand All @@ -608,6 +618,7 @@ func (r *Rest) CollectAutoSupport(p *collector.Payload) {
},
Schedules: schedules,
ClientTimeout: r.Client.Timeout.String(),
InstanceInfo: &info,
})

if (r.Name == "Rest" && (r.Object == "Volume" || r.Object == "Node")) || r.Name == "Ems" {
Expand All @@ -619,16 +630,6 @@ func (r *Rest) CollectAutoSupport(p *collector.Payload) {
}
p.Target.ClusterUUID = r.Client.Cluster().UUID

md := r.GetMetadata()
info := collector.InstanceInfo{
Count: md.LazyValueInt64("instances", "data"),
DataPoints: md.LazyValueInt64("metrics", "data"),
PollTime: md.LazyValueInt64("poll_time", "data"),
APITime: md.LazyValueInt64("api_time", "data"),
ParseTime: md.LazyValueInt64("parse_time", "data"),
PluginTime: md.LazyValueInt64("plugin_time", "data"),
}

if r.Object == "Node" || r.Name == "ems" {
var (
nodeIds []collector.ID
Expand Down
22 changes: 12 additions & 10 deletions cmd/collectors/storagegrid/storagegrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (s *StorageGrid) CollectAutoSupport(p *collector.Payload) {
exporterTypes = append(exporterTypes, exporter.GetClass())
}

var counters = make([]string, 0)
var counters = make([]string, 0, len(s.Props.Counters))
for k := range s.Props.Counters {
counters = append(counters, k)
}
Expand All @@ -520,6 +520,16 @@ func (s *StorageGrid) CollectAutoSupport(p *collector.Payload) {
}

// Add collector information
md := s.GetMetadata()
info := collector.InstanceInfo{
Count: md.LazyValueInt64("instances", "data"),
DataPoints: md.LazyValueInt64("metrics", "data"),
PollTime: md.LazyValueInt64("poll_time", "data"),
APITime: md.LazyValueInt64("api_time", "data"),
ParseTime: md.LazyValueInt64("parse_time", "data"),
PluginTime: md.LazyValueInt64("plugin_time", "data"),
}

p.AddCollectorAsup(collector.AsupCollector{
Name: s.Name,
Query: s.Props.Query,
Expand All @@ -530,6 +540,7 @@ func (s *StorageGrid) CollectAutoSupport(p *collector.Payload) {
},
Schedules: schedules,
ClientTimeout: s.client.Timeout.String(),
InstanceInfo: &info,
})

version := s.client.Cluster.Version
Expand All @@ -551,15 +562,6 @@ func (s *StorageGrid) CollectAutoSupport(p *collector.Payload) {
}

if s.Object == "Tenant" {
md := s.GetMetadata()
info := collector.InstanceInfo{
Count: md.LazyValueInt64("instances", "data"),
DataPoints: md.LazyValueInt64("metrics", "data"),
PollTime: md.LazyValueInt64("poll_time", "data"),
APITime: md.LazyValueInt64("api_time", "data"),
ParseTime: md.LazyValueInt64("parse_time", "data"),
PluginTime: md.LazyValueInt64("plugin_time", "data"),
}
p.Tenants = &info
}
}
Expand Down
27 changes: 14 additions & 13 deletions cmd/collectors/zapi/collector/zapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ func (z *Zapi) PollData() (map[string]*matrix.Matrix, error) {
}

for _, instanceElem := range instances {
//c.logger.Printf(c.Prefix, "Handling instance element <%v> [%s]", &instance, instance.GetName())
// c.logger.Printf(c.Prefix, "Handling instance element <%v> [%s]", &instance, instance.GetName())
keys, found := instanceElem.SearchContent(z.shortestPathPrefix, z.instanceKeyPaths)
//logger.Debug(z.Prefix, "Fetched instance keys: %s", strings.Join(keys, "."))
// logger.Debug(z.Prefix, "Fetched instance keys: %s", strings.Join(keys, "."))

if !found {
//logger.Debug(z.Prefix, "Skipping instance: no keys fetched")
// logger.Debug(z.Prefix, "Skipping instance: no keys fetched")
continue
}

Expand Down Expand Up @@ -451,6 +451,16 @@ func (z *Zapi) CollectAutoSupport(p *collector.Payload) {
}

// Add collector information
md := z.GetMetadata()
info := collector.InstanceInfo{
Count: md.LazyValueInt64("instances", "data"),
DataPoints: md.LazyValueInt64("metrics", "data"),
PollTime: md.LazyValueInt64("poll_time", "data"),
APITime: md.LazyValueInt64("api_time", "data"),
ParseTime: md.LazyValueInt64("parse_time", "data"),
PluginTime: md.LazyValueInt64("plugin_time", "data"),
}

p.AddCollectorAsup(collector.AsupCollector{
Name: z.Name,
Query: z.Query,
Expand All @@ -462,6 +472,7 @@ func (z *Zapi) CollectAutoSupport(p *collector.Payload) {
},
Schedules: schedules,
ClientTimeout: clientTimeout,
InstanceInfo: &info,
})

if z.Name == "Zapi" && (z.Object == "Volume" || z.Object == "Node") {
Expand All @@ -472,16 +483,6 @@ func (z *Zapi) CollectAutoSupport(p *collector.Payload) {
}
p.Target.ClusterUUID = z.Client.ClusterUUID()

md := z.GetMetadata()
info := collector.InstanceInfo{
Count: md.LazyValueInt64("instances", "data"),
DataPoints: md.LazyValueInt64("metrics", "data"),
PollTime: md.LazyValueInt64("poll_time", "data"),
APITime: md.LazyValueInt64("api_time", "data"),
ParseTime: md.LazyValueInt64("parse_time", "data"),
PluginTime: md.LazyValueInt64("plugin_time", "data"),
}

if z.Object == "Node" {
var (
nodeIds []collector.ID
Expand Down
1 change: 1 addition & 0 deletions cmd/poller/collector/asup.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type AsupCollector struct {
Schedules []Schedule
Exporters []string
Counters Counters
InstanceInfo *InstanceInfo `json:"InstanceInfo,omitempty"`
}

const (
Expand Down

0 comments on commit f613d1a

Please sign in to comment.