Skip to content

Commit

Permalink
Oxidized better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed Dec 5, 2024
1 parent 3b18d71 commit cc72a8e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/html/pages/device/showconfig.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
// Try with hostname as set in librenms first
$oxidized_hostname = $device['hostname'];
// fetch info about the node and then a list of versions for that node
$node_info = json_decode((new \App\ApiClients\Oxidized())->getContent('/node/show/' . $oxidized_hostname . '?format=json'), true);
$response = (new \App\ApiClients\Oxidized())->getContent('/node/show/' . $oxidized_hostname . '?format=json');
$node_info = json_decode($response, true);
if (! empty($node_info['last']['start'])) {
$node_info['last']['start'] = date(Config::get('dateformat.long'), strtotime($node_info['last']['start']));
}
Expand All @@ -169,7 +170,8 @@

// Try Oxidized again with new hostname, if it has changed
if ($oxidized_hostname != $device['hostname']) {
$node_info = json_decode((new \App\ApiClients\Oxidized())->getContent('/node/show/' . $oxidized_hostname . '?format=json'), true);
$response = (new \App\ApiClients\Oxidized())->getContent('/node/show/' . $oxidized_hostname . '?format=json');
$node_info = json_decode($response, true);
}
}

Expand Down Expand Up @@ -301,6 +303,9 @@
} else {
echo '<br />';
print_error("We couldn't retrieve the device information from Oxidized");
if (isset($response) && preg_match('#<title>(.*)</title>#', $response, $error_matches)) {
print_error(htmlentities($error_matches[1]));
}
$text = '';
}
}//end if
Expand Down

0 comments on commit cc72a8e

Please sign in to comment.