Beispiel #1
0
 /**
  * poller routeDest
  *
  * @return Array
  */
 public function poll_routeDest()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk ipRouteIfIndex
     $walk_ipRouteIfIndex = $snmp->walk(OID_ipRouteIfIndex);
     if (count($walk_ipRouteIfIndex) == 0) {
         // not found route
         return $_ret;
     }
     //
     $walk_ipRouteNextHop = $snmp->walk(OID_ipRouteNextHop);
     $walk_ipRouteType = $snmp->walk(OID_ipRouteType);
     $walk_ipRouteProto = $snmp->walk(OID_ipRouteProto);
     $walk_ipRouteMask = $snmp->walk(OID_ipRouteMask);
     // oid.routeDest = ifIndex
     foreach ($walk_ipRouteIfIndex as $key1 => $ifIndex) {
         $routeDest = str_replace(OID_ipRouteIfIndex . '.', '', $key1);
         $routeNextHop = $walk_ipRouteNextHop[OID_ipRouteNextHop . '.' . $routeDest];
         $routeType = $walk_ipRouteType[OID_ipRouteType . '.' . $routeDest];
         $routeProto = $walk_ipRouteProto[OID_ipRouteProto . '.' . $routeDest];
         $netmask = explode('.', $walk_ipRouteMask[OID_ipRouteMask . '.' . $routeDest]);
         $routeMasks = substr_count(decbin($netmask[0]), 1) + substr_count(decbin($netmask[1]), 1) + substr_count(decbin($netmask[2]), 1) + substr_count(decbin($netmask[3]), 1);
         $port = \App\Port::where('node_id', $this->node->id)->where('ifIndex', $ifIndex)->first();
         if ($port) {
             // found port
             $_ret[] = ['table' => 'routes', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'port_id' => $port->id, 'routeDest' => $routeDest, 'routeMasks' => $routeMasks], 'data' => ['routeNextHop' => $routeNextHop, 'routeType' => $routeType, 'routeProto' => $routeProto]];
         }
     }
     return $_ret;
 }
Beispiel #2
0
 /**
  * poller ipAddress
  *
  * @return Array
  */
 public function poll_ipAddress()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk OID_ipAdEntIfIndex
     $walk_ipAdEntIfIndex = $snmp->walk(OID_ipAdEntIfIndex);
     if (count($walk_ipAdEntIfIndex) == 0 || $walk_ipAdEntIfIndex === false) {
         // not found ipAddress
         return $_ret;
     }
     // walk netmask
     $walk_ipAdEntNetMask = $snmp->walk(OID_ipAdEntNetMask);
     // oid.ipAddress(4) = ifIndex
     foreach ($walk_ipAdEntIfIndex as $key1 => $ifIndex) {
         $ipAddress = str_replace(OID_ipAdEntIfIndex . '.', '', $key1);
         $netmask = explode('.', $walk_ipAdEntNetMask[OID_ipAdEntNetMask . '.' . $ipAddress]);
         if (count($netmask) == 4) {
             $masks = substr_count(decbin($netmask[0]), 1) + substr_count(decbin($netmask[1]), 1) + substr_count(decbin($netmask[2]), 1) + substr_count(decbin($netmask[3]), 1);
         } else {
             $masks = 0;
         }
         $port = \App\Port::where('node_id', $this->node->id)->where('ifIndex', $ifIndex)->first();
         if ($port) {
             // found port and vlan
             $_ret[] = ['table' => 'ips', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'port_id' => $port->id], 'data' => ['ipAddress' => $ipAddress, 'masks' => $masks]];
         }
     }
     return $_ret;
 }
