Files
Zane C. Bowers-Hadley 75d4da325a add generic and improved NFS support with initial support for both FreeBSD and Linux (#15906)
* add nfs-shared.inc.php

* add nfs poller

* polling now works

* add nfs.inc.php page

* mount options works now

* format cleanup

* add some missing items to the stats

* commit work from last night so I can swap over to ldap

* add gauge support

* save the OS type for it

* more work on NFS stuff

* more nfs work

* display cleanup some

* more nfs work

* update docs for NFS

* add nfs_server_rpc

* style fix

* add snmprec file

* more test stuff

* data cleanup

* style cleanup

* more style fix

* another style fix

* add deleted_at

* add client_rpc_info_calls

* more test tweaks

* more tweaks

* set two items as gauges that should be gauges

* convert a few more things from counters to gauges

* a few more tweaks for NFSv4
2024-06-30 19:36:58 -05:00

56 lines
1.5 KiB
PHP

<?php
use LibreNMS\Exceptions\JsonAppException;
use LibreNMS\RRD\RrdDefinition;
$name = 'nfs';
try {
$returned = json_app_get($device, $name, 1);
} 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;
}
include 'includes/nfs-shared.inc.php';
$data = $returned['data'];
$rrd_def = RrdDefinition::make()
->addDataset('data', 'COUNTER');
$gauge_rrd_def = RrdDefinition::make()
->addDataset('data', 'GAUGE');
$metrics = [];
foreach (array_keys($nfs_stat_keys) as $stat_name) {
$rrd_name = ['app', $name, $app->app_id, $stat_name];
$fields = ['data' => $returned['data']['stats'][$stat_name]];
if (isset($gauge_stats[$stat_name])) {
$rrd_def_to_use = $gauge_rrd_def;
} else {
$rrd_def_to_use = $rrd_def;
}
$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_to_use, 'rrd_name' => $rrd_name];
data_update($device, 'app', $tags, $fields);
$metrics[$stat_name] = $returned['data']['stats'][$stat_name];
}
$app_data = [
'is_client' => $returned['data']['is_client'],
'is_server' => $returned['data']['is_server'],
'mounts' => $returned['data']['mounts'],
'mounted_by' => $returned['data']['mounted_by'],
'os' => $returned['data']['os'],
];
$app->data = $app_data;
update_application($app, 'OK', $metrics);