diff --git a/main/views.py b/main/views.py index 23861fe..9adf051 100755 --- a/main/views.py +++ b/main/views.py @@ -81,6 +81,48 @@ def get_ipaddress(): data = pipe.read().strip().split() pipe.close() + data = [n for n in data if not n.startswith(('lo', '127'))] + #x=len(data) + + #data1 = list(range(x)) + + #data = dict(zip(data1,data)) + #data = data1 + + #data = chunks(data, 2) + + + itf = dict(zip(*[iter(data)] * 2)) + ips = {'interface': itf, 'itfip': data} + + data = ips + + except Exception,err: + data = str(err) + + return data + +def get_traffic(request): + """ + Get the traffic for the specified interface + """ + try: + pipe = os.popen("cat /proc/net/dev |" + "grep " + request + "| awk {'print $1, $9'}") + data = pipe.read().strip().split(':',1)[-1] + pipe.close() + + #data = [n for n in data if not n.startswith(('lo'))] + data = data.split() + + traffic_in = int(data[0]) + traffic_out = int(data[1]) + + #percent = (100 - ((freemem * 100) / allmem)) + #usage = (allmem - freemem) + + all_traffic = {'traffic_in': traffic_in, 'traffic_out': traffic_out} + + data = all_traffic except Exception,err: data = str(err) @@ -108,7 +150,7 @@ def get_disk(): #data = commands.getoutput("df -Ph | column -t") pipe = os.popen("df -Ph | " + "grep -v Filesystem | " + "awk '{print $1, $2, $3, $4, $5, $6}'") data = pipe.read().strip().split() - pipe.close() + pipe.close() #x=len(data) @@ -170,5 +212,6 @@ def getall(request): 'getplatform': get_platform(), 'getdisk': get_disk(), 'getip': get_ipaddress(), + #'gettraffic': get_traffic(), 'time_refresh': time_refresh }, context_instance=RequestContext(request)) diff --git a/static/css/bootstrap.min.css b/static/css/bootstrap.min.css index 0a7c951..290e388 100644 --- a/static/css/bootstrap.min.css +++ b/static/css/bootstrap.min.css @@ -1862,6 +1862,18 @@ background-repeat:no-repeat; line-height: 22px; padding: 0 6px; } + +.btn-mini-select { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + font-size: 11px; + line-height: 18px; + line-height: 18px; + padding: 0 0; +} .btn-primary, .btn-primary:hover, .btn-warning, .btn-warning:hover, .btn-danger, .btn-danger:hover, .btn-success, .btn-success:hover, .btn-info, .btn-info:hover, .btn-inverse, .btn-inverse:hover { text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); color: #ffffff; @@ -3645,4 +3657,4 @@ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endCo } .invisible { visibility: hidden; -} \ No newline at end of file +} diff --git a/templates/base_auth.html b/templates/base_auth.html index e3f711f..6dedd3f 100644 --- a/templates/base_auth.html +++ b/templates/base_auth.html @@ -4,7 +4,7 @@ -