Hardware
banshee/hardware-collection/hardware/redfish/https/
event-log
The critical and warning entries of the event logs of a server by Redfish, a new one raising.
by banshee1 installation1 version
Published on October 27, 2026. First version.
// The event logs of a server, by the Redfish service of its management card (DMTF Redfish): for each log the
// system serves (the System Event Log, HPE's Integrated Management Log), the number of its entries of
// critical and of warning severity. A new critical entry raises; one already read, kept in the log for
// years, does not. 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('log', 'Logs');
output('critical', 'number', array('label' => 'Critical entries', 'per' => 'log'));
output('warning', 'number', array('label' => 'Warning entries', 'per' => 'log'));
output('entries', 'number', array('label' => 'Entries', 'per' => 'log'));
watch.increase('new-critical', 'New critical entries', 'critical', array('critical' => 0, 'window' => '1 d', 'enabled' => false));
watch.increase('new-warning', 'New warning entries', 'warning', array('warning' => 0, 'window' => '1 d', 'enabled' => false));
watch.missing('missing', 'Log missing', 'entries', 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']);
}
// A system: {"LogServices": {"@odata.id": ".../LogServices"}}. A log service: {"Id": "Sel", "Name": "System
// Event Log", "Entries": {"@odata.id": ".../Sel/Entries"}}. An entry: {"Severity": "Critical", "Message":
// "...", "Created": "..."}; the severities of Redfish: OK, Warning, Critical.
$read = 0;
$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, 'LogServices')) {
continue;
}
$services = redfish_get($address, $system['LogServices']['@odata.id'], $user, $password);
foreach (list.get($services, 'Members', array()) as $link) {
$service = redfish_get($address, $link['@odata.id'], $user, $password);
if (!list.has($service, 'Entries')) {
continue;
}
// Its name, or its id, or its path, whichever the card gives first (a null reads as '').
$name = list.get($service, 'Name', '');
if ($name == '') {
$name = list.get($service, 'Id', '');
}
if ($name == '') {
$name = $link['@odata.id'];
}
// The entries come a page at a time: the card gives the next page's path under
// Members@odata.nextLink when it cuts the list, until the last.
$critical = 0;
$warning = 0;
$entries = 0;
$path = $service['Entries']['@odata.id'];
while ($path != '') {
$page = redfish_get($address, $path, $user, $password);
foreach (list.get($page, 'Members', array()) as $entry) {
$entries = $entries + 1;
$severity = list.get($entry, 'Severity', '');
if ($severity == 'Critical') {
$critical = $critical + 1;
} elseif ($severity == 'Warning') {
$warning = $warning + 1;
}
}
$path = list.get($page, 'Members@odata.nextLink', '');
}
value('critical', $critical, $name);
value('warning', $warning, $name);
value('entries', $entries, $name);
$read = $read + 1;
}
}
if ($read == 0) {
fail('misconfigured', 'The Redfish service serves no event log under its systems',
'No system links to a LogServices collection with entries.');
}