mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-17 18:35:55 +02:00
Feedback implemented
This commit is contained in:
parent
6033ca8502
commit
e08b1bd2bd
@ -14,9 +14,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const BEEGFS_CMD = "beegfs-ctl"
|
||||||
|
|
||||||
// Struct for the collector-specific JSON config
|
// Struct for the collector-specific JSON config
|
||||||
type BeegfsMetaCollectorConfig struct {
|
type BeegfsMetaCollectorConfig struct {
|
||||||
Beegfs string `json:"beegfs_path"`
|
Beegfs string `json:"beegfs_path"`
|
||||||
@ -63,7 +66,7 @@ func (m *BeegfsMetaCollector) Init(config json.RawMessage) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println(m.config.Beegfs)
|
|
||||||
//create map with possible variables
|
//create map with possible variables
|
||||||
m.matches = make(map[string]string)
|
m.matches = make(map[string]string)
|
||||||
for _, value := range nodeMdstat_array {
|
for _, value := range nodeMdstat_array {
|
||||||
@ -71,7 +74,7 @@ func (m *BeegfsMetaCollector) Init(config json.RawMessage) error {
|
|||||||
if skip {
|
if skip {
|
||||||
m.matches["other"] = "0"
|
m.matches["other"] = "0"
|
||||||
} else {
|
} 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
|
//get mounpoint
|
||||||
buffer, _ := ioutil.ReadFile(string("/proc/mounts"))
|
buffer, _ := ioutil.ReadFile(string("/proc/mounts"))
|
||||||
mounts := strings.Split(string(buffer), "\n")
|
mounts := strings.Split(string(buffer), "\n")
|
||||||
var mountpoint string
|
var mountpoints []string
|
||||||
for _, line := range mounts {
|
for _, line := range mounts {
|
||||||
if len(line) == 0 {
|
if len(line) == 0 {
|
||||||
continue
|
continue
|
||||||
@ -121,12 +124,20 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMetr
|
|||||||
f := strings.Fields(line)
|
f := strings.Fields(line)
|
||||||
if strings.Contains(f[0], "beegfs_ondemand") {
|
if strings.Contains(f[0], "beegfs_ondemand") {
|
||||||
// Skip excluded filesystems
|
// Skip excluded filesystems
|
||||||
if _, skip := m.skipFS[mountpoint]; skip {
|
if _, skip := m.skipFS[f[1]]; skip {
|
||||||
continue
|
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
|
m.tags["filesystem"] = mountpoint
|
||||||
|
|
||||||
// bwwgfs-ctl:
|
// bwwgfs-ctl:
|
||||||
@ -183,12 +194,24 @@ func (m *BeegfsMetaCollector) Read(interval time.Duration, output chan lp.CCMetr
|
|||||||
// split[i] = amount of md operations
|
// split[i] = amount of md operations
|
||||||
for i := 0; i <= len(split)-1; i += 2 {
|
for i := 0; i <= len(split)-1; i += 2 {
|
||||||
if _, ok := m.matches[split[i+1]]; ok {
|
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 {
|
} else {
|
||||||
f1, _ := strconv.ParseFloat(m.matches["other"], 32)
|
f1, err := strconv.ParseFloat(m.matches["other"], 32)
|
||||||
f2, _ := 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
|
||||||
|
}
|
||||||
|
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)
|
//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() {
|
func (m *BeegfsMetaCollector) Close() {
|
||||||
m.init = false
|
m.init = false
|
||||||
|
@ -25,6 +25,10 @@ in the configuration.
|
|||||||
|
|
||||||
When using the `exclude_metrics` option, the excluded metrics are summed as `other`.
|
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:
|
Available Metrics:
|
||||||
|
|
||||||
* sum
|
* sum
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ func (m *BeegfsStorageCollector) Init(config json.RawMessage) error {
|
|||||||
if skip {
|
if skip {
|
||||||
m.matches["other"] = "0"
|
m.matches["other"] = "0"
|
||||||
} else {
|
} 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
|
//get mounpoint
|
||||||
buffer, _ := ioutil.ReadFile(string("/proc/mounts"))
|
buffer, _ := ioutil.ReadFile(string("/proc/mounts"))
|
||||||
mounts := strings.Split(string(buffer), "\n")
|
mounts := strings.Split(string(buffer), "\n")
|
||||||
var mountpoint string
|
var mountpoints []string
|
||||||
for _, line := range mounts {
|
for _, line := range mounts {
|
||||||
if len(line) == 0 {
|
if len(line) == 0 {
|
||||||
continue
|
continue
|
||||||
@ -116,12 +117,19 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
|
|||||||
f := strings.Fields(line)
|
f := strings.Fields(line)
|
||||||
if strings.Contains(f[0], "beegfs_ondemand") {
|
if strings.Contains(f[0], "beegfs_ondemand") {
|
||||||
// Skip excluded filesystems
|
// Skip excluded filesystems
|
||||||
if _, skip := m.skipFS[mountpoint]; skip {
|
if _, skip := m.skipFS[f[1]]; skip {
|
||||||
continue
|
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
|
m.tags["filesystem"] = mountpoint
|
||||||
|
|
||||||
// bwwgfs-ctl:
|
// bwwgfs-ctl:
|
||||||
@ -178,11 +186,24 @@ func (m *BeegfsStorageCollector) Read(interval time.Duration, output chan lp.CCM
|
|||||||
// split[i] = amount of operations
|
// split[i] = amount of operations
|
||||||
for i := 0; i <= len(split)-1; i += 2 {
|
for i := 0; i <= len(split)-1; i += 2 {
|
||||||
if _, ok := m.matches[split[i+1]]; ok {
|
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 {
|
} else {
|
||||||
f1, _ := strconv.ParseFloat(m.matches["other"], 32)
|
f1, err := strconv.ParseFloat(m.matches["other"], 32)
|
||||||
f2, _ := strconv.ParseFloat(split[i], 32)
|
if err != nil {
|
||||||
m.matches["other"] = fmt.Sprintf("%f", f1+f2)
|
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() {
|
func (m *BeegfsStorageCollector) Close() {
|
||||||
m.init = false
|
m.init = false
|
||||||
|
@ -24,6 +24,11 @@ in the configuration.
|
|||||||
|
|
||||||
When using the `exclude_metrics` option, the excluded metrics are summed as `other`.
|
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:
|
Available Metrics:
|
||||||
|
|
||||||
* "sum"
|
* "sum"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user