-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
255 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace SwitcherCore\Modules\DellSwitch; | ||
|
||
use SnmpWrapper\Oid; | ||
use SwitcherCore\Modules\AbstractModule; | ||
use SwitcherCore\Modules\Helper; | ||
|
||
class ArpInfo extends AbstractModule | ||
{ | ||
use InterfacesTrait; | ||
|
||
public function run($params = []) | ||
{ | ||
$oid = $this->oids->getOidByName('ip.arp.macAddr')->getOid(); | ||
|
||
$this->response = $this->formatResponse($this->snmp->walk([Oid::init($oid)])); | ||
return $this; | ||
} | ||
|
||
public function getPretty() | ||
{ | ||
if ($this->response['ip.arp.macAddr']->error()) { | ||
throw new \SNMPException($this->response['ip.arp.macAddr']->error()); | ||
} | ||
$vlanIds = $this->getVlanIdsMap(); | ||
$response = []; | ||
foreach ($this->response['ip.arp.macAddr']->fetchAll() as $mac) { | ||
$ip = Helper::getIndexByOid($mac->getOid(), 3) . "." . | ||
Helper::getIndexByOid($mac->getOid(), 2) . "." . | ||
Helper::getIndexByOid($mac->getOid(), 1) . "." . | ||
Helper::getIndexByOid($mac->getOid()) | ||
; | ||
$vlanIdIndex = Helper::getIndexByOid($mac->getOid(), 4); | ||
|
||
$response[] = [ | ||
'mac' => $mac->getHexValue(), | ||
'ip' => $ip, | ||
'vlan_id' => isset($vlanIds[$vlanIdIndex]) ? $vlanIds[$vlanIdIndex] : null, | ||
'interface' => null, | ||
]; | ||
} | ||
|
||
return $response; | ||
} | ||
|
||
public function getPrettyFiltered($filter = []) | ||
{ | ||
return $this->getPretty(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace SwitcherCore\Modules\DellSwitch; | ||
|
||
use SnmpWrapper\Oid; | ||
use SwitcherCore\Modules\AbstractModule; | ||
|
||
class BgpInfo extends AbstractModule | ||
{ | ||
public function run($params = []) | ||
{ | ||
$oid = [ | ||
$this->oids->getOidByName('bgp.version'), | ||
$this->oids->getOidByName('bgp.localAs'), | ||
$this->oids->getOidByName('bgp.identifier'), | ||
]; | ||
|
||
$this->response = $this->formatResponse($this->snmp->get($oid)); | ||
|
||
foreach ($this->response as $data) { | ||
if($data->error()) { | ||
throw new \SNMPException($data->error()); | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
public function getPretty() | ||
{ | ||
|
||
return [ | ||
'version' => trim($this->getResponseByName('bgp.version')->fetchOne()->getValue()), | ||
'local_as' => $this->getResponseByName('bgp.localAs')->fetchOne()->getValue(), | ||
'identifier' => $this->getResponseByName('bgp.identifier')->fetchOne()->getValue(), | ||
]; | ||
} | ||
|
||
public function getPrettyFiltered($filter = []) | ||
{ | ||
return $this->getPretty(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace SwitcherCore\Modules\DellSwitch; | ||
|
||
use SwitcherCore\Modules\AbstractModule; | ||
use SwitcherCore\Modules\Helper; | ||
|
||
class BgpPeers extends AbstractModule | ||
{ | ||
public function run($params = []) | ||
{ | ||
$oids = $this->oids->getOidsByRegex('^bgp\.peer\..*'); | ||
$this->response = $this->formatResponse($this->snmp->walk($oids)); | ||
|
||
foreach ($this->response as $data) { | ||
if($data->error()) { | ||
throw new \SNMPException($data->error()); | ||
} | ||
} | ||
return $this; | ||
} | ||
|
||
public function getPretty() | ||
{ | ||
$bgpPeers = []; | ||
foreach ($this->response as $key => $data) { | ||
$name = str_replace("bgp.peer.", "", $key); | ||
foreach ($data->fetchAll() as $d) { | ||
$idx = | ||
Helper::getIndexByOid($d->getOid(), 3) . "." . | ||
Helper::getIndexByOid($d->getOid(), 2) . "." . | ||
Helper::getIndexByOid($d->getOid(), 1) . "." . | ||
Helper::getIndexByOid($d->getOid()) ; | ||
$bgpPeers[$idx][$name] = $d->getParsedValue(); | ||
} | ||
} | ||
return array_values($bgpPeers); | ||
} | ||
|
||
public function getPrettyFiltered($filter = []) | ||
{ | ||
return $this->getPretty(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.