2019-02-11 00:31:25 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Fs-switch.php
|
|
|
|
*
|
|
|
|
* -Description-
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-02-09 00:29:04 +01:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-02-11 00:31:25 +01:00
|
|
|
*
|
2021-02-09 00:29:04 +01:00
|
|
|
* @link https://www.librenms.org
|
2021-09-10 20:09:53 +02:00
|
|
|
*
|
2019-02-11 00:31:25 +01:00
|
|
|
* @copyright 2019 PipoCanaja
|
|
|
|
* @author PipoCanaja <pipocanaja@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace LibreNMS\OS;
|
|
|
|
|
|
|
|
use LibreNMS\Device\Processor;
|
|
|
|
use LibreNMS\OS;
|
|
|
|
|
2024-09-29 11:05:44 -05:00
|
|
|
class FsSwitch extends OS
|
2019-02-11 00:31:25 +01:00
|
|
|
{
|
2024-07-19 19:39:39 +02:00
|
|
|
public static function normalizeTransceiverValues($value): float
|
|
|
|
{
|
|
|
|
// Convert fixed-point integer thresholds to float
|
|
|
|
$type = gettype($value);
|
|
|
|
if ($type === 'integer') {
|
|
|
|
// Thresholds are integers
|
|
|
|
$value /= 100.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function normalizeTransceiverValuesCurrent($value): float
|
|
|
|
{
|
|
|
|
$value = FsSwitch::normalizeTransceiverValues($value);
|
|
|
|
$value *= 0.001; // mA to A
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
2019-02-11 00:31:25 +01:00
|
|
|
/**
|
|
|
|
* Discover processors.
|
|
|
|
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
|
|
|
|
*
|
|
|
|
* @return array Processors
|
|
|
|
*/
|
|
|
|
public function discoverProcessors()
|
|
|
|
{
|
|
|
|
$processors = [];
|
|
|
|
|
|
|
|
// Tests OID from SWITCH MIB.
|
2020-09-18 08:12:07 -05:00
|
|
|
$processors_data = snmpwalk_cache_oid($this->getDeviceArray(), 'ssCpuIdle', [], 'SWITCH', 'fs');
|
2019-02-11 00:31:25 +01:00
|
|
|
|
|
|
|
foreach ($processors_data as $index => $entry) {
|
|
|
|
$processors[] = Processor::discover(
|
|
|
|
'fs-SWITCHMIB',
|
|
|
|
$this->getDeviceId(),
|
|
|
|
'.1.3.6.1.4.1.27975.1.2.11.' . $index,
|
|
|
|
$index,
|
|
|
|
'CPU',
|
|
|
|
-1,
|
|
|
|
100 - $entry['ssCpuIdle']
|
|
|
|
);
|
|
|
|
}
|
2020-09-21 14:54:51 +02:00
|
|
|
|
2019-02-11 00:31:25 +01:00
|
|
|
return $processors;
|
|
|
|
}
|
|
|
|
}
|