query ucs for temperatures
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -15,6 +15,13 @@ type UcsmTemperaturesCollector struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
type ComputeMbTempStats struct {
|
||||
XMLName xml.Name `xml:"computeMbTempStats"`
|
||||
Dn string `xml:"dn,attr,omitempty"`
|
||||
FmTempSenIo string `xml:"fmTempSenIo,attr,omitempty"`
|
||||
FmTempSenRear string `xml:"fmTempSenRear,attr,omitempty"`
|
||||
}
|
||||
|
||||
func NewUcsmTemperatureCollector(client *api.Client, ctx context.Context) *UcsmTemperaturesCollector {
|
||||
return &UcsmTemperaturesCollector{
|
||||
ucsClient: client,
|
||||
@@ -43,27 +50,56 @@ func (u *UcsmTemperaturesCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
Blades []mo.ComputeBlade `xml:"computeBlade"`
|
||||
}
|
||||
|
||||
req := api.ConfigResolveClassRequest{
|
||||
type temps struct {
|
||||
XMLName xml.Name
|
||||
Temperatures []ComputeMbTempStats `xml:"computeMbTempStats"`
|
||||
}
|
||||
|
||||
bladeRequest := api.ConfigResolveClassRequest{
|
||||
Cookie: u.ucsClient.Cookie,
|
||||
ClassId: "computeBlade",
|
||||
InHierarchical: "false",
|
||||
}
|
||||
|
||||
var out blades
|
||||
var bladeList blades
|
||||
|
||||
log.Println("Retrieving managed objects with class `computeBlade`")
|
||||
if err := u.ucsClient.ConfigResolveClass(u.ctx, req, &out); err != nil {
|
||||
|
||||
if err := u.ucsClient.ConfigResolveClass(u.ctx, bladeRequest, &bladeList); err != nil {
|
||||
log.Fatalf("Unable to retrieve `computeBlade` managed object: %s", err)
|
||||
}
|
||||
|
||||
log.Printf("Retrieved %d compute blades\n", len(out.Blades))
|
||||
for _, blade := range out.Blades {
|
||||
log.Printf("Retrieved %d compute blades\n", len(bladeList.Blades))
|
||||
for _, blade := range bladeList.Blades {
|
||||
log.Printf("%s:\n", blade.Dn)
|
||||
log.Printf("%s:\n", blade.ComputeBoard.Dn)
|
||||
log.Printf("\tNumber of CPUs: %d\n", blade.NumOfCpus)
|
||||
log.Printf("\tTotal Memory: %d\n", blade.TotalMemory)
|
||||
log.Printf("\tModel: %s\n", blade.Model)
|
||||
log.Printf("\tVendor: %s\n", blade.Vendor)
|
||||
log.Printf("\tThermal: %s\n", blade.ComputeBoard.Thermal)
|
||||
log.Printf("\tThermal: %v\n", blade.ComputeBoard.Thermal)
|
||||
|
||||
filter := api.FilterEq{
|
||||
FilterProperty: api.FilterProperty{
|
||||
Class: "computeMbTempStats",
|
||||
Property: "dn",
|
||||
Value: blade.ComputeBoard.Dn,
|
||||
},
|
||||
}
|
||||
tempReq := api.ConfigResolveClassRequest{
|
||||
Cookie: u.ucsClient.Cookie,
|
||||
ClassId: "computeMbTempStats",
|
||||
InHierarchical: "false",
|
||||
InFilter: filter,
|
||||
}
|
||||
|
||||
var tempList temps
|
||||
log.Printf("Retrieving temperatures for this blade\n")
|
||||
if err := u.ucsClient.ConfigResolveClass(u.ctx, tempReq, &tempList); err != nil {
|
||||
log.Fatalf("Unable to retrieve `computeMbTempStats` managed object: %s", err)
|
||||
}
|
||||
|
||||
log.Printf("Front Temperature: %v\n", tempList.Temperatures[0].FmTempSenIo)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user