in internal/pacemaker/pacemakermetrics.go [739:816]
func setASCSConfigMetrics(ctx context.Context, labels map[string]string, groups []Group, exec commandlineexecutor.Execute) {
labels["ascs_automatic_recover"] = ""
labels["ascs_failure_timeout"] = ""
labels["ascs_migration_threshold"] = ""
labels["ascs_resource_stickiness"] = ""
labels["ascs_monitor_interval"] = ""
labels["ascs_monitor_timeout"] = ""
labels["ensa2_capable"] = ""
metaAttributesKeys := map[string]string{
"failure-timeout": "ascs_failure_timeout",
"migration-threshold": "ascs_migration_threshold",
"resource-stickiness": "ascs_resource_stickiness",
}
// Identify the resource group containing the ASCS resource.
var ascsGroup *Group
ASCSLoop:
for _, group := range groups {
for _, primitive := range group.Primitives {
if primitive.ClassType != "SAPInstance" {
continue
}
for _, nvPair := range primitive.InstanceAttributes.NVPairs {
if nvPair.Name == "START_PROFILE" && strings.Contains(nvPair.Value, "SCS") {
ascsGroup = &group
break ASCSLoop
}
}
}
}
if ascsGroup == nil {
log.CtxLogger(ctx).Debug("Could not find ASCS resource group. Skipping ASCS metric collection.")
return
}
var ascsProfile string
for _, primitive := range ascsGroup.Primitives {
if primitive.ClassType != "SAPInstance" {
continue
}
for _, nvPair := range primitive.InstanceAttributes.NVPairs {
switch nvPair.Name {
case "AUTOMATIC_RECOVER":
labels["ascs_automatic_recover"] = nvPair.Value
case "START_PROFILE":
ascsProfile = nvPair.Value
}
}
for _, nvPair := range primitive.MetaAttributes.NVPairs {
if key, ok := metaAttributesKeys[nvPair.Name]; ok {
labels[key] = nvPair.Value
}
}
for _, op := range primitive.Operations {
if op.Name == "monitor" {
labels["ascs_monitor_interval"] = op.Interval
labels["ascs_monitor_timeout"] = op.Timeout
}
}
}
if ascsProfile == "" {
return
}
labels["ensa2_capable"] = "false"
result := exec(ctx, commandlineexecutor.Params{
Executable: "grep",
ArgsToSplit: fmt.Sprintf("'^_ENQ' %s", ascsProfile),
})
switch {
case result.Error != nil && !result.ExitStatusParsed:
log.CtxLogger(ctx).Debugw("Could not grep ASCS profile.", "error", result.Error, "start_profile", ascsProfile)
case result.ExitCode == 0:
labels["ensa2_capable"] = "true"
}
}