40. Reports » Dashboards
Dashboards allow you to group data from any report – according to your specific needs – into one tab.
A few sample dashboards are included by default. If you have Administrator or Operator privileges, you can create and configure additional dashboards by clicking the Reports » Dashboards » [+] button on the panel’s title. Guest accounts cannot add or modify dashboards unless their role grants full dashboard permissions.
Clicking the [Configuration] button opens the Dashboard Configuration window:
● Dashboard Name – The name displayed on the dashboard tab● Dashboard Order – Position of the dashboard in the Dashboards panel, from 1 to 300● Time Range Source – Per Widget lets each widget use its own time range, while Per Dashboard overrides every widget with the dashboard’s overall time range● Default Time Range – The time range selected when the dashboard opens, from Last Hour up to Last 10 Years● Permissions – Who can modify the dashboard: Everybody, Only Administrators & Operators, Only Administrators, or Only Me● Widget Title Bar – Controls how the title bars of all widgets are rendered: Show, Show without Icons, Show without Icons and Buttons, Show as Text, or Hide — the last option is useful for wallboard-style dashboards displayed on large screens● Layout Type – Selected only when the dashboard is created: Columns stacks widgets into columns with content-driven heights, while Grid lets you place and resize widgets freely on a fixed 12-column grid● Layout – Shown for Columns dashboards only: the number of columns (1 to 4) and each column’s width percentage● Comments – Record any notes about the dashboard here. These remarks are for internal reference only
The dashboard tab’s own toolbar provides a context selector matched to the dashboard type (Sensor Interfaces, Servers, or Filters), an Actions panel with the [Add Widget] and [Configuration] buttons (hidden for guest accounts), a Time Range bar, and a Refresh split button that regenerates all widgets manually (Generate) or flicker-free at intervals from 5 seconds up to 15 minutes.
40.1. Widgets
Each dashboard contains widgets. Click [Add Widget] to insert one. The menu groups the available widgets by category; some entries appear only on the matching dashboard type (e.g., Console Events on Console dashboards, IP Accounting on IP dashboards):
Most widgets present the data of a report documented in another chapter. The exceptions are described below:
To sort widgets, click a widget’s title bar and drag it. On Grid dashboards, dragging a title bar moves the widget anywhere on the grid, and dragging a widget’s edges resizes it. To collapse a widget, click the first icon in its title bar. To configure a widget, click the second icon. To delete it, click the third icon.
Every widget has:
● A title (editable)● A height. On Columns dashboards, the default is Auto, so the widget expands as needed; alternatively, specify a fixed height in pixels, applied to the widget’s Canvas or Overall area according to the adjacent selector. On Grid dashboards, graph widgets always fill the widget frame, while the remaining widgets provide a Widget Height selector set to Automatic or Fixed● Other options described in the relevant chapters
40.2. Custom Widgets
The Custom Content widget – located in the Console widget category – renders content you provide, which makes it the extension point for building your own widgets. Its configuration window contains:
● Widget Title – The text displayed on the widget’s title bar● Widget Height – The widget’s height, as described in the previous section● Console Link Generator – Select a Console report from the Insert Links drop-down to generate an HTML snippet that opens that report in a new Console tab when clicked. Copy the generated code into the content field below● The content field – The content to render: plain text, an HTML fragment, or the absolute path of a PHP file located on the Console server (e.g.,/opt/andrisoft/webroot/mywidget.php)
When the content field contains only a file path that starts with /opt/andrisoft/webroot/, the Console executes the file with the PHP command-line interpreter on every widget refresh and renders the script’s output as the widget’s body. The script can therefore collect data from any source and emit any HTML.
40.2.1. Writing a custom PHP widget
Observe the following when writing the PHP file:
● The file must reside inside/opt/andrisoft/webroot/and be readable by the web server. Creating it requires shell access to the Console server● The script is executed as a stand-alone process, without arguments. It does not receive the Console session, the dashboard’s time range or context selection, or any HTTP request data● The script runs every time the widget is refreshed – potentially every 5 seconds – so keep it fast and cache the results of expensive operations● The script’s standard output is rendered as HTML inside the widget body for every user able to view the dashboard● Test the script from the CLI first, by runningphp /opt/andrisoft/webroot/mywidget.php
To let the script consume product data, use the REST API: enable REST API Access for a Console user in General Settings » User Management , then call the API over HTTPS with HTTP basic authentication. Because the script runs on the Console server itself, it can reach the API locally at https://127.0.0.1/wanguard-api/v1/…. The available API calls are described in Appendix 5 – Using the REST API.
40.2.2. Example custom widget
The script below renders a table with the live status and traffic of every active Sensor, obtained through the GET /wanguard-api/v1/sensor_live_stats API call. Save it as /opt/andrisoft/webroot/mywidget.php, replace the API credentials, then add a Custom Content widget whose content field contains only the path to the file:
<?php
/* Live Sensor status board - example Custom Content widget */
$apiUser = 'api_user'; // Console user with REST API Access enabled
$apiPass = 'api_pass';
$apiUrl = 'https://127.0.0.1/wanguard-api/v1/sensor_live_stats';
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPAUTH => CURLAUTH_ANY,
CURLOPT_USERPWD => "$apiUser:$apiPass",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HTTPHEADER => ['Accept: application/json'],
]);
$json = curl_exec($ch);
if (curl_errno($ch)) {
echo '<p>REST API error: ' . htmlspecialchars(curl_error($ch)) . '</p>';
exit;
}
curl_close($ch);
$sensors = json_decode($json, true);
if (!is_array($sensors) || !count($sensors)) {
echo '<p>No active Sensors.</p>';
exit;
}
function format_bps($value) {
foreach (['bps', 'Kbps', 'Mbps', 'Gbps'] as $unit) {
if ($value < 1000) return round($value, 1) . ' ' . $unit;
$value /= 1000;
}
return round($value, 1) . ' Tbps';
}
echo '<table class="wgtable" width="100%">';
echo '<tr><th align="left">Sensor Interface</th><th>Status</th>' .
'<th align="right">Bits/s In</th><th align="right">Bits/s Out</th>' .
'<th align="right">CPU %</th><th align="right">Dropped In</th></tr>';
foreach ($sensors as $row) {
printf('<tr><td>%s</td><td align="center" style="color:%s">%s</td>' .
'<td align="right">%s</td><td align="right">%s</td>' .
'<td align="right">%s</td><td align="right">%s</td></tr>',
htmlspecialchars($row['sensor']['sensor_interface_name']),
$row['status'] === 'Active' ? 'green' : 'red',
$row['status'],
format_bps($row['bits/s_in']),
format_bps($row['bits/s_out']),
$row['cpu%'],
$row['dropped_in']);
}
echo '</table>';
Note
The example disables TLS certificate validation (CURLOPT_SSL_VERIFYHOST and CURLOPT_SSL_VERIFYPEER) so it works with the Console’s self-signed certificate; if the Console has a trusted certificate, set these options to 2 and true respectively. Since the file stores API credentials in clear text, restrict its permissions so that only the web server can read it, and use a dedicated Console user whose role permits only the required calls.