blob: 12521bf162ab3d6d1372e4ba5d99798df5ec7e8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<?php
require 'Utils/Misc.class.php';
$datas = array();
if (!(exec('/sbin/ifconfig | awk -F " " \'{print $1}\' | sed -e \'/^$/d\'', $getInterfaces)))
{
$datas[] = array('interface' => 'N.A', 'ip' => 'N.A');
}
else
{
exec('/sbin/ifconfig | awk \'/inet / {print $2}\' | cut -d \':\' -f2', $getIps);
foreach ($getInterfaces as $key => $interface)
{
// Get transmit and receive datas by interface
exec('cat /sys/class/net/'.$interface.'/statistics/tx_bytes', $getBandwidth_tx);
exec('cat /sys/class/net/'.$interface.'/statistics/rx_bytes', $getBandwidth_rx);
$datas[] = array(
'interface' => $interface,
'ip' => $getIps[$key],
'transmit' => Misc::getSize($getBandwidth_tx[0]),
'receive' => Misc::getSize($getBandwidth_rx[0]),
);
unset($getBandwidth_tx, $getBandwidth_rx);
}
}
echo json_encode($datas);
|