Beispiel #3
0
 /**
  * poller macAddress
  *
  * @return Array
  */
 public function poll_macAddress()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk OID_dot1qTpFdbPort
     $walk_dot1qTpFdbPort = $snmp->walk(OID_dot1qTpFdbPort);
     if (count($walk_dot1qTpFdbPort) == 0) {
         // not found macAddress
         return $_ret;
     }
     // dot1qTpFdbPort.vlanIndex.macDec = portIndex
     foreach ($walk_dot1qTpFdbPort as $key1 => $portIndex) {
         $tmp1 = explode('.', str_replace(OID_dot1qTpFdbPort . '.', '', $key1));
         $vlanIndex = $tmp1[0];
         $macAddress = sprintf("%02s", dechex($tmp1[1])) . ':' . sprintf("%02s", dechex($tmp1[2])) . ':' . sprintf("%02s", dechex($tmp1[3])) . ':' . sprintf("%02s", dechex($tmp1[4])) . ':' . sprintf("%02s", dechex($tmp1[5])) . ':' . sprintf("%02s", dechex($tmp1[6]));
         //print "$vlanIndex $macAddress = $portIndex<br>";
         $port = \App\Port::where('node_id', $this->node->id)->where('portIndex', $portIndex)->first();
         $vlan = \App\Vlan::where('node_id', $this->node->id)->where('vlanIndex', $vlanIndex)->first();
         if ($port && $vlan) {
             // found port and vlan
             $_ret[] = ['table' => 'macs', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'port_id' => $port->id, 'vlan_id' => $vlan->id], 'data' => ['macAddress' => $macAddress]];
         }
     }
     return $_ret;
 }
Beispiel #4
0
 /**
  * Override the parent
  *
  * @return Array
  */
 public function poll_macAddress()
 {
     $_ret_from_parent = parent::poll_macAddress();
     if (count($_ret_from_parent) > 0) {
         return $_ret_from_parent;
     }
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk OID_dot1dTpFdbPort
     $walk_dot1dTpFdbPort = $snmp->walk(OID_dot1dTpFdbPort);
     if (count($walk_dot1dTpFdbPort) == 0) {
         // not found macAddress
         return $_ret;
     }
     // oid.macDec(6) = portIndex
     //  - portIndex = 0  // management port
     //  - no vlanIndex in this mib, so assume VLAN 1
     foreach ($walk_dot1dTpFdbPort as $key1 => $portIndex) {
         $tmp1 = explode('.', str_replace(OID_dot1dTpFdbPort . '.', '', $key1));
         $macAddress = sprintf("%02s", dechex($tmp1[0])) . ':' . sprintf("%02s", dechex($tmp1[1])) . ':' . sprintf("%02s", dechex($tmp1[2])) . ':' . sprintf("%02s", dechex($tmp1[3])) . ':' . sprintf("%02s", dechex($tmp1[4])) . ':' . sprintf("%02s", dechex($tmp1[5]));
         $port = \App\Port::where('node_id', $this->node->id)->where('portIndex', $portIndex)->first();
         $vlan = \App\Vlan::where('node_id', $this->node->id)->where('vlanIndex', 1)->first();
         if ($port && $vlan) {
             // found port and vlan
             $_ret[] = ['table' => 'macs', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'port_id' => $port->id, 'vlan_id' => $vlan->id], 'data' => ['macAddress' => $macAddress]];
         }
     }
     return $_ret;
 }
Beispiel #5
0
 /**
  * poller vlanName
  *
  * @return Array
  */
 public function poll_vlanName($vlanIndex = '')
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk vlanName
     //$walk_vlanName = $snmp->walk(OID_dot1qVlanStaticName);
     // walk vlanName
     $walk_vlanStatus = $snmp->walk(OID_dot1qVlanStatus);
     if (count($walk_vlanStatus) > 0) {
         // found vlans
         foreach ($walk_vlanStatus as $key1 => $value1) {
             $vlanIndex = str_replace(OID_dot1qVlanStatus . '.', '', $key1);
             if (preg_match('/\\./', $vlanIndex)) {
                 // if found 0.1, then convert to 1
                 $vlanIndex = preg_replace('/^[^\\.]+\\./', '', $vlanIndex);
             }
             $vlanName = $snmp->get([OID_dot1qVlanStaticName . '.' . $vlanIndex]);
             // some vlan does not have name defined
             if ($vlanName[OID_dot1qVlanStaticName . '.' . $vlanIndex] === false) {
                 $vlanName = $vlanIndex;
             } else {
                 $vlanName = $vlanName[OID_dot1qVlanStaticName . '.' . $vlanIndex];
             }
             $_ret[] = ['table' => 'vlans', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'vlanIndex' => $vlanIndex], 'data' => ['vlanName' => $vlanName]];
         }
     }
     return $_ret;
 }
