*/ namespace LibreNMS\OS; use App\Models\Device; use LibreNMS\Device\Processor; use LibreNMS\Interfaces\Discovery\ProcessorDiscovery; use LibreNMS\Interfaces\Polling\ProcessorPolling; use LibreNMS\OS; class Viptela extends OS implements ProcessorDiscovery, ProcessorPolling { private string $procOid = '.1.3.6.1.4.1.41916.11.1.16.0'; public function discoverOS(Device $device): void { parent::discoverOS($device); // yaml $device->hardware = $this->getHardware($device->hardware); } private function getHardware($id) { $hardware = [ '1' => 'Viptela vSmart Controller', '2' => 'Viptela vManage NMS', '3' => 'Viptela vBond Orchestrator', '4' => 'Viptela vEdge-1000', '5' => 'Viptela vEdge-2000', '6' => 'Viptela vEdge-100', '7' => 'Viptela vEdge-100-W2', '8' => 'Viptela vEdge-100-WM', '9' => 'Viptela vEdge-100-M2', '10' => 'Viptela vEdge-100-M', '11' => 'Viptela vEdge-100-B', '12' => 'Viptela vEdge Cloud', '13' => 'Viptela vContainer', '14' => 'Viptela vEdge-5000', ]; return $hardware[(string) $id] ?? $id; } /** * Discover processors. * Returns an array of LibreNMS\Device\Processor objects that have been discovered * * @return array Processor */ public function discoverProcessors() { $idle_cpu = 100 - \SnmpQuery::get([$this->procOid])->value(); $processors[] = Processor::discover( 'viptela', $this->getDeviceId(), $this->procOid, 0, 'Processor', 1, $idle_cpu, ); return $processors; } /** * 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) { $data = []; foreach ($processors as $processor) { $data[$processor['processor_id']] = 100 - \SnmpQuery::get([$this->procOid])->value(); } return $data; } }