Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ChangeLog

--- develop ---
* feature: Make the Fleet Dashboard the first tab and the default landing view on the Host MIB interface
* feature: Add a Fleet (Summary) Dashboard reached by a dashboard glyph on the Summary tab's Device Type rows: a draggable, add/remove card grid scoped to all devices or one OS type, with min/avg/max bullet charts (CPU/memory/swap/processes/uptime), a device-status stacked bar, OS type distribution, storage utilization, fleet stat tiles, and top processes by CPU and by memory; scope, card order, expanded state and refresh interval persist per user
* issue: Fix 'Uncaught TypeError: runCollector(): Argument #2 ($lastrun) must be of type float, null given' in the poller when a collector's *_lastrun/*_freq setting has never been written (e.g. a task's first run); runCollector() now accepts null and normalizes it
* issue: Fix the per-device Dashboard Storage, Per-Processor Load, Hardware and Installed Software cards rendering empty because they filtered on 'present = 1' while the underlying Storage/Hardware/Inventory tabs never did, and add a Process Use History card
Expand Down
22 changes: 10 additions & 12 deletions hmib.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
chdir('../../');
include('./include/auth.php');

set_default_action('summary');
set_default_action('summary_dashboard');
Comment thread
TheWitness marked this conversation as resolved.

if (get_request_var('action') == 'ajax_hosts') {
get_allowed_ajax_hosts(true, false, 'h.id IN (SELECT host_id FROM plugin_hmib_hrSystem)');
Expand Down Expand Up @@ -2909,7 +2909,8 @@ function clearFilter() {

/**
* Renders the top tabbed navigation bar for this page's views
* (summary/devices/storage/hardware/running/history/software/graphs),
* (summary_dashboard/summary/devices/storage/hardware/running/history/software/graphs,
* plus the conditional per-device dashboard tab),
* highlighting whichever tab corresponds to the current action. Called
* from this script's main flow at the top of every rendered view.
*
Expand All @@ -2923,6 +2924,7 @@ function hmib_tabs(): void {

// present a tabbed interface
$tabs = [
'summary_dashboard' => __esc('Fleet Dashboard', 'hmib'),
Comment thread
TheWitness marked this conversation as resolved.
'summary' => __esc('Summary', 'hmib'),
'devices' => __esc('Devices', 'hmib'),
'storage' => __esc('Storage', 'hmib'),
Expand All @@ -2936,20 +2938,15 @@ function hmib_tabs(): void {
// set the default tab
$current_tab = get_request_var('action');

// The stateful Dashboard tabs only appear once opened from their glyph: the
// Fleet Dashboard from the Summary tab, the per-device Dashboard from Devices.
$show_fleet = ($current_tab == 'summary_dashboard' || read_user_setting('hmib_summary_type', '') !== '');
// The Fleet Dashboard is the landing tab and is always present. The per-device
// Dashboard tab only appears once opened from its glyph on the Devices tab.
$show_device = ($current_tab == 'dashboard' || (int) read_user_setting('hmib_dashboard_host', 0) > 0);

$ordered = [];

foreach ($tabs as $tab_key => $tab_label) {
$ordered[$tab_key] = $tab_label;

if ($tab_key == 'summary' && $show_fleet) {
$ordered['summary_dashboard'] = __esc('Fleet Dashboard', 'hmib');
}

if ($tab_key == 'devices' && $show_device) {
$ordered['dashboard'] = __esc('Dashboard', 'hmib');
}
Expand All @@ -2975,8 +2972,8 @@ function hmib_tabs(): void {
* Renders the Host MIB dashboard/summary view: an overview of monitored
* device counts by status/OS type, top running processes, and other
* aggregate statistics, driven by this view's filter request
* variables. Called from this script's main request-dispatch switch as
* the default view (action=summary or no action).
* variables. Called from this script's main request-dispatch switch
* when action=summary.
*
* @return void
*
Expand Down Expand Up @@ -5431,7 +5428,8 @@ function hmib_summary_card_ajax(): string {
* uptime, OS type distribution and top processes by CPU/memory) scoped to all
* devices or a single OS type. Card order, expanded state, the selected OS type
* and the auto-refresh interval persist per user. Called from this script's main
* request-dispatch switch when action=summary_dashboard.
* request-dispatch switch when action=summary_dashboard, and as the default
* landing view when no action is supplied.
*
* @return void
*
Expand Down
8 changes: 8 additions & 0 deletions locales/po/cacti.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,14 @@ msgstr ""
msgid "Host MIB Inventory Summary"
msgstr ""

#: setup.php
msgid "Host MIB Device Dashboard"
msgstr ""

#: setup.php
msgid "Host MIB Fleet Dashboard"
msgstr ""

#: setup.php
msgid "Host MIB Details"
msgstr ""
Expand Down
7 changes: 5 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,19 @@ function hmib_config_arrays(): void {
/**
* Draw_navigation_text hook: registers the breadcrumb/navigation title
* entries for this plugin's hmib.php and hmib_types.php pages and their
* sub-views. Called by Cacti's navigation framework via the
* 'draw_navigation_text' hook.
* sub-views (including the Fleet Dashboard landing view
* summary_dashboard and the per-device dashboard). Called by Cacti's
* navigation framework via the 'draw_navigation_text' hook.
*
* @param array $nav The navigation entries array being built up.
*
* @return array The $nav array with this plugin's entries added.
*/
function hmib_draw_navigation_text($nav): array {
$nav['hmib.php:summary_dashboard'] = ['title' => __('Host MIB Fleet Dashboard', 'hmib'), 'mapping' => '', 'url' => 'hmib.php', 'level' => '0'];
$nav['hmib.php:summary'] = ['title' => __('Host MIB Inventory Summary', 'hmib'), 'mapping' => '', 'url' => 'hmib.php', 'level' => '0'];
$nav['hmib.php:devices'] = ['title' => __('Host MIB Details', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0'];
$nav['hmib.php:dashboard'] = ['title' => __('Host MIB Device Dashboard', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0'];
$nav['hmib.php:storage'] = ['title' => __('Host MIB Storage', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0'];
$nav['hmib.php:hardware'] = ['title' => __('Host MIB Hardware', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0'];
$nav['hmib.php:running'] = ['title' => __('Host MIB Running Processes', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0'];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/HmibNavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

expect($nav)->toHaveKey('other.php:');

foreach (array('hmib.php:summary', 'hmib.php:devices', 'hmib_types.php:', 'hmib_types.php:edit') as $key) {
foreach (array('hmib.php:summary_dashboard', 'hmib.php:summary', 'hmib.php:devices', 'hmib.php:dashboard', 'hmib_types.php:', 'hmib_types.php:edit') as $key) {
expect($nav)->toHaveKey($key);
}

expect($nav['hmib.php:summary_dashboard']['url'])->toBe('hmib.php');
expect($nav['hmib_types.php:']['url'])->toBe('hmib_types.php');
});
Loading