mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
use LibreNMS\RRD\RrdDefinition;
|
|
|
|
$name = 'drbd';
|
|
$drbd_data = $agent_data['app'][$name][$app->app_instance];
|
|
foreach (explode('|', $drbd_data) as $part) {
|
|
[$stat, $val] = explode('=', $part);
|
|
if (! empty($stat)) {
|
|
$drbd[$stat] = $val;
|
|
}
|
|
}
|
|
|
|
$rrd_name = ['app', $name, $app->app_instance];
|
|
$rrd_def = RrdDefinition::make()
|
|
->addDataset('ns', 'DERIVE', 0, 125000000000)
|
|
->addDataset('nr', 'DERIVE', 0, 125000000000)
|
|
->addDataset('dw', 'DERIVE', 0, 125000000000)
|
|
->addDataset('dr', 'DERIVE', 0, 125000000000)
|
|
->addDataset('al', 'DERIVE', 0, 125000000000)
|
|
->addDataset('bm', 'DERIVE', 0, 125000000000)
|
|
->addDataset('lo', 'GAUGE', 0, 125000000000)
|
|
->addDataset('pe', 'GAUGE', 0, 125000000000)
|
|
->addDataset('ua', 'GAUGE', 0, 125000000000)
|
|
->addDataset('ap', 'GAUGE', 0, 125000000000)
|
|
->addDataset('oos', 'GAUGE', 0, 125000000000);
|
|
|
|
$fields = [
|
|
'ns' => $drbd['ns'],
|
|
'nr' => $drbd['nr'],
|
|
'dw' => $drbd['dw'],
|
|
'dr' => $drbd['dr'],
|
|
'al' => $drbd['al'],
|
|
'bm' => $drbd['bm'],
|
|
'lo' => $drbd['lo'],
|
|
'pe' => $drbd['pe'],
|
|
'ua' => $drbd['ua'],
|
|
'ap' => $drbd['ap'],
|
|
'oos' => $drbd['oos'],
|
|
];
|
|
|
|
$tags = ['name', 'app_id', 'rrd_name', 'rrd_def'];
|
|
data_update($device, 'app', $tags, $fields);
|
|
update_application($app, $drbd_data, $fields);
|
|
|
|
unset($drbd, $drbd_data);
|