Beispiel #6
0
 /**
  * poller name
  *
  * @return Array
  */
 public function poll_portIndex($ifIndex = '')
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk portIndex
     $walk_portIndex = $snmp->walk(OID_dot1dBasePortIfIndex);
     if (count($walk_portIndex) > 0) {
         // found ports
         foreach ($walk_portIndex as $key1 => $value1) {
             $portIndex = str_replace(OID_dot1dBasePortIfIndex . '.', '', $key1);
             $ifIndex = $value1;
             $_ret[] = ['table' => 'ports', 'action' => 'update', 'key' => ['node_id' => $this->node->id, 'ifIndex' => $ifIndex], 'data' => ['portIndex' => $portIndex]];
         }
     }
     return $_ret;
 }
Beispiel #7
0
 /**
  * poller clientMacAddress
  *
  * @return Array
  */
 public function poll_clientMacAddress()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk coDot11StationMACAddress
     $walk_coDot11StationMACAddress = $snmp->walk(OID_Colubris_coDot11StationMACAddress);
     if (count($walk_coDot11StationMACAddress) == 0 || $walk_coDot11StationMACAddress === false) {
         // not found coDot11StationMACAddress
         return $_ret;
     }
     // oid.ifIndex.clientIndex
     foreach ($walk_coDot11StationMACAddress as $key1 => $clientMacHex) {
         $clientMacAddress = str_replace(' ', ':', $clientMacHex);
         $clientSuffix = str_replace(OID_Colubris_coDot11StationMACAddress . '.', '', $key1);
         $tmp1 = explode('.', $clientSuffix);
         $ifIndex = $tmp1[0];
         $clientIndex = $tmp1[1];
         // find port_id
         $port = \App\Port::where('node_id', $this->node->id)->where('ifIndex', $ifIndex)->first();
         if ($port) {
             // find bssid
             $bssid = \App\Bssid::where('node_id', $this->node->id)->where('port_id', $port->id)->first();
             //
             $clientDetails = $snmp->get([OID_Colubris_coDot11StationIPAddress . '.' . $clientSuffix, OID_Colubris_coDot11SignalLevel . '.' . $clientSuffix]);
             if (isset($clientDetails[OID_Colubris_coDot11StationIPAddress . '.' . $clientSuffix])) {
                 $clientIpAddress = $clientDetails[OID_Colubris_coDot11StationIPAddress . '.' . $clientSuffix];
             } else {
                 $clientIpAddress = null;
             }
             if (isset($clientDetails[OID_Colubris_coDot11SignalLevel . '.' . $clientSuffix])) {
                 $clientSignalStrength = $clientDetails[OID_Colubris_coDot11SignalLevel . '.' . $clientSuffix];
             } else {
                 $clientSignalStrength = null;
             }
             if ($bssid) {
                 // found bssid
                 $_ret[] = ['table' => 'bds', 'action' => 'insert', 'key' => ['node_id' => $this->node->id, 'bssid_id' => $bssid->id, 'clientMacAddress' => $clientMacAddress, 'timestamp' => \Carbon\Carbon::now()], 'data' => ['clientIpAddress' => $clientIpAddress, 'clientSignalStrength' => $clientSignalStrength, 'clientBytesReceived' => 0, 'clientBytesSent' => 0]];
             }
         }
     }
     return $_ret;
 }
Beispiel #8
0
 /**
  * poller name
  *
  * @return Array
  */
 public function poll_ifDescr($ifIndex = '')
 {
     // return
     $_ret = [];
     if ($ifIndex != '') {
         $poll_results = $this->poll_if('ifDescr', $ifIndex);
         return $poll_results;
     }
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk ifDescr
     $walk_ifDescr = $snmp->walk(OID_ifDescr);
     if ($walk_ifDescr !== false && count($walk_ifDescr) > 0) {
         // found ports
         foreach ($walk_ifDescr as $key1 => $value1) {
             $ifIndex = str_replace(OID_ifDescr . '.', '', $key1);
             $ifDescr = $value1;
             $_ret[] = ['table' => 'ports', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'ifIndex' => $ifIndex], 'data' => ['ifDescr' => $ifDescr]];
         }
     }
     return $_ret;
 }
