mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
add Linux Softnet Stat app (#15094)
* add linux_softnet_stat poller * add graphs and app page for linux_softnet_stat * fix polling * rename a few items, clean up the app specific page, and add to the apps page * convert from derive to counter * save the budget and budget_usecs to app data * display current value of the budgets * now track budget values * add tests data * rename it * add docs for Linux Softnet Stat * re-order and add budget for app page graph order * style fix * correct data location * fix metrics for the json
This commit is contained in:
parent
3190bdb8b2
commit
0ed68e33de
@ -996,6 +996,33 @@ b.) "pkg_tool_cmd" - String path to the package tool binary ["/sbin/rpmconf"]
|
||||
|
||||
5. Restart snmpd.
|
||||
|
||||
## Linux Softnet Stat
|
||||
|
||||
### SNMP Extend
|
||||
|
||||
1: Install the depends, which on a Debian based system would be as below.
|
||||
```
|
||||
apt-get install -y cpanminus zlib1g-dev
|
||||
cpanm File::Slurp MIME::Base64 JSON Gzip::Faster
|
||||
```
|
||||
|
||||
2. Download the script into the desired host.
|
||||
```
|
||||
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/linux_softnet_stat -O /etc/snmp/linux_softnet_stat
|
||||
```
|
||||
|
||||
3. Make the script executable
|
||||
```
|
||||
chmod +x /etc/snmp/linux_softnet_stat
|
||||
```
|
||||
|
||||
4. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add:
|
||||
```
|
||||
extend linux_softnet_stat /etc/snmp/linux_softnet_stat -b
|
||||
```
|
||||
|
||||
Then either enable the application Linux Softnet Stat or wait for it to be re-discovered.
|
||||
|
||||
## mailcow-dockerized postfix
|
||||
|
||||
### SNMP Extend
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'backlog_length';
|
||||
$unit_text = 'Backlog Length';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
$name = 'linux_softnet_stat';
|
||||
$unit_text = 'Budget Value';
|
||||
$colours = 'psychedelic';
|
||||
$dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 15;
|
||||
|
||||
$rrd_filename = Rrd::name($device['hostname'], ['app', $name, $app->app_id]);
|
||||
|
||||
$rrd_list = [];
|
||||
if (Rrd::checkRrdExists($rrd_filename)) {
|
||||
$rrd_list[] = [
|
||||
'filename' => $rrd_filename,
|
||||
'descr' => 'Budget',
|
||||
'ds' => 'budget',
|
||||
];
|
||||
$rrd_list[] = [
|
||||
'filename' => $rrd_filename,
|
||||
'descr' => 'Budget usecs',
|
||||
'ds' => 'budget_usecs',
|
||||
];
|
||||
} else {
|
||||
d_echo('RRD "' . $rrd_filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_multi_line.inc.php';
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'cpu_collision';
|
||||
$unit_text = 'CPU Collision';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'flow_limit';
|
||||
$unit_text = 'Limit Hits/Sec';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'packet_dropped';
|
||||
$unit_text = 'Pkt Drops/Sec';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'packets';
|
||||
$unit_text = 'Pkts/Sec';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'received_rps';
|
||||
$unit_text = 'RPS/Sec';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$ds = 'time_squeeze';
|
||||
$unit_text = 'Time Squeeze';
|
||||
$filename = Rrd::name($device['hostname'], ['app', 'linux_softnet_stat', $app->app_id]);
|
||||
|
||||
if (! Rrd::checkRrdExists($filename)) {
|
||||
d_echo('RRD "' . $filename . '" not found');
|
||||
}
|
||||
|
||||
require 'includes/html/graphs/generic_stats.inc.php';
|
@ -456,6 +456,16 @@ $graphs['wireguard'] = [
|
||||
$graphs['linux_config_files'] = [
|
||||
'number_of_confs',
|
||||
];
|
||||
$graphs['linux_softnet_stat'] = [
|
||||
'packets',
|
||||
'time_squeeze',
|
||||
'backlog_length',
|
||||
'packet_dropped',
|
||||
'cpu_collision',
|
||||
'flow_limit',
|
||||
'received_rps',
|
||||
'budget',
|
||||
];
|
||||
|
||||
echo '<div class="panel panel-default">';
|
||||
echo '<div class="panel-heading">';
|
||||
|
39
includes/html/pages/device/apps/linux_softnet_stat.inc.php
Normal file
39
includes/html/pages/device/apps/linux_softnet_stat.inc.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
$budget = $app->data['budget'] ?? 'unknown';
|
||||
$budget_usecs = $app->data['budget_usecs'] ?? 'unknown';
|
||||
|
||||
print_optionbar_start();
|
||||
echo 'Current Budget: ' . $budget . "<br>\nCurrent Budget usecs:" . $budget_usecs . "\n<br>";
|
||||
print_optionbar_end();
|
||||
|
||||
$graphs = [
|
||||
'linux_softnet_stat_packets' => 'Packets Per Second',
|
||||
'linux_softnet_stat_time_squeeze' => 'Time Squeezes Per Second',
|
||||
'linux_softnet_stat_backlog_length' => 'Backlog Lenght',
|
||||
'linux_softnet_stat_packet_dropped' => 'Packets Dropped Per Second',
|
||||
'linux_softnet_stat_cpu_collision' => 'CPU Collisions Per Second',
|
||||
'linux_softnet_stat_flow_limit' => 'Flow Limit Hit Per Second',
|
||||
'linux_softnet_stat_received_rps' => 'Received RPS Per Second',
|
||||
'linux_softnet_stat_budget' => 'Budget Sysctl Values',
|
||||
];
|
||||
|
||||
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;
|
||||
|
||||
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>';
|
||||
}
|
44
includes/polling/applications/linux_softnet_stat.inc.php
Normal file
44
includes/polling/applications/linux_softnet_stat.inc.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Exceptions\JsonAppException;
|
||||
use LibreNMS\RRD\RrdDefinition;
|
||||
|
||||
$name = 'linux_softnet_stat';
|
||||
|
||||
try {
|
||||
$data = json_app_get($device, $name)['data'];
|
||||
} catch (JsonAppException $e) {
|
||||
echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL;
|
||||
update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rrd_name = ['app', $name, $app->app_id];
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('backlog_length', 'GAUGE')
|
||||
->addDataset('cpu_collision', 'COUNTER')
|
||||
->addDataset('flow_limit', 'COUNTER')
|
||||
->addDataset('packet_dropped', 'COUNTER')
|
||||
->addDataset('packets', 'COUNTER')
|
||||
->addDataset('received_rps', 'COUNTER')
|
||||
->addDataset('time_squeeze', 'COUNTER')
|
||||
->addDataset('budget', 'GAUGE')
|
||||
->addDataset('budget_usecs', 'GAUGE');
|
||||
|
||||
$fields = [
|
||||
'backlog_length' => $data['totals']['backlog_length'],
|
||||
'cpu_collision' => $data['totals']['cpu_collision'],
|
||||
'flow_limit' => $data['totals']['flow_limit'],
|
||||
'packet_dropped' => $data['totals']['packet_dropped'],
|
||||
'packets' => $data['totals']['packets'],
|
||||
'received_rps' => $data['totals']['received_rps'],
|
||||
'time_squeeze' => $data['totals']['time_squeeze'],
|
||||
'budget' => $data['budget'],
|
||||
'budget_usecs' => $data['budget_usecs'],
|
||||
];
|
||||
|
||||
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
|
||||
data_update($device, 'app', $tags, $fields);
|
||||
$app->data = ['budget' => $data['budget'], 'budget_usecs' => $data['budget_usecs']];
|
||||
update_application($app, 'OK', $fields);
|
86
tests/data/linux_linux_softnet_stat-v1.json
Normal file
86
tests/data/linux_linux_softnet_stat-v1.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"applications": {
|
||||
"discovery": {
|
||||
"applications": [
|
||||
{
|
||||
"app_type": "linux_softnet_stat",
|
||||
"app_state": "UNKNOWN",
|
||||
"discovered": "1",
|
||||
"app_state_prev": null,
|
||||
"app_status": "",
|
||||
"app_instance": "",
|
||||
"data": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"poller": {
|
||||
"applications": {
|
||||
"0": {
|
||||
"app_type": "linux_softnet_stat",
|
||||
"app_state": "OK",
|
||||
"discovered": "1",
|
||||
"app_state_prev": "UNKNOWN",
|
||||
"app_status": "",
|
||||
"app_instance": "",
|
||||
"data": "{\"budget\":\"300\",\"budget_usecs\":\"8000\"}"
|
||||
}
|
||||
},
|
||||
"application_metrics": [
|
||||
{
|
||||
"metric": "backlog_length",
|
||||
"value": "0",
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "budget",
|
||||
"value": "300",
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "budget_usecs",
|
||||
"value": "8000",
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "cpu_collision",
|
||||
"value": 0,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "flow_limit",
|
||||
"value": 0,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "packet_dropped",
|
||||
"value": 0,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "packets",
|
||||
"value": 395382025,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "received_rps",
|
||||
"value": 0,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
},
|
||||
{
|
||||
"metric": "time_squeeze",
|
||||
"value": 0,
|
||||
"value_prev": null,
|
||||
"app_type": "linux_softnet_stat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
10
tests/snmpsim/linux_linux_softnet_stat-v1.snmprec
Normal file
10
tests/snmpsim/linux_linux_softnet_stat-v1.snmprec
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user