getNet.

@return array of network devices
175861
public function getNet()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Network Devices');
        }

        // Hold our return values
        $return = [];

        // Get values for each device
        foreach ((array) @glob('/sys/class/net/*', GLOB_NOSORT) as $path) {
            $nic = basename($path);

            // States
            $operstate_contents = Common::getContents($path.'/operstate');
            switch ($operstate_contents) {
                case 'down':
                case 'up':
                case 'unknown':
                    $state = $operstate_contents;
                break;

                default:
                    $state = 'unknown';
                break;
            }

            if ($state === 'unknown' && file_exists($path.'/carrier')) {
                $carrier = Common::getContents($path.'/carrier', false);
                if (!empty($carrier)) {
                    $state = 'up';
                } else {
                    $state = 'down';
                }
            }

            // Try the weird ways of getting type (https://stackoverflow.com/a/16060638)
            $type = false;
            $typeCode = Common::getIntFromFile($path.'/type');

            if ($typeCode == 772) {
                $type = 'Loopback';
            } elseif ($typeCode == 65534) {
                $type = 'Tunnel';
            } elseif ($typeCode == 776) {
                $type = 'IPv6 in IPv4';
            }

            if (!$type) {
                $type_contents = strtoupper(Common::getContents($path.'/device/modalias'));
                list($type_match) = explode(':', $type_contents, 2);

                if (in_array($type_match, array('PCI', 'USB'))) {
                    $type = 'Ethernet ('.$type_match.')';

                    // Driver maybe?
                    if (($uevent_contents = @parse_ini_file($path.'/device/uevent')) && isset($uevent_contents['DRIVER'])) {
                        $type .= ' ('.$uevent_contents['DRIVER'].')';
                    }
                } elseif ($type_match == 'VIRTIO') {
                    $type = 'VirtIO';
                } elseif ($type_contents == 'XEN:VIF') {
                    $type = 'Xen (VIF)';
                } elseif ($type_contents == 'XEN-BACKEND:VIF') {
                    $type = 'Xen Backend (VIF)';
                } elseif (is_dir($path.'/bridge')) {
                    $type = 'Bridge';
                } elseif (is_dir($path.'/bonding')) {
                    $type = 'Bond';
                }

                // TODO find some way of finding out what provides the virt-specific kvm vnet devices
            }

            $speed = Common::getIntFromFile($path.'/speed');

            // Save and get info for each
            $return[$nic] = array(

                // Stats are stored in simple files just containing the number
                'recieved' => array(
                    'bytes' => Common::getIntFromFile($path.'/statistics/rx_bytes'),
                    'errors' => Common::getIntFromFile($path.'/statistics/rx_errors'),
                    'packets' => Common::getIntFromFile($path.'/statistics/rx_packets'),
                ),
                'sent' => array(
                    'bytes' => Common::getIntFromFile($path.'/statistics/tx_bytes'),
                    'errors' => Common::getIntFromFile($path.'/statistics/tx_errors'),
                    'packets' => Common::getIntFromFile($path.'/statistics/tx_packets'),
                ),

                // These were determined above
                'state' => $state,
                'type' => $type ?: 'N/A',
                'port_speed' => $speed > 0 ? $speed : false,
            );
        }

        // Return array of info
        return $return;
    }
1070562
public function getConnections()
    {
        $connections = [];
        foreach ($this->getConnectionNames() as $name) {
            $connections[$name] = $this->getConnection($name);
        }

        return $connections;
    }
155630
public function getMinHost()
    {
        if ($this->network_size === 32 || $this->network_size === 31) {
            return $this->ip_address;
        }
        return $this->minHostCalculation(self::FORMAT_QUADS, '.');
    }
810681
private function getCurrentDeviceProperties()
    {
        if ($properties = $this->getDeviceDetector()->detect()) {
            $parser = $this->getUserAgentParser();

            $properties['platform']         = $parser->getOperatingSystemFamily();
            $properties['platform_version'] = $parser->getOperatingSystemVersion();
        }

        return $properties;
    }