Beispiel #9
0
 /**
  * poller arpAddress
  *
  * @return Array
  */
 public function poll_arpAddress()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk ipNetToMediaPhysAddress
     $walk_ipNetToMediaPhysAddress = $snmp->walk(OID_ipNetToMediaPhysAddress);
     if (count($walk_ipNetToMediaPhysAddress) == 0) {
         // not found arpAddress
         return $_ret;
     }
     // oid.ifIndex.ipAddress(4) = macAddress
     foreach ($walk_ipNetToMediaPhysAddress as $key1 => $macAddress) {
         $tmp1 = explode('.', str_replace(OID_ipNetToMediaPhysAddress . '.', '', $key1));
         $ifIndex = $tmp1[0];
         $ipAddress = $tmp1[1] . '.' . $tmp1[2] . '.' . $tmp1[3] . '.' . $tmp1[4];
         $port = \App\Port::where('node_id', $this->node->id)->where('ifIndex', $ifIndex)->first();
         if ($port) {
             // found port
             $_ret[] = ['table' => 'arps', 'action' => 'sync', 'key' => ['node_id' => $this->node->id, 'port_id' => $port->id, 'ipAddress' => $ipAddress], 'data' => ['macAddress' => $macAddress]];
         }
     }
     return $_ret;
 }
Beispiel #10
0
 /**
  * poller ap client
  *
  * @return Array
  */
 public function poll_apClient()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     $walk_nUserApBSSID = $snmp->walk(OID_Aruba_nUserApBSSID);
     if (count($walk_nUserApBSSID) == 0) {
         return $_ret;
     }
     // oid.clientMacDec(6).clientIpAddress(4) = bssidMacHex
     foreach ($walk_nUserApBSSID as $key1 => $bssidMacHex) {
         $bssidMacAddress = str_replace(' ', ':', trim($bssidMacHex));
         $clientSuffix = str_replace(OID_Aruba_nUserApBSSID . '.', '', $key1);
         $tmp1 = explode('.', $clientSuffix);
         $clientMacAddress = sprintf("%02s", dechex($tmp1[0])) . ':' . sprintf("%02s", dechex($tmp1[1])) . ':' . sprintf("%02s", dechex($tmp1[2])) . ':' . sprintf("%02s", dechex($tmp1[3])) . ':' . sprintf("%02s", dechex($tmp1[4])) . ':' . sprintf("%02s", dechex($tmp1[5]));
         $clientIpAddress = $tmp1[6] . '.' . $tmp1[7] . '.' . $tmp1[8] . '.' . $tmp1[9];
         // find bssid
         $bssid = \App\Bssid::where('bssidMacAddress', $bssidMacAddress)->first();
         $clientSignalStrength = 0;
         $clientBytesReceived = 0;
         $clientBytesSent = 0;
         // get more details about client
         $clientDetails = $snmp->get([OID_Aruba_staUserAgent . '.' . $clientSuffix, OID_Aruba_staUserType . '.' . $clientSuffix]);
         if (isset($clientDetails[OID_Aruba_staUserAgent . '.' . $clientSuffix])) {
             $clientUserAgent = $clientDetails[OID_Aruba_staUserAgent . '.' . $clientSuffix];
         } else {
             $clientUserAgent = '';
         }
         if (isset($clientDetails[OID_Aruba_staUserType . '.' . $clientSuffix])) {
             $clientUserType = $clientDetails[OID_Aruba_staUserType . '.' . $clientSuffix];
         } else {
             $clientUserType = '';
         }
         if ($bssid) {
             // found bssid
             $_ret[] = ['table' => 'bds', 'action' => 'insert', 'key' => ['node_id' => $bssid->node->id, 'bssid_id' => $bssid->id, 'clientMacAddress' => $clientMacAddress, 'timestamp' => \Carbon\Carbon::now()], 'data' => ['clientIpAddress' => $clientIpAddress, 'clientSignalStrength' => $clientSignalStrength, 'clientBytesReceived' => $clientBytesReceived, 'clientBytesSent' => $clientBytesSent, 'clientUserAgent' => $clientUserAgent, 'clientUserType' => $clientUserType]];
         }
     }
     return $_ret;
 }
