jenningsloy318 / redfish_exporter

exporter to get metrics from redfish based hardware such as lenovo/dell/superc servers
Apache License 2.0
70 stars 62 forks source link

memory: json: cannot unmarshal object into Go struct field .Location of type string #8

Closed matejzero closed 4 years ago

matejzero commented 4 years ago

To not clutter https://github.com/jenningsloy318/redfish_exporter/issues/4 too much, I will split the issues to separate tickets.

When querying memory metrics from redfish, I get an error INFO[0008] Errors Getting memory from computer system : json: cannot unmarshal object into Go struct field .Location of type string source="system_collector.go:386".

Redfish output for empyt slot

{
    "AllowedSpeedsMHz": [],
    "VolatileRegionSizeLimitMiB": null,
    "MemoryDeviceType": null,
    "Id": "2",
    "MemorySubsystemControllerProductID": null,
    "Links": {
        "Chassis": {
            "@odata.id": "/redfish/v1/Chassis/1"
        }
    },
    "MemoryMedia": [],
    "PartNumber": null,
    "DeviceID@Redfish.Deprecated": "The property is deprecated. Please use ModuleProductID instead.",
    "MemoryLocation": {
        "Channel": 2,
        "MemoryController": 0,
        "Slot": 2,
        "Socket": 1
    },
    "MemorySubsystemControllerManufacturerID": null,
    "MemoryType": null,
    "DeviceLocator": null,
    "Name": "DIMM 2",
    "Oem": {
        "Lenovo": {
            "@odata.type": "#LenovoMemory.v1_0_0.LenovoMemory",
            "FruPartNumber": null
        }
    },
    "@odata.type": "#Memory.v1_7_1.Memory",
    "RankCount": null,
    "BaseModuleType": null,
    "DeviceID": null,
    "VendorID": null,
    "Regions": [],
    "ModuleProductID": null,
    "@odata.id": "/redfish/v1/Systems/1/Memory/2",
    "OperatingSpeedMhz": null,
    "SerialNumber": null,
    "SubsystemDeviceID@Redfish.Deprecated": "The property is deprecated. Please use MemorySubsystemControllerProductID instead.",
    "CapacityMiB": null,
    "Description": "This resource is used to represent a memory for a Redfish implementation.",
    "BusWidthBits": null,
    "Manufacturer": null,
    "SubsystemDeviceID": null,
    "OperatingMemoryModes": [],
    "Status": {
        "State": "Absent",
        "Health": null
    },
    "DataWidthBits": null,
    "SecurityCapabilities": {},
    "ModuleManufacturerID": null,
    "SubsystemVendorID@Redfish.Deprecated": "The property is deprecated. Please use MemorySubsystemControllerManufacturerID instead.",
    "SubsystemVendorID": null,
    "Location": {
        "PartLocation": {
            "LocationType": "Slot",
            "ServiceLabel": "DIMM 2",
            "LocationOrdinalValue": 1
        }
    },
    "PersistentRegionSizeLimitMiB": null,
    "@odata.etag": "\"d9b7eb2d8ff48aed4e2bece427f6a77f\"",
    "VendorID@Redfish.Deprecated": "The property is deprecated. Please use ModuleManufacturerID instead.",
    "VolatileSizeMiB": null,
    "FunctionClasses": []
}

Redfish output for populted slot:

{
    "AllowedSpeedsMHz": [
        2666
    ],
    "VolatileRegionSizeLimitMiB": null,
    "MemoryDeviceType": "DDR4",
    "Id": "5",
    "MemorySubsystemControllerProductID": "0x0000",
    "Links": {
        "Chassis": {
            "@odata.id": "/redfish/v1/Chassis/1"
        }
    },
    "MemoryMedia": [
        "DRAM"
    ],
    "PartNumber": "xxxxxxxx",
    "DeviceID@Redfish.Deprecated": "The property is deprecated. Please use ModuleProductID instead.",
    "MemoryLocation": {
        "Channel": 0,
        "MemoryController": 0,
        "Slot": 5,
        "Socket": 1
    },
    "MemorySubsystemControllerManufacturerID": "0x0000",
    "MemoryType": "DRAM",
    "DeviceLocator": "DIMM 5",
    "Name": "DIMM 5",
    "Oem": {
        "Lenovo": {
            "@odata.type": "#LenovoMemory.v1_0_0.LenovoMemory",
            "FruPartNumber": "xxxxxx"
        }
    },
    "@odata.type": "#Memory.v1_7_1.Memory",
    "RankCount": 1,
    "BaseModuleType": "RDIMM",
    "DeviceID": "DIMM_5",
    "VendorID": "SK Hynix",
    "Regions": [],
    "SecurityCapabilities": {},
    "@odata.id": "/redfish/v1/Systems/1/Memory/5",
    "OperatingSpeedMhz": 2400,
    "SerialNumber": "xxxxxxx",
    "SubsystemDeviceID@Redfish.Deprecated": "The property is deprecated. Please use MemorySubsystemControllerProductID instead.",
    "CapacityMiB": 32768,
    "Description": "This resource is used to represent a memory for a Redfish implementation.",
    "BusWidthBits": 72,
    "Manufacturer": "SK Hynix",
    "SubsystemDeviceID": "0x0000",
    "OperatingMemoryModes": [
        "Volatile"
    ],
    "Status": {
        "State": "Enabled",
        "Health": "OK"
    },
    "DataWidthBits": 64,
    "SubsystemVendorID@Redfish.Deprecated": "The property is deprecated. Please use MemorySubsystemControllerManufacturerID instead.",
    "ModuleManufacturerID": "0xad80",
    "Location": {
        "PartLocation": {
            "LocationType": "Slot",
            "ServiceLabel": "DIMM 5",
            "LocationOrdinalValue": 4
        }
    },
    "SubsystemVendorID": "0x0000",
    "PersistentRegionSizeLimitMiB": null,
    "@odata.etag": "\"785972fc74cf58990168a1aba42935e0\"",
    "ModuleProductID": "0x0000",
    "VendorID@Redfish.Deprecated": "The property is deprecated. Please use ModuleManufacturerID instead.",
    "VolatileSizeMiB": 32768,
    "FunctionClasses": [
        "Volatile"
    ]
}

