From 8099c2418414a8bf5d6d5a56c2c67f59d3780045 Mon Sep 17 00:00:00 2001 From: Hardikl <83282894+Hardikl@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:01:31 +0530 Subject: [PATCH] feat: adding quotas detail in asup (#3020) * feat: adding quotas detail in asup * feat: Adding only PluginInstances field in asup * feat: minor changes --- cmd/collectors/rest/plugins/qtree/qtree.go | 2 ++ cmd/collectors/rest/rest.go | 8 +++++++- cmd/collectors/zapi/collector/zapi.go | 12 +++++++++--- cmd/collectors/zapi/plugins/qtree/qtree.go | 2 ++ cmd/poller/collector/asup.go | 16 +++++++++------- cmd/poller/collector/collector.go | 2 ++ pkg/util/metadata.go | 6 ++++-- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/cmd/collectors/rest/plugins/qtree/qtree.go b/cmd/collectors/rest/plugins/qtree/qtree.go index 4e625eec5..49eb1d31a 100644 --- a/cmd/collectors/rest/plugins/qtree/qtree.go +++ b/cmd/collectors/rest/plugins/qtree/qtree.go @@ -189,6 +189,8 @@ func (q *Qtree) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util. return nil, nil, err } + q.client.Metadata.PluginInstances = uint64(quotaCount) + q.Logger.Info(). Int("numQuotas", quotaCount). Int("metrics", numMetrics). diff --git a/cmd/collectors/rest/rest.go b/cmd/collectors/rest/rest.go index 460cbbe1a..2053f51b7 100644 --- a/cmd/collectors/rest/rest.go +++ b/cmd/collectors/rest/rest.go @@ -729,7 +729,7 @@ func (r *Rest) CollectAutoSupport(p *collector.Payload) { InstanceInfo: &info, }) - if (r.Name == "Rest" && (r.Object == "Volume" || r.Object == "Node")) || r.Name == "Ems" { + if (r.Name == "Rest" && (r.Object == "Volume" || r.Object == "Node" || r.Object == "Qtree")) || r.Name == "Ems" { version := r.Client.Cluster().Version p.Target.Version = strconv.Itoa(version[0]) + "." + strconv.Itoa(version[1]) + "." + strconv.Itoa(version[2]) p.Target.Model = "cdot" @@ -762,6 +762,12 @@ func (r *Rest) CollectAutoSupport(p *collector.Payload) { if r.Object == "Volume" { p.Volumes = &info } + if r.Object == "Qtree" { + info = collector.InstanceInfo{ + PluginInstances: md.LazyValueInt64("pluginInstances", "data"), + } + p.Quotas = &info + } } } diff --git a/cmd/collectors/zapi/collector/zapi.go b/cmd/collectors/zapi/collector/zapi.go index 8da576e48..e7bfce037 100644 --- a/cmd/collectors/zapi/collector/zapi.go +++ b/cmd/collectors/zapi/collector/zapi.go @@ -465,7 +465,7 @@ func (z *Zapi) CollectAutoSupport(p *collector.Payload) { InstanceInfo: &info, }) - if z.Name == "Zapi" && (z.Object == "Volume" || z.Object == "Node") { + if z.Name == "Zapi" && (z.Object == "Volume" || z.Object == "Node" || z.Object == "Qtree") { p.Target.Version = z.GetHostVersion() p.Target.Model = z.GetHostModel() if p.Target.Serial == "" { @@ -473,7 +473,8 @@ func (z *Zapi) CollectAutoSupport(p *collector.Payload) { } p.Target.ClusterUUID = z.Client.ClusterUUID() - if z.Object == "Node" { + switch z.Object { + case "Node": var ( nodeIDs []collector.ID err error @@ -494,8 +495,13 @@ func (z *Zapi) CollectAutoSupport(p *collector.Payload) { p.Target.Serial = nodeIDs[0].SerialNumber } } - } else if z.Object == "Volume" { + case "Volume": p.Volumes = &info + case "Qtree": + info = collector.InstanceInfo{ + PluginInstances: md.LazyValueInt64("pluginInstances", "data"), + } + p.Quotas = &info } } } diff --git a/cmd/collectors/zapi/plugins/qtree/qtree.go b/cmd/collectors/zapi/plugins/qtree/qtree.go index 30e926552..86620adce 100644 --- a/cmd/collectors/zapi/plugins/qtree/qtree.go +++ b/cmd/collectors/zapi/plugins/qtree/qtree.go @@ -221,6 +221,8 @@ func (q *Qtree) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util. } } + q.client.Metadata.PluginInstances = uint64(quotaIndex) + q.Logger.Info(). Int("numQuotas", quotaIndex). Int("metrics", numMetrics). diff --git a/cmd/poller/collector/asup.go b/cmd/poller/collector/asup.go index 7d8778760..0cf073601 100644 --- a/cmd/poller/collector/asup.go +++ b/cmd/poller/collector/asup.go @@ -30,6 +30,7 @@ type Payload struct { Platform *platformInfo Nodes *InstanceInfo `json:"Nodes,omitempty"` Volumes *InstanceInfo `json:"Volumes,omitempty"` + Quotas *InstanceInfo `json:"Quotas,omitempty"` Tenants *InstanceInfo `json:"Tenants,omitempty"` Collectors *[]AsupCollector path string @@ -49,13 +50,14 @@ type ID struct { } type InstanceInfo struct { - Count int64 - DataPoints int64 - PollTime int64 - APITime int64 - ParseTime int64 - PluginTime int64 - Ids []ID `json:"Ids,omitempty"` // revive:disable-line var-naming + Count int64 + DataPoints int64 + PollTime int64 + APITime int64 + ParseTime int64 + PluginTime int64 + PluginInstances int64 + Ids []ID `json:"Ids,omitempty"` // revive:disable-line var-naming } type Process struct { diff --git a/cmd/poller/collector/collector.go b/cmd/poller/collector/collector.go index 2a207f77f..a5c0bcff9 100644 --- a/cmd/poller/collector/collector.go +++ b/cmd/poller/collector/collector.go @@ -256,6 +256,7 @@ func Init(c Collector) error { _, _ = md.NewMetricUint64("instances") _, _ = md.NewMetricUint64("bytesRx") _, _ = md.NewMetricUint64("numCalls") + _, _ = md.NewMetricUint64("pluginInstances") // Used by collector logging but not exported loggingOnly := []string{begin, "export_time"} @@ -459,6 +460,7 @@ func (c *AbstractCollector) Start(wg *sync.WaitGroup) { if pluginMetadata != nil { _ = c.Metadata.LazyAddValueUint64("bytesRx", task.Name, pluginMetadata.BytesRx) _ = c.Metadata.LazyAddValueUint64("numCalls", task.Name, pluginMetadata.NumCalls) + _ = c.Metadata.LazySetValueUint64("pluginInstances", task.Name, pluginMetadata.PluginInstances) } } } diff --git a/pkg/util/metadata.go b/pkg/util/metadata.go index ebab78e28..56736a3f6 100644 --- a/pkg/util/metadata.go +++ b/pkg/util/metadata.go @@ -1,11 +1,13 @@ package util type Metadata struct { - BytesRx uint64 - NumCalls uint64 + BytesRx uint64 + NumCalls uint64 + PluginInstances uint64 } func (m *Metadata) Reset() { m.BytesRx = 0 m.NumCalls = 0 + m.PluginInstances = 0 }