Skip to content

Commit

Permalink
added brocade cpu load support
Browse files Browse the repository at this point in the history
  • Loading branch information
toberd committed Dec 9, 2020
1 parent af1243c commit 3ba1e42
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/communicator/device_class_to_code_communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func getCodeCommunicator(classIdentifier string, rel *relatedNetworkDeviceCommun
return &poweroneACCCommunicator{baseCommunicator{rel}}, nil
case "powerone/pcc":
return &poweronePCCCommunicator{baseCommunicator{rel}}, nil
case "ironware":
return &ironwareCommunicator{baseCommunicator{rel}}, nil
}
return nil, tholaerr.NewNotFoundError(fmt.Sprintf("no communicator found for device class identifier '%s'", classIdentifier))
}
40 changes: 40 additions & 0 deletions core/communicator/ironware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package communicator

import (
"context"
"github.com/inexio/thola/core/network"
"github.com/pkg/errors"
"strconv"
"strings"
)

type ironwareCommunicator struct {
baseCommunicator
}

func (c *ironwareCommunicator) GetCPUComponentCPULoad(ctx context.Context) ([]float64, error) {
con, ok := network.DeviceConnectionFromContext(ctx)
if !ok || con.SNMP == nil {
return nil, errors.New("no device connection available")
}
responses, err := con.SNMP.SnmpClient.SNMPWalk(ctx, ".1.3.6.1.4.1.1991.1.1.2.11.1.1.5")
if err != nil {
return nil, errors.Wrap(err, "snmpwalk failed")
}
var cpus []float64
for _, response := range responses {
if !strings.HasSuffix(response.GetOID(), "300") {
continue
}
valueString, err := response.GetValueString()
if err != nil {
return nil, errors.Wrap(err, "couldn't get string value")
}
value, err := strconv.ParseFloat(valueString, 64)
if err != nil {
return nil, errors.Wrap(err, "failed to parse snmp response")
}
cpus = append(cpus, value)
}
return cpus, nil
}
2 changes: 2 additions & 0 deletions core/config/device-classes/generic/ironware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: ironware
config:
snmp:
max_repetitions: 1
components:
cpuComponent: true

match:
conditions:
Expand Down

0 comments on commit 3ba1e42

Please sign in to comment.