688208
private function _network()
    {
        $dev = null;
        if (CommonFunctions::executeProgram('netstat', '-nibd', $netstat, PSI_DEBUG)) {
            $lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($lines as $line) {
                $ar_buf = preg_split("/\s+/", $line);
                if (!empty($ar_buf[0])) {
                    if (preg_match('/^<Link/i', $ar_buf[2])) {
                        $dev = new NetDevice();
                        $dev->setName($ar_buf[0]);
                        if ((strlen($ar_buf[3]) < 17) && ($ar_buf[0] != $ar_buf[3])) { /* no MAC or dev name*/
                            if (isset($ar_buf[11]) && (trim($ar_buf[11]) != '')) { /* Idrop column exist*/
                              $dev->setTxBytes($ar_buf[9]);
                              $dev->setRxBytes($ar_buf[6]);
                              $dev->setErrors($ar_buf[4] + $ar_buf[8]);
                              $dev->setDrops($ar_buf[11] + $ar_buf[5]);
                            } else {
                              $dev->setTxBytes($ar_buf[8]);
                              $dev->setRxBytes($ar_buf[5]);
                              $dev->setErrors($ar_buf[4] + $ar_buf[7]);
                              $dev->setDrops($ar_buf[10]);
                            }
                        } else {
                            if (isset($ar_buf[12]) && (trim($ar_buf[12]) != '')) { /* Idrop column exist*/
                              $dev->setTxBytes($ar_buf[10]);
                              $dev->setRxBytes($ar_buf[7]);
                              $dev->setErrors($ar_buf[5] + $ar_buf[9]);
                              $dev->setDrops($ar_buf[12] + $ar_buf[6]);
                            } else {
                              $dev->setTxBytes($ar_buf[9]);
                              $dev->setRxBytes($ar_buf[6]);
                              $dev->setErrors($ar_buf[5] + $ar_buf[8]);
                              $dev->setDrops($ar_buf[11]);
                            }
                        }
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' 2>/dev/null', $bufr2, PSI_DEBUG))) {
                            $bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
                            foreach ($bufe2 as $buf2) {
                                if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2)) {
                                    if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
                                } elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)) {
                                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
                                } elseif ((preg_match('/^\s+inet6\s+([^\s%]+)\s+prefixlen/i', $buf2, $ar_buf2)
                                      || preg_match('/^\s+inet6\s+([^\s%]+)%\S+\s+prefixlen/i', $buf2, $ar_buf2))
                                      && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
                                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
                                } elseif (preg_match('/^\s+media:\s+/i', $buf2) && preg_match('/[\(\s](\d+)(G*)base/i', $buf2, $ar_buf2)) {
                                    if (isset($ar_buf2[2]) && strtoupper($ar_buf2[2])=="G") {
                                        $unit = "G";
                                    } else {
                                        $unit = "M";
                                    }
                                    if (preg_match('/[<\s]([^\s<]+)-duplex/i', $buf2, $ar_buf3))
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s '.strtolower($ar_buf3[1]));
                                    else
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s');
                                }
                            }
                        }
                        $this->sys->setNetDevices($dev);
                    }
                }
            }
        }
    }
1061310
protected function &getReadArray()
    {
        $readArray = array();
        $readArray[] = $this->socket->getRawSocket();
        foreach ($this->clients as $client) {
            if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSED) {
                $readArray[] = $client->getSocket()->getRawSocket();
            }
        }

        return $readArray;
    }
1359206
public java.util.List<NetworkInterface> getGatewayNetworkInterfaces() {
        if (gatewayNetworkInterfaces == null) {
            gatewayNetworkInterfaces = new com.amazonaws.internal.SdkInternalList<NetworkInterface>();
        }
        return gatewayNetworkInterfaces;
    }
818277
public function getDevices(): array
    {
        if (!$this->discovered) {
            $socket = new Socket(
                $this->getNetworkInterface(),
                $this->getMulticastAddress(),
                $this->collection->getLogger()
            );
            $this->discoverDevices($socket);
            $this->discovered = true;
        }

        return $this->collection->getDevices();
    }
