Files
librenms-librenms/includes/polling/applications/linux_softnet_stat.inc.php
Zane C. Bowers-Hadley 0ed68e33de 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
2023-06-11 16:37:55 +02:00

45 lines
1.5 KiB
PHP

<?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);