banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Hardware

banshee/hardware-collection/hardware/redfish/https/

processors

The health, type and cores of each processor of a server by Redfish.

  • hardware
  • server
  • redfish
  • bmc
  • processor
  • cpu
  • https

by banshee1 installation1 version

v1Latest

Published on October 27, 2026. First version.

Keen 1.0.0 · 106 lines
// The processors of a server, by the Redfish service of its management card (DMTF Redfish): the health of
// each processor the system lists (central processors, and on some cards the GPUs and FPGAs it carries), its
// type and its cores. Any card that serves Redfish: Dell iDRAC, HPE iLO, Supermicro, Lenovo XCC, OpenBMC.
need('protocol:http');
$address = need('host:address');
$user = need('protocol:http:user');
$password = need('protocol:http:password');

per('processor', 'Processors');
output('health', 'text', array('label' => 'Health', 'per' => 'processor'));
output('type', 'text', array('label' => 'Type', 'per' => 'processor'));
output('cores', 'number', array('label' => 'Cores', 'per' => 'processor'));

watch.state('unhealthy', 'Processor degraded', 'health', array('warning' => array('warning'), 'critical' => array('critical')));
watch.missing('missing', 'Processor missing', 'health', array('enabled' => false));

// Returns one Redfish resource, read by its path (/redfish/v1/...), the account in Basic. The password only
// goes in the Basic header: the answer is not secret.
function redfish_get($address, $path, $user, $password) {
    $answer = http.get('https://' . $address . $path, headers=array('Accept' => 'application/json'), user=$user, password=$password);
    if ($answer['status'] == 401 || $answer['status'] == 403) {
        fail('misconfigured', 'The Redfish service refuses the account, code ' . $answer['status'], $path);
    }
    if ($answer['status'] != 200) {
        fail('unreachable', 'The Redfish service answers code ' . $answer['status'], $path);
    }
    return json.read($answer['body']);
}

// Returns the health of a resource, in lower case (ok, warning, critical): the health it rolls up from what
// is under it when it gives one, its own otherwise, unknown when it gives neither.
function health_of($resource) {
    $status = list.get($resource, 'Status', array());
    $health = list.get($status, 'HealthRollup', '');
    if ($health == '') {
        $health = list.get($status, 'Health', '');
    }
    if ($health == '') {
        return 'unknown';
    }
    return text.lower($health);
}

// Returns the instance name of each item: its name, or, when another item bears the same name, its name
// followed by its id.
function instance_names($items) {
    $counts = array();
    foreach ($items as $item) {
        $counts[$item['name']] = list.get($counts, $item['name'], 0) + 1;
    }
    $names = array();
    foreach ($items as $key => $item) {
        $names[$key] = $item['name'];
        if ($item['name'] == '' || $counts[$item['name']] > 1) {
            $names[$key] = text.trim($item['name'] . ' ' . $item['id']);
        }
        // A card that gives neither a name nor an id (both null, read as '').
        if ($names[$key] == '') {
            $names[$key] = 'unnamed ' . ($key + 1);
        }
    }
    return $names;
}

// A processor: {"Id": "CPU.Socket.1", "Name": "CPU 1", "Socket": "CPU.Socket.1", "ProcessorType": "CPU",
// "TotalCores": 32, "Status": {"State": "Enabled", "Health": "OK"}}. An empty socket is a processor the card
// says absent.
$items = array();
$systems = redfish_get($address, '/redfish/v1/Systems', $user, $password);
foreach (list.get($systems, 'Members', array()) as $member) {
    $system = redfish_get($address, $member['@odata.id'], $user, $password);
    if (!list.has($system, 'Processors')) {
        continue;
    }
    $processors = redfish_get($address, $system['Processors']['@odata.id'], $user, $password);
    foreach (list.get($processors, 'Members', array()) as $link) {
        $processor = redfish_get($address, $link['@odata.id'], $user, $password);
        if (list.get(list.get($processor, 'Status', array()), 'State', '') == 'Absent') {
            continue;
        }
        $item = array('name' => list.get($processor, 'Name', list.get($processor, 'Socket', 'Processor')),
            'id' => list.get($processor, 'Id', ''), 'health' => health_of($processor));
        if (list.get($processor, 'ProcessorType', '') != '') {
            $item['type'] = text.lower($processor['ProcessorType']);
        }
        if (list.get($processor, 'TotalCores', '') != '') {
            $item['cores'] = $processor['TotalCores'];
        }
        $items = list.add($items, $item);
    }
}

if (list.count($items) == 0) {
    fail('misconfigured', 'The Redfish service serves no processor',
        'No system links to a Processors collection, or every socket is empty.');
}
$names = instance_names($items);
foreach ($items as $key => $item) {
    value('health', $item['health'], $names[$key]);
    if (list.has($item, 'type')) {
        value('type', $item['type'], $names[$key]);
    }
    if (list.has($item, 'cores')) {
        value('cores', $item['cores'], $names[$key]);
    }
}