librenms-librenms/includes/html/forms/parse-customoid.inc.php
louis-oui 934260cc75 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
2019-12-18 18:17:21 -06:00

47 lines
1.4 KiB
PHP

<?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'],
]);
}