From Eratic Eider, 5 Years ago, written in Plain Text.
Embed
  1. namespace LibreNMS\OS;
  2.  
  3. use LibreNMS\Device\Processor;
  4. use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
  5. use LibreNMS\OS;
  6.  
  7. class Smartax extends OS implements ProcessorDiscovery
  8. {
  9.     /**
  10.      * Discover processors.
  11.      * Returns an array of LibreNMS\Device\Processor objects that have been discovered
  12.      *
  13.      * @return array Processors
  14.      */
  15.     public function discoverProcessors()
  16.     {
  17.         $data = snmpwalk_group($this->getDevice(), '1.3.6.1.4.1.2011.2.6.7.1.1.2.1.5.0');
  18.         //$proc_descr = snmpwalk_group($this->getDevice(), '1.3.6.1.4.1.2011.2.6.7.1.1.2.1.7.0');
  19.  
  20.         $processors = array();
  21.         $count = 1;
  22.         foreach ($data as $index => $entry) {
  23.             if ($entry != -1) {
  24.                 $processors[] = Processor::discover(
  25.                     "smartax",
  26.                     $this->getDeviceId(),
  27.                     "$index",
  28.                     zeropad($count),
  29.                     "Unit $count processor",
  30.                     1,
  31.                     $entry
  32.                 );
  33.             }
  34.  
  35.             $count++;
  36.         }
  37.  
  38.  
  39.         return $processors;
  40.     }
  41. }