439281
def get_network():
    """"""
    meta = SoftLayer.MetadataManager()
    network_tables = []
    for network_func in [meta.public_network, meta.private_network]:
        network = network_func()

        table = formatting.KeyValueTable(['name', 'value'])
        table.align['name'] = 'r'
        table.align['value'] = 'l'
        table.add_row(['mac addresses',
                       formatting.listing(network['mac_addresses'],
                                          separator=',')])
        table.add_row(['router', network['router']])
        table.add_row(['vlans',
                       formatting.listing(network['vlans'], separator=',')])
        table.add_row(['vlan ids',
                       formatting.listing(network['vlan_ids'], separator=',')])
        network_tables.append(table)

    return network_tables
71527
public function getBroadcastAddress()
    {
        $network_quads         = $this->getNetworkPortionQuads();
        $number_ip_addresses   = $this->getNumberIPAddresses();

        $network_range_quads   = [];
        $network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[0] & ( $this->subnet_mask >> 24 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 24 ) & 0xFF ));
        $network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[1] & ( $this->subnet_mask >> 16 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 16 ) & 0xFF ));
        $network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[2] & ( $this->subnet_mask >>  8 ) ) + ( ( ( $number_ip_addresses - 1 ) >>  8 ) & 0xFF ));
        $network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[3] & ( $this->subnet_mask >>  0 ) ) + ( ( ( $number_ip_addresses - 1 ) >>  0 ) & 0xFF ));

        return implode('.', $network_range_quads);
    }
580222
public function getWifi()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Wifi');
        }

        // Return these
        $return = [];

        // In here
        $contents = Common::getContents('/proc/net/wireless');

        // Oi
        if ($contents == false) {
            Errors::add('Linux WiFi info parser', '/proc/net/wireless does not exist');

            return $return;
        }

        // Parse
        @preg_match_all('/^ (\S+)\:\s*(\d+)\s*(\S+)\s*(\S+)\s*(\S+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*$/m', $contents, $match, PREG_SET_ORDER);

        // Match
        foreach ($match as $wlan) {
            $return[] = array(
                'device' => $wlan[1],
                'status' => $wlan[2],
                'quality_link' => $wlan[3],
                'quality_level' => $wlan[4],
                'quality_noise' => $wlan[5],
                'dis_nwid' => $wlan[6],
                'dis_crypt' => $wlan[7],
                'dis_frag' => $wlan[8],
                'dis_retry' => $wlan[9],
                'dis_misc' => $wlan[10],
                'mis_beac' => $wlan[11],
            );
        }

        // Done
        return $return;
    }
739973
public function getAllDevicesID()
    {
        $devicesId = array();

        foreach ($this->deviceClassificationNames as $className) {
            $currentMap = $this->persistenceStorage->load($className);

            if (!is_array($currentMap)) {
                $currentMap = array();
            }

            $overwritten = $this->persistenceStorage->load($className . '_overwritten');

            if (!is_array($overwritten)) {
                $overwritten = array();
            }

            $devicesId = array_merge($devicesId, array_values($currentMap), $overwritten);
        }

        return $devicesId;
    }
1216798
function GetDSN()
    {
	    return array(
		    'phptype'  => $this->Type,
		    'username' => $this->Username,
		    'password' => $this->Password,
		    'hostspec' => $this->ConnectionString,
		    'database' => $this->DBName,
	    );
	}
252704
protected function getWebsocketConnections(): array
    {
        return array_filter(iterator_to_array($this->server->connections), function ($fd) {
            return $this->server->isEstablished($fd);
        });
    }
93594
public function getNodes()
    {
        $nodes = [];
        foreach ($this->applications as $application) {
            foreach ($application->getNodes() as $node) {
                $nodes[$node->getName()] = $node;
            }
        }

        return $nodes;
    }
941052
public function devices()
    {
        if (empty($this->all_devices)) {
            $response = $this->fromJson($this->api->get('devices'));

            $this->all_devices = array_map(function ($device) {
                return new Device($device);
            }, $response['devices']);
        }

        return $this->all_devices;
    }
1349999
public function getDrivers(): array
    {
        $result = [];
        foreach (array_keys($this->config['connections'] ?? $this->config['drivers'] ?? []) as $driver) {
            $result[$driver] = $this->getDriver($driver);
        }

        return $result;
    }