Browse Source

code update

windows
Florian N 12 years ago
parent
commit
efa0bc15be
  1. 45
      main/views.py
  2. 14
      static/css/bootstrap.min.css
  3. 2
      templates/base_auth.html
  4. 4
      templates/ip.html
  5. 7
      templates/main.html
  6. 3
      usage/views.py

45
main/views.py

@ -81,6 +81,48 @@ def get_ipaddress():
data = pipe.read().strip().split() data = pipe.read().strip().split()
pipe.close() 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: except Exception,err:
data = str(err) data = str(err)
@ -108,7 +150,7 @@ def get_disk():
#data = commands.getoutput("df -Ph | column -t") #data = commands.getoutput("df -Ph | column -t")
pipe = os.popen("df -Ph | " + "grep -v Filesystem | " + "awk '{print $1, $2, $3, $4, $5, $6}'") pipe = os.popen("df -Ph | " + "grep -v Filesystem | " + "awk '{print $1, $2, $3, $4, $5, $6}'")
data = pipe.read().strip().split() data = pipe.read().strip().split()
pipe.close()
pipe.close()
#x=len(data) #x=len(data)
@ -170,5 +212,6 @@ def getall(request):
'getplatform': get_platform(), 'getplatform': get_platform(),
'getdisk': get_disk(), 'getdisk': get_disk(),
'getip': get_ipaddress(), 'getip': get_ipaddress(),
#'gettraffic': get_traffic(),
'time_refresh': time_refresh 'time_refresh': time_refresh
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))

14
static/css/bootstrap.min.css

@ -1862,6 +1862,18 @@ background-repeat:no-repeat;
line-height: 22px; line-height: 22px;
padding: 0 6px; 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 { .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); text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
color: #ffffff; color: #ffffff;
@ -3645,4 +3657,4 @@ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endCo
} }
.invisible { .invisible {
visibility: hidden; visibility: hidden;
}
}

2
templates/base_auth.html

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="{% static "img/favicon.ico" %}"> <link rel="shortcut icon" href="{% static "img/favicon.ico" %}">
<title>{% block title %}{% endblock %}</title>
<title>{% block title %}PyDash - Authentication{% endblock %}</title>
<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">
<link href="{% static "css/dashboard.css" %}" rel="stylesheet"> <link href="{% static "css/dashboard.css" %}" rel="stylesheet">
<link href="{% static "css/signin.css" %}" rel="stylesheet"> <link href="{% static "css/signin.css" %}" rel="stylesheet">

4
templates/ip.html

@ -6,9 +6,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for data in getip %}
{% for itfip in getip.itfip %}
{% cycle '<tr>' ''%} {% cycle '<tr>' ''%}
<td>{{data}}</td>
<td>{{itfip}}</td>
{% cycle '' '</tr>' %} {% cycle '' '</tr>' %}
{% endfor %} {% endfor %}
</tbody> </tbody>

7
templates/main.html

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<title>{% block title %}{% endblock %}</title>
<title>{% block title %}PyDash{% endblock %}</title>
<link href="{% static "css/fonts.css" %}" rel="stylesheet"> <link href="{% static "css/fonts.css" %}" rel="stylesheet">
<link href="{% static "css/font-awesome.css" %}" rel="stylesheet"> <link href="{% static "css/font-awesome.css" %}" rel="stylesheet">
<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">
@ -175,7 +175,7 @@
</div> </div>
<!-- /widget --> <!-- /widget -->
</div><!-- /span --> </div><!-- /span -->
<div class="span3"> <div class="span3">
<div class="widget"> <div class="widget">
<div class="widget-header"> <i class="icon-monitor"></i> <div class="widget-header"> <i class="icon-monitor"></i>
@ -186,8 +186,7 @@
<!-- /widget-header --> <!-- /widget-header -->
<div class="widget-content"> <div class="widget-content">
<div align="center" style="padding:10px;"> <div align="center" style="padding:10px;">
<span class="lead value odometer" style="margin-top:11px;" id="ispeed-rate">0</span>
<span class="lead">Mbps</span>
<span class="lead">{{gettraffic}}</span>
</div> </div>
</div> </div>
<!-- /widget-content --> <!-- /widget-content -->

3
usage/views.py

@ -6,6 +6,8 @@ from django.utils import simplejson
from main.views import * from main.views import *
from pydash.settings import TIME_JS_REFRESH from pydash.settings import TIME_JS_REFRESH
time_refresh = TIME_JS_REFRESH
def cpuusage(request): def cpuusage(request):
""" """
Return CPU Usage in % Return CPU Usage in %
@ -188,3 +190,4 @@ def loadaverage(request):
response.cookies['load_average'] = datasets response.cookies['load_average'] = datasets
response.write(data) response.write(data)
return response return response
Loading…
Cancel
Save