mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Hytera repeater support (#4163)
This commit is contained in:
BIN
html/images/os/hytera.png
Normal file
BIN
html/images/os/hytera.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -1993,6 +1993,12 @@ $config['os'][$os]['over'][1]['text'] = 'CPU Usage';
|
||||
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
|
||||
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
|
||||
|
||||
// Hytera repeaters
|
||||
$os = "hytera";
|
||||
$config['os'][$os]['text'] = 'Hytera Repeater';
|
||||
$config['os'][$os]['type'] = 'wireless';
|
||||
$config['os'][$os]['icon'] = 'hytera';
|
||||
|
||||
// Graph Types
|
||||
require_once $config['install_dir'].'/includes/load_db_graph_types.inc.php';
|
||||
|
||||
|
||||
8
includes/discovery/os/hytera.inc.php
Normal file
8
includes/discovery/os/hytera.inc.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (!$os) {
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.40297.1.2.1.1.1')) {
|
||||
$os = "hytera";
|
||||
}
|
||||
}
|
||||
|
||||
26
includes/discovery/sensors/temperatures/hytera.inc.php
Normal file
26
includes/discovery/sensors/temperatures/hytera.inc.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "hytera") {
|
||||
$oids = snmp_walk($device, "rptPaTemprature", "-OsqnU","HYTERA-REPEATER-MIB");
|
||||
d_echo($oids);
|
||||
if ($oids !== false) {
|
||||
echo("HYTERA-REPEATER-MIB ");
|
||||
}
|
||||
$divisor = 1;
|
||||
$type = "hytera";
|
||||
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "PA Temperature " . $index;
|
||||
$oid = ".1.3.6.1.4.1.40297.1.2.1.2.2." . $index;
|
||||
$temperature = hytera_h2f(str_replace("\"", "",snmp_get($device, $oid, "-Oqv")),2);
|
||||
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', 0, 0, 70, 75, $temperature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
includes/discovery/sensors/voltages/hytera.inc.php
Normal file
25
includes/discovery/sensors/voltages/hytera.inc.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "hytera") {
|
||||
$oids = snmp_walk($device, "rptVoltage", "-OsqnU","HYTERA-REPEATER-MIB");
|
||||
d_echo($oids);
|
||||
if ($oids !== false) {
|
||||
echo("HYTERA-REPEATER-MIB ");
|
||||
}
|
||||
$divisor = 1;
|
||||
$type = "hytera";
|
||||
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Voltage " . $index;
|
||||
$oid = ".1.3.6.1.4.1.40297.1.2.1.2.1." . $index;
|
||||
$voltage = hytera_h2f(str_replace("\"", "",snmp_get($device, $oid, "-OUqnv", "")),2);
|
||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', 11.00, 11.5, 14.5, 15, $voltage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,3 +1453,73 @@ function report_this($message) {
|
||||
return '<h2>'.$message.' Please <a href="'.$config['project_issues'].'">report this</a> to the '.$config['project_name'].' developers.</h2>';
|
||||
|
||||
}//end report_this()
|
||||
|
||||
function hytera_h2f($number,$nd)
|
||||
{
|
||||
if (strlen(str_replace(" ","",$number)) == 4) {
|
||||
$hex = '';
|
||||
for ($i = 0; $i < strlen($number); $i++) {
|
||||
$byte = strtoupper(dechex(ord($number{$i})));
|
||||
$byte = str_repeat('0', 2 - strlen($byte)).$byte;
|
||||
$hex.=$byte." ";
|
||||
}
|
||||
$number = $hex;
|
||||
unset($hex);
|
||||
}
|
||||
$r = '';
|
||||
$y = explode(' ', $number);
|
||||
foreach ($y as $z) {
|
||||
$r = $z . '' . $r;
|
||||
}
|
||||
|
||||
$hex = array();
|
||||
$number = substr($r, 0, -1);
|
||||
//$number = str_replace(" ", "", $number);
|
||||
for ($i=0; $i<strlen($number); $i++) {
|
||||
$hex[]=substr($number,$i,1);
|
||||
}
|
||||
|
||||
$dec = array();
|
||||
$hexCount = count($hex);
|
||||
for ($i=0; $i<$hexCount; $i++) {
|
||||
$dec[]=hexdec($hex[$i]);
|
||||
}
|
||||
|
||||
$binfinal = "";
|
||||
$decCount = count($dec);
|
||||
for ($i=0; $i<$decCount; $i++) {
|
||||
$binfinal.=sprintf("%04d",decbin($dec[$i]));
|
||||
}
|
||||
|
||||
$sign=substr($binfinal,0,1);
|
||||
$exp=substr($binfinal,1,8);
|
||||
$exp=bindec($exp);
|
||||
$exp-=127;
|
||||
$scibin=substr($binfinal,9);
|
||||
$binint=substr($scibin,0,$exp);
|
||||
$binpoint=substr($scibin,$exp);
|
||||
$intnumber=bindec("1".$binint);
|
||||
|
||||
$tmppoint = "";
|
||||
for ($i=0; $i<strlen($binpoint); $i++) {
|
||||
$tmppoint[]=substr($binpoint,$i,1);
|
||||
}
|
||||
|
||||
$tmppoint=array_reverse($tmppoint);
|
||||
$tpointnumber=number_format($tmppoint[0]/2,strlen($binpoint),'.','');
|
||||
|
||||
$pointnumber = "";
|
||||
for ($i=1; $i<strlen($binpoint); $i++) {
|
||||
$pointnumber=number_format($tpointnumber/2,strlen($binpoint),'.','');
|
||||
$tpointnumber=$tmppoint[$i+1].substr($pointnumber,1);
|
||||
}
|
||||
|
||||
$floatfinal=$intnumber+$pointnumber;
|
||||
|
||||
if ($sign==1) {
|
||||
$floatfinal=-$floatfinal;
|
||||
}
|
||||
|
||||
return number_format($floatfinal,$nd,'.','');
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ function poll_sensor($device, $class, $unit) {
|
||||
if ($class == 'temperature') {
|
||||
if ($device['os'] == 'netapp') {
|
||||
include 'includes/polling/temperatures/netapp.inc.php';
|
||||
}
|
||||
else if ($device['os'] == 'canopy') {
|
||||
} elseif ($device['os'] == 'canopy') {
|
||||
include 'includes/polling/temperatures/canopy.inc.php';
|
||||
}
|
||||
else {
|
||||
} elseif ($device['os'] == 'hytera') {
|
||||
require_once 'includes/polling/temperatures/hytera.inc.php';
|
||||
} else {
|
||||
// Try 5 times to get a valid temp reading
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
d_echo("Attempt $i ");
|
||||
@@ -49,8 +49,9 @@ function poll_sensor($device, $class, $unit) {
|
||||
// end if
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
else if ($class == 'state') {
|
||||
} elseif ($class == "voltage" && $device['os'] == 'hytera') {
|
||||
require_once "includes/polling/voltages/hytera.inc.php";
|
||||
} elseif ($class == 'state') {
|
||||
$sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB', $mibdir)));
|
||||
if (!is_numeric($sensor_value)) {
|
||||
$state_value = dbFetchCell('SELECT `state_value` FROM `state_translations` LEFT JOIN `sensors_to_state_indexes` ON `state_translations`.`state_index_id` = `sensors_to_state_indexes`.`state_index_id` WHERE `sensors_to_state_indexes`.`sensor_id` = ? AND `state_translations`.`state_descr` LIKE ?', array($sensor['sensor_id'], $sensor_value));
|
||||
|
||||
3
includes/polling/temperatures/hytera.inc.php
Normal file
3
includes/polling/temperatures/hytera.inc.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$sensor_value = hytera_h2f(str_replace("\"", "",snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "")),2);
|
||||
4
includes/polling/voltages/hytera.inc.php
Normal file
4
includes/polling/voltages/hytera.inc.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
|
||||
$sensor_value = hytera_h2f(str_replace("\"", "",snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "")),2);
|
||||
1885
mibs/HYTERA-REPEATER-MIB
Normal file
1885
mibs/HYTERA-REPEATER-MIB
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user