Skip to content
Open
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
142 changes: 79 additions & 63 deletions collector/system_stats_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
const prefix_stats = "spectrum_systemstats_"

var (
metrics [49]*prometheus.Desc
metricsPromDescMap map[string]*prometheus.Desc
metricsDescMap map[string]string //update InitmetricsDescMap function for any new stat added in lssystemstats api rsp
)

type systemStatsCollector struct {
Expand All @@ -34,87 +35,99 @@ type systemStatsCollector struct {
func init() {
registerCollector("lssystemstats", defaultEnabled, NewSystemStatsCollector)
}
func NewSystemStatsCollector() (Collector, error) {
labelnames := []string{"resource"}
if len(utils.ExtraLabelNames) > 0 {
labelnames = append(labelnames, utils.ExtraLabelNames...)
}
metrics = [49]*prometheus.Desc{
prometheus.NewDesc(prefix_stats+"compression_cpu_pc", "The percentage of allocated CPU capacity that is used for compression.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"cpu_pc", "The percentage of allocated CPU capacity that is used for the system.", labelnames, nil),

prometheus.NewDesc(prefix_stats+"fc_mb", "The total number of megabytes transferred per second (MBps) for Fibre Channel traffic on the system. This value includes host I/O and any bandwidth that is used for communication within the system.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"fc_io", "The total input/output (I/O) operations that are transferred per seconds for Fibre Channel traffic on the system. This value includes host I/O and any bandwidth that is used for communication within the system.", labelnames, nil),
func InitmetricsDescMap() {
metricsDescMap = make(map[string]string)
metricsDescMap["compression_cpu_pc"] = "The percentage of allocated CPU capacity that is used for compression."
metricsDescMap["cpu_pc"] = "The percentage of allocated CPU capacity that is used for the system."

prometheus.NewDesc(prefix_stats+"sas_mb", "The total number of megabytes transferred per second (MBps) for serial-attached SCSI (SAS) traffic on the system. This value includes host I/O and bandwidth that is used for background RAID activity.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"sas_io", "The total I/O operations that are transferred per second for SAS traffic on the system. This value includes host I/O and bandwidth that is used for background RAID activity.", labelnames, nil),
metricsDescMap["fc_mb"] = "The total number of megabytes transferred per second (MBps) for Fibre Channel traffic on the system. This value includes host I/O and any bandwidth that is used for communication within the system."
metricsDescMap["fc_io"] = "The total input/output (I/O) operations that are transferred per seconds for Fibre Channel traffic on the system. This value includes host I/O and any bandwidth that is used for communication within the system."

prometheus.NewDesc(prefix_stats+"iscsi_mb", "The total number of megabytes transferred per second (MBps) for iSCSI traffic on the system.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"iscsi_io", "The total I/O operations that are transferred per second for iSCSI traffic on the system.", labelnames, nil),
metricsDescMap["sas_mb"] = "The total number of megabytes transferred per second (MBps) for serial-attached SCSI (SAS) traffic on the system. This value includes host I/O and bandwidth that is used for background RAID activity."
metricsDescMap["sas_io"] = "The total I/O operations that are transferred per second for SAS traffic on the system. This value includes host I/O and bandwidth that is used for background RAID activity."

prometheus.NewDesc(prefix_stats+"write_cache_pc", "The percentage of the write cache usage for the node.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"total_cache_pc", "The total percentage for both the write and read cache usage for the node.", labelnames, nil),
metricsDescMap["iscsi_mb"] = "The total number of megabytes transferred per second (MBps) for iSCSI traffic on the system."
metricsDescMap["iscsi_io"] = "The total I/O operations that are transferred per second for iSCSI traffic on the system."

prometheus.NewDesc(prefix_stats+"vdisk_mb", "The average number of megabytes transferred per second (MBps) for read and write operations to volumes during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"vdisk_io", "The average number of I/O operations that are transferred per second for read and write operations to volumes during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"vdisk_ms", "The average amount of time in milliseconds that the system takes to respond to read and write requests to volumes over the sample period.", labelnames, nil),
metricsDescMap["write_cache_pc"] = "The percentage of the write cache usage for the node."
metricsDescMap["total_cache_pc"] = "The total percentage for both the write and read cache usage for the node."

prometheus.NewDesc(prefix_stats+"mdisk_mb", "The average number of megabytes transferred per second (MBps) for read and write operations to MDisks during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"mdisk_io", "The average number of I/O operations that are transferred per second for read and write operations to MDisks during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"mdisk_ms", "The average amount of time in milliseconds that the system takes to respond to read and write requests to MDisks over the sample period.", labelnames, nil),
metricsDescMap["vdisk_mb"] = "The average number of megabytes transferred per second (MBps) for read and write operations to volumes during the sample period."
metricsDescMap["vdisk_io"] = "The average number of I/O operations that are transferred per second for read and write operations to volumes during the sample period."
metricsDescMap["vdisk_ms"] = "The average amount of time in milliseconds that the system takes to respond to read and write requests to volumes over the sample period."

prometheus.NewDesc(prefix_stats+"drive_mb", "The average number of megabytes transferred per second (MBps) for read and write operations to drives during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"drive_io", "The average number of I/O operations that are transferred per second for read and write operations to drives during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"drive_ms", "The average amount of time in milliseconds that the system takes to respond to read and write requests to drives over the sample period.", labelnames, nil),
metricsDescMap["mdisk_mb"] = "The average number of megabytes transferred per second (MBps) for read and write operations to MDisks during the sample period."
metricsDescMap["mdisk_io"] = "The average number of I/O operations that are transferred per second for read and write operations to MDisks during the sample period."
metricsDescMap["mdisk_ms"] = "The average amount of time in milliseconds that the system takes to respond to read and write requests to MDisks over the sample period."

prometheus.NewDesc(prefix_stats+"vdisk_r_mb", "The average number of megabytes transferred per second (MBps) for read operations to volumes during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"vdisk_r_io", "The average number of I/O operations that are transferred per second for read operations to volumes during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"vdisk_r_ms", "The average amount of time in milliseconds that the system takes to respond to read requests to volumes over the sample period.", labelnames, nil),
metricsDescMap["drive_mb"] = "The average number of megabytes transferred per second (MBps) for read and write operations to drives during the sample period."
metricsDescMap["drive_io"] = "The average number of I/O operations that are transferred per second for read and write operations to drives during the sample period."
metricsDescMap["drive_ms"] = "The average amount of time in milliseconds that the system takes to respond to read and write requests to drives over the sample period."

prometheus.NewDesc(prefix_stats+"vdisk_w_mb", "The average number of megabytes transferred per second (MBps) for read and write operations to volumes during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"vdisk_w_io", "The average number of I/O operations that are transferred per second for write operations to volumes during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"vdisk_w_ms", "The average amount of time in milliseconds that the system takes to respond to write requests to volumes over the sample period.", labelnames, nil),
metricsDescMap["vdisk_r_mb"] = "The average number of megabytes transferred per second (MBps) for read operations to volumes during the sample period."
metricsDescMap["vdisk_r_io"] = "The average number of I/O operations that are transferred per second for read operations to volumes during the sample period."
metricsDescMap["vdisk_r_ms"] = "The average amount of time in milliseconds that the system takes to respond to read requests to volumes over the sample period."

prometheus.NewDesc(prefix_stats+"mdisk_r_mb", "The average number of megabytes transferred per second (MBps) for read operations to MDisks during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"mdisk_r_io", "The average number of I/O operations that are transferred per second for read operations to MDisks during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"mdisk_r_ms", "The average amount of time in milliseconds that the system takes to respond to read requests to MDisks over the sample period.", labelnames, nil),
metricsDescMap["vdisk_w_mb"] = "The average number of megabytes transferred per second (MBps) for read and write operations to volumes during the sample period."
metricsDescMap["vdisk_w_io"] = "The average number of I/O operations that are transferred per second for write operations to volumes during the sample period."
metricsDescMap["vdisk_w_ms"] = "The average amount of time in milliseconds that the system takes to respond to write requests to volumes over the sample period."

prometheus.NewDesc(prefix_stats+"mdisk_w_mb", "The average number of megabytes transferred per second (MBps) for write operations to MDisks during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"mdisk_w_io", "TThe average number of I/O operations that are transferred per second for write operations to MDisks during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"mdisk_w_ms", "the average amount of time in milliseconds that the system takes to respond to write requests to MDisks over the sample period.", labelnames, nil),
metricsDescMap["mdisk_r_mb"] = "The average number of megabytes transferred per second (MBps) for read operations to MDisks during the sample period."
metricsDescMap["mdisk_r_io"] = "The average number of I/O operations that are transferred per second for read operations to MDisks during the sample period."
metricsDescMap["mdisk_r_ms"] = "The average amount of time in milliseconds that the system takes to respond to read requests to MDisks over the sample period."

prometheus.NewDesc(prefix_stats+"drive_r_mb", "The average number of megabytes transferred per second (MBps) for read operations to drives during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"drive_r_io", "The average number of I/O operations that are transferred per second for read operations to drives during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"drive_r_ms", "The average amount of time in milliseconds that the system takes to respond to read requests to drives over the sample period.", labelnames, nil),
metricsDescMap["mdisk_w_mb"] = "The average number of megabytes transferred per second (MBps) for write operations to MDisks during the sample period."
metricsDescMap["mdisk_w_io"] = "TThe average number of I/O operations that are transferred per second for write operations to MDisks during the sample period."
metricsDescMap["mdisk_w_ms"] = "the average amount of time in milliseconds that the system takes to respond to write requests to MDisks over the sample period."

prometheus.NewDesc(prefix_stats+"drive_w_mb", "The average number of megabytes transferred per second (MBps) for write operations to drives during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"drive_w_io", "The average number of I/O operations that are transferred per second for write operations to drives during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"drive_w_ms", "The average amount of time in milliseconds that the system takes to respond write requests to drives over the sample period.", labelnames, nil),
metricsDescMap["drive_r_mb"] = "The average number of megabytes transferred per second (MBps) for read operations to drives during the sample period."
metricsDescMap["drive_r_io"] = "The average number of I/O operations that are transferred per second for read operations to drives during the sample period."
metricsDescMap["drive_r_ms"] = "The average amount of time in milliseconds that the system takes to respond to read requests to drives over the sample period."

prometheus.NewDesc(prefix_stats+"power_w", "the power that is consumed in watts.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"temp_c", " the ambient temperature in Celsius.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"temp_f", "the ambient temperature in Fahrenheit.", labelnames, nil),
metricsDescMap["drive_w_mb"] = "The average number of megabytes transferred per second (MBps) for write operations to drives during the sample period."
metricsDescMap["drive_w_io"] = "The average number of I/O operations that are transferred per second for write operations to drives during the sample period."
metricsDescMap["drive_w_ms"] = "The average amount of time in milliseconds that the system takes to respond write requests to drives over the sample period."

prometheus.NewDesc(prefix_stats+"iplink_mb", "The average number of megabytes requested to be transferred per second (MBps) over the IP partnership link during the sample period. This value is calculated before any compression of the data takes place. This value does not include iSCSI host input/output (I/O) operations.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"iplink_io", "TThe total input/output (I/O) operations that are transferred per second for IP partnership traffic on the system.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"iplink_comp_mb", "The average number of compressed megabytes transferred per second (MBps) over the IP Replication link during the sample period. This value is calculated after any compression of |the data takes place. This value does not include iSCSI host I/O operations.", labelnames, nil),
metricsDescMap["power_w"] = "the power that is consumed in watts."
metricsDescMap["temp_c"] = " the ambient temperature in Celsius."
metricsDescMap["temp_f"] = "the ambient temperature in Fahrenheit."

prometheus.NewDesc(prefix_stats+"cloud_up_mb", "The average number of megabytes transferred per second (Mbps) for upload operations to a cloud account during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"cloud_up_ms", "The average amount of time (in milliseconds) it takes for the system to respond to upload requests to a cloud account during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"cloud_down_mb", "The average number of Mbps for download operations to a cloud account during the sample period.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"cloud_down_ms", "The average amount of time (in milliseconds) it takes for the system to respond to download requests to a cloud account during the sample period.", labelnames, nil),
metricsDescMap["iplink_mb"] = "The average number of megabytes requested to be transferred per second (MBps) over the IP partnership link during the sample period. This value is calculated before any compression of the data takes place. This value does not include iSCSI host input/output (I/O) operations."
metricsDescMap["iplink_io"] = "TThe total input/output (I/O) operations that are transferred per second for IP partnership traffic on the system."
metricsDescMap["iplink_comp_mb"] = "The average number of compressed megabytes transferred per second (MBps) over the IP Replication link during the sample period. This value is calculated after any compression of |the data takes place. This value does not include iSCSI host I/O operations."

prometheus.NewDesc(prefix_stats+"iser_mb", "The total number of megabytes transferred per second (MBps) for iSER traffic on the system.", labelnames, nil),
prometheus.NewDesc(prefix_stats+"iser_io", "The total I/O operations that are transferred per second for iSER traffic on the system.", labelnames, nil),
}
metricsDescMap["cloud_up_mb"] = "The average number of megabytes transferred per second (Mbps) for upload operations to a cloud account during the sample period."
metricsDescMap["cloud_up_ms"] = "The average amount of time (in milliseconds) it takes for the system to respond to upload requests to a cloud account during the sample period."
metricsDescMap["cloud_down_mb"] = "The average number of Mbps for download operations to a cloud account during the sample period."
metricsDescMap["cloud_down_ms"] = "The average amount of time (in milliseconds) it takes for the system to respond to download requests to a cloud account during the sample period."

metricsDescMap["iser_mb"] = "The total number of megabytes transferred per second (MBps) for iSER traffic on the system."
metricsDescMap["iser_io"] = "The total I/O operations that are transferred per second for iSER traffic on the system."
metricsDescMap["nvme_rdma_mb"] = "The total number of megabytes transferred per second (MBps) for NVMe over RDMA traffic on the system."
metricsDescMap["nvme_rdma_io"] = "The total I/O operations that are transferred per second for NVMe over RDMA traffic on the system."
metricsDescMap["nvme_tcp_mb"] = "The total number of megabytes transferred per second (MBps) for NVMe over TCP traffic on the system."
metricsDescMap["nvme_tcp_io"] = "The total I/O operations that are transferred per second for NVMe over TCP traffic on the system."
}

func NewSystemStatsCollector() (Collector, error) {
InitmetricsDescMap()
labelnames := []string{"resource"}
if len(utils.ExtraLabelNames) > 0 {
labelnames = append(labelnames, utils.ExtraLabelNames...)
}
metricsPromDescMap = make(map[string]*prometheus.Desc)
for statName, statDef := range metricsDescMap {
metricsPromDescMap[statName] = prometheus.NewDesc(prefix_stats+statName, statDef, labelnames, nil)
}
metricsDescMap = nil //ready for cleanup
return &systemStatsCollector{}, nil
}

// Describe describes the metrics
// Describe describes the metricsPromDescMap
func (*systemStatsCollector) Describe(ch chan<- *prometheus.Desc) {

for _, metric := range metrics {
for _, metric := range metricsPromDescMap {
ch <- metric
}

Expand Down Expand Up @@ -162,10 +175,13 @@ func (c *systemStatsCollector) Collect(sClient utils.SpectrumClient, ch chan<- p
}

systemStats := gjson.Parse(systemStatsResp).Array()
for i, systemStat := range systemStats {
// ignore the fields greater than 49
if i < 49 {
ch <- prometheus.MustNewConstMetric(metrics[i], prometheus.GaugeValue, systemStat.Get("stat_current").Float(), labelvalues...)

for _, systemStat := range systemStats {

mrtricDesc, isExist := metricsPromDescMap[systemStat.Get("stat_name").String()]
//new stat will be ignored if not added in metricsDescMap
if isExist {
ch <- prometheus.MustNewConstMetric(mrtricDesc, prometheus.GaugeValue, systemStat.Get("stat_current").Float(), labelvalues...)
}
}
logger.Debugln("exit SystemStats collector")
Expand Down