mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
ifconfig ok
This commit is contained in:
parent
164e571a97
commit
f10f6dcbb0
1 changed files with 18 additions and 2 deletions
|
@ -38,11 +38,22 @@ except ImportError:
|
||||||
sys.stderr.write('apt-get install python-yaml\n')
|
sys.stderr.write('apt-get install python-yaml\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
|
import fcntl
|
||||||
|
import struct
|
||||||
if not __debug__:
|
if not __debug__:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
s = xmlrpclib.ServerProxy('http://127.0.0.1:61209')
|
s = xmlrpclib.ServerProxy('http://127.0.0.1:61209')
|
||||||
|
|
||||||
|
def get_ip_address(ifname):
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
return socket.inet_ntoa(fcntl.ioctl(
|
||||||
|
s.fileno(),
|
||||||
|
0x8915, # SIOCGIFADDR
|
||||||
|
struct.pack('256s', ifname[:15])
|
||||||
|
)[20:24])
|
||||||
|
|
||||||
def bytes2human(n):
|
def bytes2human(n):
|
||||||
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
||||||
prefix = {}
|
prefix = {}
|
||||||
|
@ -126,6 +137,11 @@ def monitor_info(memory=False, cpu=False, disk=False, ifconfig=False, uptime=Fal
|
||||||
result = {}
|
result = {}
|
||||||
for k, fs in enumerate(json.loads(s.getNetwork())):
|
for k, fs in enumerate(json.loads(s.getNetwork())):
|
||||||
interface = fs['interface_name']
|
interface = fs['interface_name']
|
||||||
|
if interface != "lo":
|
||||||
|
ip = get_ip_address(str(interface))
|
||||||
|
del fs['interface_name']
|
||||||
|
result[ip] = fs
|
||||||
|
else:
|
||||||
del fs['interface_name']
|
del fs['interface_name']
|
||||||
result[interface] = fs
|
result[interface] = fs
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Add table
Reference in a new issue