Feedback implemented

This commit is contained in:
Mehmet Soysal 2022-03-04 11:33:09 +01:00
parent 6033ca8502
commit e08b1bd2bd
No known key found for this signature in database
GPG Key ID: 7B6342DE1987F322
4 changed files with 187 additions and 132 deletions

View File

@ -14,9 +14,12 @@ import (
"strings"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
)
const BEEGFS_CMD = "beegfs-ctl"
// Struct for the collector-specific JSON config
type BeegfsMetaCollectorConfig struct {
Beegfs string `json:"beegfs_path"`
@ -63,7 +66,7 @@ func (m *BeegfsMetaCollector) Init(config json.RawMessage) error {
return err
}
}
println(m.config.Beegfs)
//create map with possible variables
m.matches = make(map[string]string)
for _, value := range nodeMdstat_array {
@ -71,7 +74,7 @@ func (m *BeegfsMetaCollector) Init(config json.RawMessage) error {
if skip {
m.matches["other"] = "0"
} else {
m.matches[value] = "0"
m.matches["beegfs_cmeta_"+value] = "0"
}
}
@ -113,7 +116,7 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMetr
//get mounpoint
buffer, _ := ioutil.ReadFile(string("/proc/mounts"))
mounts := strings.Split(string(buffer), "\n")
var mountpoint string
var mountpoints []string
for _, line := range mounts {
if len(line) == 0 {
continue
@ -121,12 +124,20 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMetr
f := strings.Fields(line)
if strings.Contains(f[0], "beegfs_ondemand") {
// Skip excluded filesystems
if _, skip := m.skipFS[mountpoint]; skip {
if _, skip := m.skipFS[f[1]]; skip {
continue
}
mountpoint = f[1]
mountpoints = append(mountpoints, f[1])
}
}
if len(mountpoints) == 0 {
cclog.ComponentError(
m.name,
"Read(): Failed to find BeeGFS on Demand FS.")
}
for _, mountpoint := range mountpoints {
m.tags["filesystem"] = mountpoint
// bwwgfs-ctl:
@ -183,12 +194,24 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMetr
// split[i] = amount of md operations
for i := 0; i <= len(split)-1; i += 2 {
if _, ok := m.matches[split[i+1]]; ok {
m.matches[split[i+1]] = split[i]
m.matches["beegfs_cmeta_"+split[i+1]] = split[i]
} else {
f1, _ := strconv.ParseFloat(m.matches["other"], 32)
f2, _ := strconv.ParseFloat(split[i], 32)
f1, err := strconv.ParseFloat(m.matches["other"], 32)
if err != nil {
cclog.ComponentError(
m.name,
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
continue
}
f2, err := strconv.ParseFloat(split[i], 32)
if err != nil {
cclog.ComponentError(
m.name,
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
continue
}
//mdStat["other"] = fmt.Sprintf("%f", f1+f2)
m.matches["other"] = fmt.Sprintf("%f", f1+f2)
m.matches["beegfs_cstorage_other"] = fmt.Sprintf("%f", f1+f2)
}
}
@ -201,6 +224,7 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMetr
}
}
}
}
func (m *BeegfsMetaCollector) Close() {
m.init = false

View File

@ -25,6 +25,10 @@ in the configuration.
When using the `exclude_metrics` option, the excluded metrics are summed as `other`.
Important: The metrics listed below, are similar to the naming of BeeGFS. The Collector prefixes these with `beegfs_cstorage`(beegfs client storage).
For example beegfs metric `open`-> `beegfs_cstorage_open`
Available Metrics:
* sum

View File

@ -14,6 +14,7 @@ import (
"strings"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
)
@ -66,7 +67,7 @@ func (m *BeegfsStorageCollector) Init(config json.RawMessage) error {
if skip {
m.matches["other"] = "0"
} else {
m.matches[value] = "0"
m.matches["beegfs_cstorage_"+value] = "0"
}
}
@ -108,7 +109,7 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
//get mounpoint
buffer, _ := ioutil.ReadFile(string("/proc/mounts"))
mounts := strings.Split(string(buffer), "\n")
var mountpoint string
var mountpoints []string
for _, line := range mounts {
if len(line) == 0 {
continue
@ -116,12 +117,19 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
f := strings.Fields(line)
if strings.Contains(f[0], "beegfs_ondemand") {
// Skip excluded filesystems
if _, skip := m.skipFS[mountpoint]; skip {
if _, skip := m.skipFS[f[1]]; skip {
continue
}
mountpoint = f[1]
mountpoints = append(mountpoints, f[1])
}
}
if len(mountpoints) == 0 {
cclog.ComponentError(
m.name,
"Read(): Failed to find BeeGFS on Demand FS.")
}
// collects stats for each BeeGFS on Demand FS
for _, mountpoint := range mountpoints {
m.tags["filesystem"] = mountpoint
// bwwgfs-ctl:
@ -178,11 +186,24 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
// split[i] = amount of operations
for i := 0; i <= len(split)-1; i += 2 {
if _, ok := m.matches[split[i+1]]; ok {
m.matches[split[i+1]] = split[i]
m.matches["beegfs_cstorage_"+split[i+1]] = split[i]
//m.matches[split[i+1]] = split[i]
} else {
f1, _ := strconv.ParseFloat(m.matches["other"], 32)
f2, _ := strconv.ParseFloat(split[i], 32)
m.matches["other"] = fmt.Sprintf("%f", f1+f2)
f1, err := strconv.ParseFloat(m.matches["other"], 32)
if err != nil {
cclog.ComponentError(
m.name,
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
continue
}
f2, err := strconv.ParseFloat(split[i], 32)
if err != nil {
cclog.ComponentError(
m.name,
fmt.Sprintf("Metric (other): Failed to convert str written '%s' to float: %v", m.matches["other"], err))
continue
}
m.matches["beegfs_cstorage_other"] = fmt.Sprintf("%f", f1+f2)
}
}
@ -195,6 +216,7 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
}
}
}
}
func (m *BeegfsStorageCollector) Close() {
m.init = false

View File

@ -24,6 +24,11 @@ in the configuration.
When using the `exclude_metrics` option, the excluded metrics are summed as `other`.
Important: The metrics listed below, are similar to the naming of BeeGFS. The Collector prefixes these with `beegfs_cstorage_`(beegfs client meta).
For example beegfs metric `open`-> `beegfs_cstorage_`
Note: BeeGFS FS offers many Metadata Information. Probably it makes sense to exlcude most of them. Nevertheless, these excluded metrics will be summed as `beegfs_cstorage_other`.
Available Metrics:
* "sum"