Files
librenms-librenms/includes/html/pages/device/apps/sagan.inc.php
Zane C. Bowers-Hadley b827e2bbbd add support for Sagan (#14070)
* add sagan instance fetch function

* add sagan discovery

* add sagan poller

* add sagan graphs

* add graph sources

* add sagan to apps page

* remove alert

* more app graph work

* polling fix

* re-order keys and add alert key

* correct field key usage

* add alert and fix a missing unit

* more unit fixes

* add alert status

* add alert rules for sagan

* fix a missing : after S while I am here in the json stat tool helper... also add tests

* now add the tests

* add docs

* point php-cs-fixer at two files

* remove-unneeded sagan instance fetch function

* convert to use app_data

* style fix

* apply bennet-esyoil's suggestions here as well

* update for the new app model

* convert poller to the new method

* convert the sagan device app page

* convert sagan

* doc cleanup
2022-08-04 18:12:34 -05:00

71 lines
1.9 KiB
PHP

<?php
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'apps',
'app' => 'sagan',
];
print_optionbar_start();
echo generate_link('Totals', $link_array);
$sagan_instances = $app->data['instances'] ?? [];
sort($sagan_instances);
foreach ($sagan_instances as $index => $sinstance) {
$label = $vars['sinstance'] == $sinstance
? '<span class="pagemenu-selected">' . $sinstance . '</span>'
: $sinstance;
echo generate_link($label, $link_array, ['sinstance' => $sinstance]);
if ($index < (count($sagan_instances) - 1)) {
echo ', ';
}
}
print_optionbar_end();
$graphs = [
'sagan_bytes'=>'Bytes',
'sagan_eps'=>'Events Per Second',
'sagan_total'=>'Recieved Log Entries',
'sagan_drop'=>'Drop',
'sagan_drop_percent'=>'Drop Percent',
'sagan_f_total'=>'Flows Total',
'sagan_f_dropped'=>'Flows Dropped',
'sagan_f_drop_percent'=>'Flows Dropped Percent',
'sagan_ignore'=>'Ignore',
'sagan_bytes_ignored'=>'Bytes Ignored',
'sagan_match'=>'Match',
'sagan_max_bytes_log_line'=>'Max Bytes Log Line',
'sagan_threshold'=>'Threshold',
'sagan_uptime'=>'Uptime',
'sagan_alert'=>'Alert: 0=OK, 1=WARNING, 2=CRITICAL, 3+UNKNOWN',
];
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = \LibreNMS\Config::get('time.now');
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_' . $key;
if (isset($vars['sinstance'])) {
$graph_array['sinstance'] = $vars['sinstance'];
}
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">' . $text . '</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/html/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}