Files

114 lines
3.9 KiB
PHP
Raw Permalink Normal View History

2018-02-05 07:39:13 -06:00
<?php
/**
* Powerconnect.php
*
* Dell PowerConnect
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\OS;
2020-04-17 17:37:56 -05:00
use Illuminate\Support\Str;
2018-02-05 07:39:13 -06:00
use LibreNMS\Device\Processor;
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\Interfaces\Polling\ProcessorPolling;
use LibreNMS\OS;
use LibreNMS\OS\Traits\VxworksProcessorUsage;
class Powerconnect extends OS implements ProcessorDiscovery, ProcessorPolling
{
// pull in VxWorks processor parsing, but allow us to extend it
use VxworksProcessorUsage {
VxworksProcessorUsage::discoverProcessors as discoverVxworksProcessors;
VxworksProcessorUsage::pollProcessors as pollVxworksProcessors;
}
/**
* 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
$device = $this->getDeviceArray();
2020-04-17 17:37:56 -05:00
if (Str::startsWith($device['sysObjectID'], [
'.1.3.6.1.4.1.674.10895.3020',
'.1.3.6.1.4.1.674.10895.3021',
'.1.3.6.1.4.1.674.10895.3030',
'.1.3.6.1.4.1.674.10895.3031',
])) {
2020-09-21 15:59:34 +02:00
d_echo('Dell Powerconnect 55xx');
2020-09-21 14:54:51 +02:00
return [
2018-02-05 07:39:13 -06:00
Processor::discover(
'powerconnect-nv',
$this->getDeviceId(),
'.1.3.6.1.4.1.89.1.7.0',
0
2020-09-21 14:54:51 +02:00
),
];
2020-04-17 17:37:56 -05:00
} elseif (Str::startsWith($device['sysObjectID'], [
'.1.3.6.1.4.1.674.10895.3024',
'.1.3.6.1.4.1.674.10895.3042',
'.1.3.6.1.4.1.674.10895.3053',
'.1.3.6.1.4.1.674.10895.3054',
'.1.3.6.1.4.1.674.10895.3056',
'.1.3.6.1.4.1.674.10895.3058',
'.1.3.6.1.4.1.674.10895.3065',
'.1.3.6.1.4.1.674.10895.3046',
'.1.3.6.1.4.1.674.10895.3063',
'.1.3.6.1.4.1.674.10895.3064',
'.1.3.6.1.4.1.674.10895.3065',
'.1.3.6.1.4.1.674.10895.3066',
'.1.3.6.1.4.1.674.10895.3078',
'.1.3.6.1.4.1.674.10895.3079',
'.1.3.6.1.4.1.674.10895.3080',
'.1.3.6.1.4.1.674.10895.3081',
'.1.3.6.1.4.1.674.10895.3082',
'.1.3.6.1.4.1.674.10895.3083',
])) {
2018-02-05 07:39:13 -06:00
return $this->discoverVxworksProcessors('.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0');
}
2020-09-21 14:54:51 +02:00
2018-02-05 07:39:13 -06:00
return $this->discoverVxworksProcessors('.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.4.0');
}
/**
* Poll processor data. This can be implemented if custom polling is needed.
*
* @param array $processors Array of processor entries from the database that need to be polled
* @return array of polled data
*/
public function pollProcessors(array $processors)
{
2020-09-21 14:54:51 +02:00
$data = [];
2018-02-05 07:39:13 -06:00
foreach ($processors as $processor) {
if ($processor['processor_type'] == 'powerconnect-nv') {
2020-09-18 08:12:07 -05:00
$data[$processor['processor_id']] = snmp_get($this->getDeviceArray(), $processor['processor_oid'], '-Oqv');
2018-02-05 07:39:13 -06:00
} else {
2020-09-21 14:54:51 +02:00
$data += $this->pollVxworksProcessors([$processor]);
2018-02-05 07:39:13 -06:00
}
}
return $data;
}
}