Browse Source

change how we get IP data

windows
Florian N 12 years ago
parent
commit
cf5a83e18e
  1. 46
      main/views.py
  2. 4
      pydash/settings.py
  3. 4
      static/js/dashboard.js

46
main/views.py

@ -70,31 +70,31 @@ def get_ipaddress():
"""
Get the IP Address
"""
data = []
try:
if get_platform()['osname'] == "Linux":
pipe = os.popen("ip addr | grep -A3 'LOWER_UP' | awk '{if ($2 == \"forever\"){printf \"unavailable,\"} else{ printf \"%s,\",$2}}'|awk -F,, '{print $0}'")
else:
pipe = os.popen("ip addr | grep -A3 'LOWER_UP' | awk '{if ($2 == \"forever\"){printf \"unavailable,,\"} else{ printf \"%s,\",$2}}'|awk -F,, '{print $0}'")
data = pipe.read().strip().split(',,')
pipe.close()
eth = os.popen("ip addr | grep LOWER_UP | awk '{print $2}'")
iface = eth.read().strip().replace(':','').split('\n')
eth.close()
del iface[0]
for i in iface:
pipe = os.popen("ip addr show " + i + "| awk '{if ($2 == \"forever\"){!$2} else {print $2}}'")
data1 = pipe.read().strip().split('\n')
pipe.close()
if len(data1) == 2:
data1.append('unavailable', 'unavailable')
if len(data1) == 3:
data1.append('unavailable')
data1[0] = i
data.append(data1)
ips = {'interface': iface, 'itfip': data}
data = ips
except Exception,err:
data = str(err)
data = [i.split(',', 4) for i in data]
if len(data) == 2:
del data[0]
if len(data) > 2:
data = data[1:-1]
itf = []
for e in data:
itf.append(e[0].strip(':'))
ips = {'interface': itf, 'itfip': data}
data = ips
except Exception,err:
data = str(err)
return data
def get_cpus():

4
pydash/settings.py

@ -18,7 +18,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '1)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af'
SECRET_KEY = '1)23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
@ -35,7 +35,7 @@ TIME_JS_REFRESH = 30000
TIME_JS_REFRESH_LONG = 120000
TIME_JS_REFRESH_NET = 2000
VERSION = "1.4.3"
VERSION = "1.4.4"
ALLOWED_HOSTS = ['*']

4
static/js/dashboard.js

@ -234,8 +234,8 @@ dashboard.getIps = function() {
aoColumns: [
{ sTitle: "INTERFACE" },
{ sTitle: "MAC ADDRESS" },
{ sTitle: "IPv4 ADDRESS" },
{ sTitle: "IPv6 ADDRESS",
{ sTitle: "IP ADDRESS" },
{ sTitle: "IP ADDRESS",
sDefaultContent: "unavailable" }
],
bPaginate: false,

Loading…
Cancel
Save