diff --git a/content/network/NetworkData.php b/content/network/NetworkData.php index 9c4f980..30c324c 100644 --- a/content/network/NetworkData.php +++ b/content/network/NetworkData.php @@ -26,17 +26,26 @@ private function prepareData() * * Also using one of the scripts in lib/string_helpers.php to * print the network speed in either b/s, Kb/s or Gb/s. + * + * The local IP address and subnet mask are retrieved using the + * 'ip' command. */ $output = shell_exec('sh ./lib/transfer_rate.sh ' . $this->interface); $rates = explode(' ', $output); + $ip_address = shell_exec("ip addr show " . $this->interface . " | grep 'inet\b' | awk '{print $2}' | cut -d/ -f1"); + $subnet_mask = shell_exec("ip addr show " . $this->interface . " | grep 'inet\b' | awk '{print $2}' | cut -d/ -f2"); + // data object $data = new \stdClass(); $data->down = StringHelpers::prettyBaud($rates[0]); $data->up = StringHelpers::prettyBaud($rates[1]); + $data->ip_address = trim($ip_address); + $data->subnet_mask = trim($subnet_mask); + return $data; } diff --git a/content/network/NetworkView.php b/content/network/NetworkView.php index 6cbffaf..782808e 100644 --- a/content/network/NetworkView.php +++ b/content/network/NetworkView.php @@ -12,12 +12,14 @@ - - + + - - + + + +

Down:

down;?>

IP address:

ip_address . "/" . $network_data->subnet_mask;?>

Up:

up;?>

Down:

down;?>

Up:

up;?>