Beispiel #11
0
 /**
  * poller clientMacAddress
  *
  * @return Array
  */
 public function poll_clientMacAddress()
 {
     // return
     $_ret = [];
     $snmp = new \App\Lnms\Snmp($this->node->ip_address, $this->node->snmp_comm_ro);
     // walk cDot11ClientIpAddress
     $walk_cDot11ClientIpAddress = $snmp->walk(OID_cDot11ClientIpAddress);
     if (count($walk_cDot11ClientIpAddress) == 0) {
         // not found cDot11ClientIpAddress
         return $_ret;
     }
     $walk1 = $snmp->walk(OID_cDot11ClientSignalStrength);
     // oid.?.??.bssidNameDec.clientMacAddressDec = clientIpAddressHex
     foreach ($walk_cDot11ClientIpAddress as $key1 => $clientIpAddressHex) {
         $clientSuffix = str_replace(OID_cDot11ClientIpAddress . '.', '', $key1);
         $tmp1 = explode('.', $clientSuffix);
         // find which bssidName each client connected
         // TODO : for now ignore the first 2-bytes
         // find bssidName
         $bssidName = '';
         for ($i = 2; $i < count($tmp1) - 6; $i++) {
             $bssidName .= chr($tmp1[$i]);
         }
         // find clientMacAddress
         $clientMacAddress = '';
         for ($i = count($tmp1) - 6; $i < count($tmp1); $i++) {
             $clientMacAddress .= sprintf("%02s", dechex($tmp1[$i])) . ':';
         }
         $clientMacAddress = trim($clientMacAddress, ':');
         // find clientIpAddress
         $tmp2 = explode(' ', trim($clientIpAddressHex));
         $clientIpAddress = '';
         for ($i = 0; $i < count($tmp2); $i++) {
             $clientIpAddress .= hexdec($tmp2[$i]) . '.';
         }
         $clientIpAddress = trim($clientIpAddress, '.');
         // get cDot11ClientStatisticEntry
         $walk_clientStatistics = $snmp->get([OID_cDot11ClientSignalStrength . '.' . $clientSuffix, OID_cDot11ClientBytesReceived . '.' . $clientSuffix, OID_cDot11ClientBytesSent . '.' . $clientSuffix]);
         if (isset($walk_clientStatistics[OID_cDot11ClientSignalStrength . '.' . $clientSuffix])) {
             $clientSignalStrength = $walk_clientStatistics[OID_cDot11ClientSignalStrength . '.' . $clientSuffix];
         } else {
             $clientSignalStrength = null;
         }
         if (isset($walk_clientStatistics[OID_cDot11ClientBytesReceived . '.' . $clientSuffix])) {
             $clientBytesReceived = $walk_clientStatistics[OID_cDot11ClientBytesReceived . '.' . $clientSuffix];
         } else {
             $clientBytesReceived = null;
         }
         if (isset($walk_clientStatistics[OID_cDot11ClientBytesSent . '.' . $clientSuffix])) {
             $clientBytesSent = $walk_clientStatistics[OID_cDot11ClientBytesSent . '.' . $clientSuffix];
         } else {
             $clientBytesSent = null;
         }
         // find bssid
         $bssid = \App\Bssid::where('node_id', $this->node->id)->where('bssidName', $bssidName)->first();
         if ($bssid) {
             // found bssid
             $_ret[] = ['table' => 'bds', 'action' => 'insert', 'key' => ['node_id' => $this->node->id, 'bssid_id' => $bssid->id, 'clientMacAddress' => $clientMacAddress, 'timestamp' => \Carbon\Carbon::now()], 'data' => ['clientIpAddress' => $clientIpAddress, 'clientSignalStrength' => $clientSignalStrength, 'clientBytesReceived' => $clientBytesReceived, 'clientBytesSent' => $clientBytesSent]];
         }
     }
     return $_ret;
 }