mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Feature: Custom OID polling and graphing (#10945)
* merge * fix db migration * fix new auth * fix new auth * fix new auth * fix new auth * fix db schema tests * fix polling customoid * fix polling customoid * fix graph * fix graph * fix graph * fix CI * fix CI * always update prev value * typo
This commit is contained in:
46
includes/html/forms/parse-customoid.inc.php
Normal file
46
includes/html/forms/parse-customoid.inc.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
);
|
||||
echo _json_encode($response);
|
||||
exit;
|
||||
}
|
||||
$customoid_id = $_POST['customoid_id'];
|
||||
|
||||
if (is_numeric($customoid_id) && $customoid_id > 0) {
|
||||
$oid = dbFetchRow('SELECT * FROM `customoids` WHERE `customoid_id` = ? LIMIT 1', [$customoid_id]);
|
||||
|
||||
if ($oid['customoid_alert'] == 1) {
|
||||
$alerts = true;
|
||||
} else {
|
||||
$alerts = false;
|
||||
}
|
||||
if ($oid['customoid_passed'] == 1) {
|
||||
$cpassed = true;
|
||||
$passed = 'on';
|
||||
} else {
|
||||
$cpassed = false;
|
||||
$passed = '';
|
||||
}
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo json_encode([
|
||||
'name' => $oid['customoid_descr'],
|
||||
'oid' => $oid['customoid_oid'],
|
||||
'datatype' => $oid['customoid_datatype'],
|
||||
'unit' => $oid['customoid_unit'],
|
||||
'divisor' => $oid['customoid_divisor'],
|
||||
'multiplier' => $oid['customoid_multiplier'],
|
||||
'limit' => $oid['customoid_limit'],
|
||||
'limit_warn' => $oid['customoid_limit_warn'],
|
||||
'limit_low' => $oid['customoid_limit_low'],
|
||||
'limit_low_warn' => $oid['customoid_limit_low_warn'],
|
||||
'alerts' => $alerts,
|
||||
'cpassed' => $cpassed,
|
||||
'passed' => $passed,
|
||||
'user_func' => $oid['user_func'],
|
||||
]);
|
||||
}
|
Reference in New Issue
Block a user