mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Allow customisation of rrd step/heartbeat when creating new rrd files (#5947)
* feature: Allow customisation of rrd step/heartbeat when creating new rrd files * revert defaults * added docs + webui config option * Move RrdDefinition to an Object to make them easier to create and remove the possibility of typos. * Fix style/lint issues and missing use statements * 3 more missing use statements * updated doc + moved schema file
This commit is contained in:
@@ -8,14 +8,15 @@
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
use LibreNMS\RRD\RrdDefinition;
|
||||
|
||||
if (strstr($hardware, 'CMM') == false) {
|
||||
$fecInErrorsCount = snmp_get($device, "fecInErrorsCount.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB");
|
||||
$fecOutErrorsCount = snmp_get($device, "fecOutErrorsCount.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB");
|
||||
if (is_numeric($fecInErrorsCount) && is_numeric($fecOutErrorsCount)) {
|
||||
$rrd_def = array(
|
||||
'DS:fecInErrorsCount:GAUGE:600:0:100000',
|
||||
'DS:fecOutErrorsCount:GAUGE:600:0:100000'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('fecInErrorsCount', 'GAUGE', 0, 100000)
|
||||
->addDataset('fecOutErrorsCount', 'GAUGE', 0, 100000);
|
||||
|
||||
$fields = array(
|
||||
'fecInErrorsCount' => $fecInErrorsCount,
|
||||
@@ -29,7 +30,7 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
|
||||
$crcErrors = snmp_get($device, "fecCRCError.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB");
|
||||
if (is_numeric($crcErrors)) {
|
||||
$rrd_def = 'DS:crcErrors:GAUGE:600:0:100000';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('crcErrors', 'GAUGE', 0, 100000);
|
||||
$fields = array(
|
||||
'crcErrors' => $crcErrors,
|
||||
);
|
||||
@@ -42,11 +43,10 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
$horizontal = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.118.0", "-Ovqn", ""));
|
||||
$combined = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.21.0", "-Ovqn", "");
|
||||
if (is_numeric($vertical) && is_numeric($horizontal) && is_numeric($combined)) {
|
||||
$rrd_def = array(
|
||||
'DS:vertical:GAUGE:600:-150:0',
|
||||
'DS:horizontal:GAUGE:600:-150:0',
|
||||
'DS:combined:GAUGE:600:-150:0'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('vertical', 'GAUGE', -150, 0)
|
||||
->addDataset('horizontal', 'GAUGE', -150, 0)
|
||||
->addDataset('combined', 'GAUGE', -150, 0);
|
||||
$fields = array(
|
||||
'vertical' => floatval($vertical),
|
||||
'horizontal' => floatval($horizontal),
|
||||
@@ -60,7 +60,7 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
|
||||
$rssi = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.2.0", "-Ovqn", "");
|
||||
if (is_numeric($rssi)) {
|
||||
$rrd_def = 'DS:rssi:GAUGE:600:0:5000';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('rssi', 'GAUGE', 0, 5000);
|
||||
$fields = array(
|
||||
'rssi' => $rssi,
|
||||
);
|
||||
@@ -72,7 +72,7 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
|
||||
$jitter = snmp_get($device, "jitter.0", "-Ovqn", "WHISP-SM-MIB");
|
||||
if (is_numeric($jitter)) {
|
||||
$rrd_def = 'DS:jitter:GAUGE:600:0:20';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('jitter', 'GAUGE', 0, 20);
|
||||
$fields = array(
|
||||
'jitter' => $jitter,
|
||||
);
|
||||
@@ -85,10 +85,9 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
$horizontal = str_replace('"', "", snmp_get($device, "radioDbmHorizontal.0", "-Ovqn", "WHISP-SM-MIB"));
|
||||
$vertical = str_replace('"', "", snmp_get($device, "radioDbmVertical.0", "-Ovqn", "WHISP-SM-MIB"));
|
||||
if (is_numeric($horizontal) && is_numeric($vertical)) {
|
||||
$rrd_def = array(
|
||||
'DS:horizontal:GAUGE:600:-100:100',
|
||||
'DS:vertical:GAUGE:600:-100:100'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('horizontal', 'GAUGE', -100, 100)
|
||||
->addDataset('vertical', 'GAUGE', -100, 100);
|
||||
|
||||
$fields = array(
|
||||
'horizontal' => $horizontal,
|
||||
@@ -102,7 +101,7 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
|
||||
$ssr = str_replace('"', "", snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "WHISP-SM-MIB"));
|
||||
if (is_numeric($ssr)) {
|
||||
$rrd_def = 'DS:ssr:GAUGE:600:-150:150';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150);
|
||||
$fields = array(
|
||||
'ssr' => $ssr,
|
||||
);
|
||||
@@ -115,10 +114,9 @@ if (strstr($hardware, 'CMM') == false) {
|
||||
$horizontal = str_replace('"', "", snmp_get($device, "signalToNoiseRatioSMHorizontal.0", "-Ovqn", "WHISP-SM-MIB"));
|
||||
$vertical = str_replace('"', "", snmp_get($device, "signalToNoiseRatioSMVertical.0", "-Ovqn", "WHISP-SM-MIB"));
|
||||
if (is_numeric($horizontal) && is_numeric($vertical)) {
|
||||
$rrd_def = array(
|
||||
'DS:horizontal:GAUGE:600:0:100',
|
||||
'DS:vertical:GAUGE:600:0:100'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('horizontal', 'GAUGE', 0, 100)
|
||||
->addDataset('vertical', 'GAUGE', 0, 100);
|
||||
$fields = array(
|
||||
'horizontal' => $horizontal,
|
||||
'vertical' => $vertical,
|
||||
@@ -140,7 +138,7 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware,
|
||||
$gpsStatus = 1;
|
||||
}
|
||||
if (is_numeric($gpsStatus)) {
|
||||
$rrd_def = 'DS:whispGPSStats:GAUGE:600:0:4';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('whispGPSStats', 'GAUGE', 0, 4);
|
||||
$fields = array(
|
||||
'whispGPSStats' => $gpsStatus,
|
||||
);
|
||||
@@ -153,10 +151,9 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware,
|
||||
$visible = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.7.0", "-Ovqn", ""));
|
||||
$tracked = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.8.0", "-Ovqn", ""));
|
||||
if (is_numeric($visible) && is_numeric($tracked)) {
|
||||
$rrd_def = array(
|
||||
'DS:visible:GAUGE:600:0:1000',
|
||||
'DS:tracked:GAUGE:600:0:1000'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('visible', 'GAUGE', 0, 1000)
|
||||
->addDataset('tracked', 'GAUGE', 0, 1000);
|
||||
$fields = array(
|
||||
'visible' => floatval($visible),
|
||||
'tracked' => floatval($tracked),
|
||||
@@ -172,10 +169,9 @@ if (strstr($version, 'AP') == false) {
|
||||
$horizontal = str_replace('"', "", snmp_get($device, "linkRadioDbmHorizontal.2", "-Ovqn", "WHISP-APS-MIB"));
|
||||
$vertical = str_replace('"', "", snmp_get($device, "linkRadioDbmVertical.2", "-Ovqn", "WHISP-APS-MIB"));
|
||||
if (is_numeric($horizontal) && is_numeric($vertical)) {
|
||||
$rrd_def = array(
|
||||
'DS:horizontal:GAUGE:600:-100:0',
|
||||
'DS:vertical:GAUGE:600:-100:0'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('horizontal', 'GAUGE', -100, 0)
|
||||
->addDataset('vertical', 'GAUGE', -100, 0);
|
||||
$fields = array(
|
||||
'horizontal' => $horizontal,
|
||||
'vertical' => $vertical,
|
||||
@@ -188,7 +184,7 @@ if (strstr($version, 'AP') == false) {
|
||||
|
||||
$lastLevel = str_replace('"', "", snmp_get($device, "lastPowerLevel.2", "-Ovqn", "WHISP-APS-MIB"));
|
||||
if (is_numeric($lastLevel)) {
|
||||
$rrd_def = 'DS:last:GAUGE:600:-100:0';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('last', 'GAUGE', -100, 0);
|
||||
$fields = array(
|
||||
'last' => $lastLevel,
|
||||
);
|
||||
@@ -201,10 +197,9 @@ if (strstr($version, 'AP') == false) {
|
||||
$horizontal = str_replace('"', "", snmp_get($device, "signalToNoiseRatioHorizontal.2", "-Ovqn", "WHISP-APS-MIB"));
|
||||
$vertical = str_replace('"', "", snmp_get($device, "signalToNoiseRatioVertical.2", "-Ovqn", "WHISP-APS-MIB"));
|
||||
if (is_numeric($horizontal) && is_numeric($vertical)) {
|
||||
$rrd_def = array(
|
||||
'DS:horizontal:GAUGE:600:0:100',
|
||||
'DS:vertical:GAUGE:600:0:100'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('horizontal', 'GAUGE', 0, 100)
|
||||
->addDataset('vertical', 'GAUGE', 0, 100);
|
||||
$fields = array(
|
||||
'horizontal' => $horizontal,
|
||||
'vertical' => $vertical,
|
||||
@@ -217,7 +212,7 @@ if (strstr($version, 'AP') == false) {
|
||||
|
||||
$ssr = str_replace('"', "", snmp_get($device, "linkSignalStrengthRatio.2", "-Ovqn", "WHISP-APS-MIB"));
|
||||
if (is_numeric($ssr)) {
|
||||
$rrd_def = 'DS:ssr:GAUGE:600:-150:150';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150);
|
||||
$fields = array(
|
||||
'ssr' => $ssr,
|
||||
);
|
||||
@@ -234,12 +229,11 @@ if (strstr($version, 'AP') == false) {
|
||||
$avgRadio = str_replace('"', "", snmp_get($device, "radioDbmAvg.0", "-Ovqn", "WHISP-SM-MIB"));
|
||||
|
||||
if (is_numeric($dbmRadio) && is_numeric($minRadio) && is_numeric($maxRadio) && is_numeric($avgRadio)) {
|
||||
$rrd_def = array(
|
||||
'DS:dbm:GAUGE:600:-100:0',
|
||||
'DS:min:GAUGE:600:-100:0',
|
||||
'DS:max:GAUGE:600:-100:0',
|
||||
'DS:avg:GAUGE:600:-100:0'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('dbm', 'GAUGE', -100, 0)
|
||||
->addDataset('min', 'GAUGE', -100, 0)
|
||||
->addDataset('max', 'GAUGE', -100, 0)
|
||||
->addDataset('avg', 'GAUGE', -100, 0);
|
||||
|
||||
$fields = array(
|
||||
'dbm' => $dbmRadio,
|
||||
@@ -266,10 +260,9 @@ if (strstr($version, 'AP')) {
|
||||
$uplinkutilization = $multi_get_array[0]["WHISP-APS-MIB::frUtlLowTotalUplinkUtilization"];
|
||||
|
||||
if (is_numeric($registered) && is_numeric($failed)) {
|
||||
$rrd_def = array(
|
||||
'DS:regCount:GAUGE:600:0:15000',
|
||||
'DS:failed:GAUGE:600:0:15000'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('regCount', 'GAUGE', 0, 15000)
|
||||
->addDataset('failed', 'GAUGE', 0, 15000);
|
||||
$fields = array(
|
||||
'regCount' => $registered,
|
||||
'failed' => $failed,
|
||||
@@ -281,7 +274,7 @@ if (strstr($version, 'AP')) {
|
||||
}
|
||||
|
||||
if (is_numeric($freq)) {
|
||||
$rrd_def = 'DS:freq:GAUGE:600:0:100000';
|
||||
$rrd_def = RrdDefinition::make()->addDataset('freq', 'GAUGE', 0, 100000);
|
||||
if ($freq > 99999) {
|
||||
$freq = $freq / 100000;
|
||||
} else {
|
||||
@@ -297,10 +290,9 @@ if (strstr($version, 'AP')) {
|
||||
}
|
||||
|
||||
if (is_numeric($downlinkutilization) && is_numeric($uplinkutilization)) {
|
||||
$rrd_def = array(
|
||||
'DS:downlinkutilization:GAUGE:600:0:15000',
|
||||
'DS:uplinkutilization:GAUGE:600:0:15000'
|
||||
);
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('downlinkutilization', 'GAUGE', 0, 15000)
|
||||
->addDataset('uplinkutilization', 'GAUGE', 0, 15000);
|
||||
$fields = array(
|
||||
'downlinkutilization' => $downlinkutilization,
|
||||
'uplinkutilization' => $uplinkutilization,
|
||||
|
Reference in New Issue
Block a user