The problem is in the gofish library in https://github.com/stmcginnis/gofish/blob/73f4bfdc949f2942e60cc396a70c7bedd2b95a8c/redfish/memory.go#L240. This should be extended.

Mockup from DMTF page: https://redfish.dmtf.org/redfish/mockups/v1/922#

Looking at http://redfish.dmtf.org/schemas/v1/Resource.v1_9_0.json#/definitions/Location, Location is quite a big resource. I think it could be left out and MemoryLocation should be used for memory.

matejzero commented 4 years ago

I know this is Lenovo specific exporter, but I also have a Dell server on hand and can compare.

Dell doesn't export MemoryLocation. But I get the DIMM slots in Name and DeviceLocator.

JSON from Dell:

{
    "@odata.context": "/redfish/v1/$metadata#Memory.Memory",
    "@odata.type": "#Memory.v1_6_0.Memory",
    "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory/DIMM.Socket.A2",
    "AllowedSpeedsMHz": [
        3200
    ],
    "AllowedSpeedsMHz@odata.count": 1,
    "Assembly": {
        "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
    },
    "BaseModuleType": null,
    "BusWidthBits": 72,
    "CacheSizeMiB": 0,
    "CapacityMiB": 32768,
    "DataWidthBits": 64,
    "Description": "DIMM A2",
    "DeviceLocator": "DIMM A2",
    "ErrorCorrection": "MultiBitECC",
    "FirmwareRevision": "",
    "Id": "DIMM.Socket.A2",
    "Links": {
        "Chassis": {
            "@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
        }
    },
    "LogicalSizeMiB": 0,
    "Manufacturer": "Hynix Semiconductor",
    "MaxTDPMilliWatts": [],
    "MaxTDPMilliWatts@odata.count": 0,
    "MemoryDeviceType": "DDR4",
    "MemoryMedia": [],
    "MemoryMedia@odata.count": 0,
    "MemorySubsystemControllerManufacturerID": null,
    "MemorySubsystemControllerProductID": null,
    "MemoryType": "DRAM",
    "Metrics": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory/DIMM.Socket.A2/MemoryMetrics"
    },
    "ModuleManufacturerID": null,
    "ModuleProductID": null,
    "Name": "DIMM A2",
    "NonVolatileSizeMiB": 0,
    "Oem": {
        "Dell": {
            "DellMemory": {
                "BankLabel": "A",
                "LastSystemInventoryTime": "2020-01-23T14:47:56+00:00",
                "LastUpdateTime": "2020-01-04T13:51:14+00:00",
                "ManufactureDate": "Mon Dec 09 13:00:00 2019 UTC",
                "MemoryTechnology": "DRAM",
                "Model": "DDR4 DIMM",
                "RemainingRatedWriteEndurancePercent": null,
                "SystemEraseCapability": "NotSupported",
                "@odata.context": "/redfish/v1/$metadata#DellMemory.DellMemory",
                "@odata.type": "#DellMemory.v1_1_0.DellMemory",
                "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/Memory/DellMemory/DIMM.Socket.A2"
            }
        }
    },
    "OperatingMemoryModes": [
        "Volatile"
    ],
    "OperatingMemoryModes@odata.count": 1,
    "OperatingSpeedMhz": 3200,
    "PartNumber": "zzzzzzz",
    "RankCount": 2,
    "SerialNumber": "xxxxx",
    "Status": {
        "Health": "OK",
        "State": "Enabled"
    },
    "VolatileSizeMiB": 32768
}
jenningsloy318 commented 4 years ago

@matejzero created a issue on upstream https://github.com/stmcginnis/gofish/issues/61, will try to fix it once there is a update

jenningsloy318 commented 4 years ago

@matejzero Please grab the latest source code, build the binary and then test if the issue is fixed

matejzero commented 4 years ago

Working on Lenovo servers, but can't confirm on Dell as it panics due to an error in powersupplies. Will open a separate ticket.