Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

97 lines
3.2 KiB
PHP
Raw Permalink Normal View History

2018-02-05 07:39:13 -06:00
<?php
/**
* Boss.php
2018-02-05 07:39:13 -06:00
*
* -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/>.
2018-02-05 07:39:13 -06:00
*
2021-02-09 00:29:04 +01:00
* @link https://www.librenms.org
2021-09-10 20:09:53 +02:00
*
2018-02-05 07:39:13 -06:00
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\OS;
2020-09-18 08:12:07 -05:00
use App\Models\Device;
2018-02-05 07:39:13 -06:00
use LibreNMS\Device\Processor;
2020-09-18 08:12:07 -05:00
use LibreNMS\Interfaces\Discovery\OSDiscovery;
2018-02-05 07:39:13 -06:00
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\OS;
2020-09-18 08:12:07 -05:00
class Boss extends OS implements OSDiscovery, ProcessorDiscovery
2018-02-05 07:39:13 -06:00
{
2020-09-18 08:12:07 -05:00
public function discoverOS(Device $device): void
{
// Try multiple ways of getting firmware version
$version = null;
preg_match('/SW:v?([^ ]+) /', $device->sysDescr, $version_matches);
$version = $version_matches[1] ?? null;
if (empty($version)) {
2021-11-14 14:58:13 -06:00
$version = explode(' on', snmp_get($this->getDeviceArray(), '.1.3.6.1.4.1.2272.1.1.7.0', '-Oqvn'))[0] ?: null;
2020-09-18 08:12:07 -05:00
}
if (empty($version)) {
2021-11-14 14:58:13 -06:00
$version = snmp_get($this->getDeviceArray(), '.1.3.6.1.4.1.45.1.6.4.2.1.10.0', '-Oqvn') ?: null;
2020-09-18 08:12:07 -05:00
}
$device->version = $version;
// Get hardware details, expand ERS to normalize
$details = str_replace('ERS', 'Ethernet Routing Switch', $device->sysDescr);
// Make boss devices hardware string compact
$details = str_replace('Ethernet Routing Switch ', 'ERS-', $details);
$details = str_replace('Virtual Services Platform ', 'VSP-', $details);
2021-11-14 14:58:13 -06:00
$device->hardware = explode(' ', $details, 2)[0] ?: null;
2020-09-18 08:12:07 -05:00
// Is this a 5500 series or 5600 series stack?
$stack = snmp_walk($this->getDeviceArray(), '.1.3.6.1.4.1.45.1.6.3.3.1.1.6.8', '-OsqnU');
$stack = explode("\n", $stack);
$stack_size = count($stack);
if ($stack_size > 1) {
$device->features = "Stack of $stack_size units";
}
}
2018-02-05 07:39:13 -06:00
/**
* Discover processors.
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
*
* @return array Processors
*/
public function discoverProcessors()
{
2020-09-18 08:12:07 -05:00
$data = snmpwalk_group($this->getDeviceArray(), 's5ChasUtilCPUUsageLast10Minutes', 'S5-CHASSIS-MIB');
2018-02-05 07:39:13 -06:00
2020-09-18 08:12:07 -05:00
$processors = [];
2018-02-05 07:39:13 -06:00
$count = 1;
foreach ($data as $index => $entry) {
$processors[] = Processor::discover(
'avaya-ers',
2018-02-05 07:39:13 -06:00
$this->getDeviceId(),
".1.3.6.1.4.1.45.1.6.3.8.1.1.6.$index",
zeropad($count),
"Unit $count processor",
1,
2022-10-19 00:34:19 +02:00
$entry['sgProxyCpuCoreBusyPerCent'] ?? null
2018-02-05 07:39:13 -06:00
);
$count++;
}
return $processors;
}
}