From 6660c595ba64bd886ff912a544f02c31a8282891 Mon Sep 17 00:00:00 2001 From: Florian N Date: Thu, 20 Feb 2014 21:00:14 -0500 Subject: [PATCH 01/27] add all data to urls --- main/views.py | 6 +---- pydash/urls.py | 2 ++ static/js/dashboard.js | 15 +++++++++++ templates/main.html | 13 ++++++--- usage/views.py | 61 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 9 deletions(-) diff --git a/main/views.py b/main/views.py index f6ec73d..1cc9c5e 100755 --- a/main/views.py +++ b/main/views.py @@ -317,11 +317,7 @@ def get_netstat(): @login_required(login_url='/login/') def getall(request): - return render_to_response('main.html', {'gethostname': get_platform()['hostname'], - 'getplatform': get_platform()['osname'], - 'getkernel': get_platform()['kernel'], - 'getcpus': get_cpus(), - 'time_refresh': time_refresh, + return render_to_response('main.html', {'time_refresh': time_refresh, 'time_refresh_long': time_refresh_long, 'time_refresh_net': time_refresh_net, 'version': version diff --git a/pydash/urls.py b/pydash/urls.py index 60eff05..9841377 100644 --- a/pydash/urls.py +++ b/pydash/urls.py @@ -24,6 +24,8 @@ urlpatterns = patterns('', url(r'^info/proc/$', 'usage.views.getproc', name='getproc'), url(r'^info/getdiskio/$', 'usage.views.getdiskio', name='getdiskio'), url(r'^info/loadaverage/$', 'usage.views.loadaverage', name='loadaverage'), + url(r'^info/platform/([\w\-\.]+)/$', 'usage.views.platform', name='platform'), + url(r'^info/getcpus/([\w\-\.]+)/$', 'usage.views.getcpus', name='getcpus'), url(r'^info/getnetstat/$', 'usage.views.getnetstat', name='getnetstat') ) diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 2411923..5b41e06 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -103,6 +103,21 @@ var dashboard = {}; dashboard.getUptime = function() { get_os_data('/info/uptime/', "#get-uptime"); } +dashboard.getOSname = function() { + get_os_data('/info/platform/osname/', "#get-osname"); + } +dashboard.getHostname = function() { + get_os_data('/info/platform/hostname/', "#get-hostname"); + } +dashboard.getKernel = function() { + get_os_data('/info/platform/kernel/', "#get-kernel"); + } +dashboard.getCPUcount = function() { + get_os_data('/info/getcpus/count/', "#get-cpucount"); + } +dashboard.getCPUtype = function() { + get_os_data('/info/getcpus/type/', "#get-cputype"); + } dashboard.getDisk = function() { $.getJSON('/info/getdisk/', function(data) { destroy_dataTable("get_disk"); diff --git a/templates/main.html b/templates/main.html index 521ebc9..1362f5d 100644 --- a/templates/main.html +++ b/templates/main.html @@ -72,11 +72,11 @@

- OS: {{ getplatform }}
+ OS:
Uptime: Hours
- Hostname: {{ gethostname }}
- Kernel: {{ getkernel }}
- CPU(s): {{ getcpus.cpus }} x {{ getcpus.type }} + Hostname:
+ Kernel:
+ CPU(s): x

@@ -407,7 +407,12 @@ $(function pageLoad() { cpuu_usage(); traffic_usage(); disk_io(); + dashboard.getOSname(); dashboard.getUptime(); + dashboard.getHostname(); + dashboard.getKernel(); + dashboard.getCPUcount(); + dashboard.getCPUtype(); dashboard.getDisk(); dashboard.getUsers(); dashboard.getNetstat(); diff --git a/usage/views.py b/usage/views.py index dc53442..33cdffc 100755 --- a/usage/views.py +++ b/usage/views.py @@ -49,6 +49,67 @@ def getnetstat(request): response['Content-Type'] = "text/javascript" response.write(data) return response + +@login_required(login_url='/login/') +def platform(request, name): + """ + Return the hostname + """ + getplatform = get_platform() + hostname = getplatform['hostname'] + osname = getplatform['osname'] + kernel = getplatform['kernel'] + + if name == 'hostname': + try: + data = hostname + except Exception: + data = None + + if name == 'osname': + try: + data = osname + except Exception: + data = None + + if name == 'kernel': + try: + data = kernel + except Exception: + data = None + + data = json.dumps(data) + response = HttpResponse() + response['Content-Type'] = "text/javascript" + response.write(data) + return response + +@login_required(login_url='/login/') +def getcpus(request, name): + """ + Return the CPU number and type/model + """ + getcpus = get_cpus() + cputype = getcpus['type'] + cpucount = getcpus['cpus'] + + if name == 'type': + try: + data = cputype + except Exception: + data = None + + if name == 'count': + try: + data = cpucount + except Exception: + data = None + + data = json.dumps(data) + response = HttpResponse() + response['Content-Type'] = "text/javascript" + response.write(data) + return response @login_required(login_url='/login/') From d57dfddbd21ec276d927f156f26854b146a32e63 Mon Sep 17 00:00:00 2001 From: Florian N Date: Fri, 21 Feb 2014 23:18:30 -0500 Subject: [PATCH 02/27] fix null values in datatable --- pydash/settings.py | 2 +- static/js/dashboard.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pydash/settings.py b/pydash/settings.py index afab89c..dd637b0 100644 --- a/pydash/settings.py +++ b/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)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3a9' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 5b41e06..57c5d63 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -152,7 +152,8 @@ dashboard.getUsers = function() { aoColumns: [ { sTitle: "USER" }, { sTitle: "TTY" }, - { sTitle: "LOOGED IN FROM" } + { sTitle: "LOOGED IN FROM", + sDefaultContent: "unavailable" } ], bPaginate: false, bFilter: true, @@ -231,7 +232,8 @@ dashboard.getIps = function() { { sTitle: "INTERFACE" }, { sTitle: "MAC ADDRESS" }, { sTitle: "IPv4 ADDRESS" }, - { sTitle: "IPv6 ADDRESS" } + { sTitle: "IPv6 ADDRESS", + sDefaultContent: "unavailable" } ], bPaginate: false, bFilter: true, From 827640cafe41727f53a150c22b743e24aadf6961 Mon Sep 17 00:00:00 2001 From: Florian N Date: Fri, 21 Feb 2014 23:23:02 -0500 Subject: [PATCH 03/27] clean up for data unavailable --- main/views.py | 6 ------ pydash/settings.py | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/main/views.py b/main/views.py index 1cc9c5e..71b7fb4 100755 --- a/main/views.py +++ b/main/views.py @@ -128,9 +128,6 @@ def get_users(): except Exception, err: data = str(err) - if data[0] == []: - data = [['No', 'data', 'available']] - return data def get_traffic(request): @@ -308,9 +305,6 @@ def get_netstat(): except Exception, err: data = str(err) - if data[0] == []: - data = [['No', 'data', 'available']] - return data diff --git a/pydash/settings.py b/pydash/settings.py index dd637b0..5e0d2e0 100644 --- a/pydash/settings.py +++ b/pydash/settings.py @@ -18,7 +18,8 @@ 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!3a9' +SECRET_KEY = '1)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af' +#SECRET_KEY = '1)$-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3a9' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False From 7649d0304f234ad3a883a877f4f0cb7acc24f6f1 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 22 Feb 2014 16:25:14 -0500 Subject: [PATCH 04/27] small fix for ips --- main/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/views.py b/main/views.py index 71b7fb4..ba11243 100755 --- a/main/views.py +++ b/main/views.py @@ -71,12 +71,15 @@ def get_ipaddress(): Get the IP Address """ try: - pipe = os.popen(" ip addr | grep -A3 'LOWER_UP' | awk '{printf \"%s,\",$2}'|awk -F,, '{print $0}'") + 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() - data = [n for n in data if not n.startswith(('lo', '127'))] 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: From 6ed4f3ee6e29eaf42f915c4a27330b72d73888d7 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 22 Feb 2014 16:49:27 -0500 Subject: [PATCH 05/27] small fix for arch --- main/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/views.py b/main/views.py index ba11243..e352373 100755 --- a/main/views.py +++ b/main/views.py @@ -71,7 +71,10 @@ def get_ipaddress(): Get the IP Address """ try: - pipe = os.popen("ip addr | grep -A3 'LOWER_UP' | awk '{if ($2 == \"forever\"){printf \"unavailable,,\"} else{ printf \"%s,\",$2}}'|awk -F,, '{print $0}'") + 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() From e4e387cfe280e55ac8a9ae0abd7e0563770ba893 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sun, 23 Feb 2014 13:10:51 -0500 Subject: [PATCH 06/27] fix #18 --- main/views.py | 7 +++++-- static/js/dashboard.js | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/main/views.py b/main/views.py index e352373..cee502a 100755 --- a/main/views.py +++ b/main/views.py @@ -129,8 +129,11 @@ def get_users(): data = pipe.read().strip().split('\n') pipe.close() - data = [i.split(None, 3) for i in data] - + if data == [""]: + data = None + else: + data = [i.split(None, 3) for i in data] + except Exception, err: data = str(err) diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 57c5d63..355e7a4 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -153,11 +153,14 @@ dashboard.getUsers = function() { { sTitle: "USER" }, { sTitle: "TTY" }, { sTitle: "LOOGED IN FROM", - sDefaultContent: "unavailable" } + sDefaultContent: "unavailable" } ], - bPaginate: false, - bFilter: true, - sDom: "lrtip", + aaSorting: [ + [0, "desc"] + ], + bPaginate: true, + sPaginationType: "two_button", + bFilter: false, bAutoWidth: false, bInfo: false }).fadeIn(); From 733399e6084aca123f915c9c2fcc911b597e509b Mon Sep 17 00:00:00 2001 From: Florian N Date: Mon, 24 Feb 2014 19:44:45 -0500 Subject: [PATCH 07/27] Update settings.py --- pydash/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydash/settings.py b/pydash/settings.py index 5e0d2e0..c4649df 100644 --- a/pydash/settings.py +++ b/pydash/settings.py @@ -19,7 +19,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) # 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!3a9' + # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False From ba2544a9d769f30096c94ae2187aa6da474b79b9 Mon Sep 17 00:00:00 2001 From: Jordan Milne Date: Thu, 27 Feb 2014 15:38:38 -0400 Subject: [PATCH 08/27] Change eval(cookies) to json.loads(cookies) This fixes an RCE vulnerability in the cookie handling. If you rely on an attacker not being able to set cookies for security, you're going to have a bad time. Also, eval(cookies) will choke on valid JSON. See http://stackoverflow.com/a/1083302 --- usage/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usage/views.py b/usage/views.py index 33cdffc..7d896ba 100755 --- a/usage/views.py +++ b/usage/views.py @@ -244,7 +244,7 @@ def memusage(request): if not cookies: datasets.append(0) else: - datasets = eval(cookies) + datasets = json.loads(cookies) if len(datasets) > 10: while datasets: del datasets[0] @@ -303,7 +303,7 @@ def loadaverage(request): if not cookies: datasets.append(0) else: - datasets = eval(cookies) + datasets = json.loads(cookies) if len(datasets) > 10: while datasets: del datasets[0] @@ -375,7 +375,7 @@ def gettraffic(request): datasets_out.append(0) datasets_out_o.append(0) else: - datasets = eval(cookies) + datasets = json.loads(cookies) datasets_in = datasets[0] datasets_out = datasets[1] datasets_in_i = datasets[2] @@ -498,7 +498,7 @@ def getdiskio(request): datasets_out.append(0) datasets_out_o.append(0) else: - datasets = eval(cookies) + datasets = json.loads(cookies) datasets_in = datasets[0] datasets_out = datasets[1] datasets_in_i = datasets[2] From 17ac565e48af7c217090a364d9af2cdab818b397 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 1 Mar 2014 22:07:00 -0500 Subject: [PATCH 09/27] expand/collapse any table --- pydash/settings.py | 3 +-- static/css/style.css | 5 ----- static/js/dashboard.js | 9 +++++++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pydash/settings.py b/pydash/settings.py index c4649df..8acb3a8 100644 --- a/pydash/settings.py +++ b/pydash/settings.py @@ -20,7 +20,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '1)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af' - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False @@ -37,7 +36,7 @@ TIME_JS_REFRESH = 30000 TIME_JS_REFRESH_LONG = 120000 TIME_JS_REFRESH_NET = 2000 -VERSION = 1.4 +VERSION = 1.4.1 ALLOWED_HOSTS = ['*'] diff --git a/static/css/style.css b/static/css/style.css index 42c55ff..ce10fee 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -410,12 +410,8 @@ textarea { .widget-content { padding: 20px 15px 15px; - background: #FFF; - - border: 1px solid #D5D5D5; - -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; @@ -423,7 +419,6 @@ textarea { .widget-header+.widget-content { border-top: none; - -webkit-border-top-left-radius: 0; -webkit-border-top-right-radius: 0; -moz-border-radius-topleft: 0; diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 355e7a4..7542790 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -250,3 +250,12 @@ dashboard.getIps = function() { }); } +//Expand-Collapse div/table +jQuery(document).ready(function() { + jQuery(".widget-content").show(); + //toggle the componenet with class msg_body + jQuery(".widget-header").click(function() + { + jQuery(this).next(".widget-content").slideToggle(500); + }); +}); \ No newline at end of file From 4210cfb2b8d34cb10313801dfa05e93970054551 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 1 Mar 2014 22:08:45 -0500 Subject: [PATCH 10/27] v 1.4.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 725194b..db360d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -pyDash - v1.4 +pyDash - v1.4.1 ====== A small web monitoring dashboard for your linux pc/server writen in Python and Django + Chart.js. From 36dadb8e9951e42a844258aa7d7df961b70d616f Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 1 Mar 2014 22:11:44 -0500 Subject: [PATCH 11/27] typo --- static/js/dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 7542790..1a54f88 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -250,7 +250,7 @@ dashboard.getIps = function() { }); } -//Expand-Collapse div/table +//Expand-Contract div/table jQuery(document).ready(function() { jQuery(".widget-content").show(); //toggle the componenet with class msg_body From 0156a2710fd17f8685431221fe5679019ad78803 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 1 Mar 2014 22:13:01 -0500 Subject: [PATCH 12/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db360d5..30c95bf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pyDash - v1.4.1 ====== -A small web monitoring dashboard for your linux pc/server writen in Python and Django + Chart.js. +A small web-based monitoring dashboard for your linux pc/server writen in Python and Django + Chart.js. The dashboard is built using only Python libraries available in the main Python distribution, trying to create a small list of dependencies without the need of installing many packages or libraries. From 833f19cbac733f726b403f865ad5ecc19907d8f8 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 1 Mar 2014 22:25:52 -0500 Subject: [PATCH 13/27] version value fix --- pydash/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydash/settings.py b/pydash/settings.py index 8acb3a8..face6fd 100644 --- a/pydash/settings.py +++ b/pydash/settings.py @@ -36,7 +36,7 @@ TIME_JS_REFRESH = 30000 TIME_JS_REFRESH_LONG = 120000 TIME_JS_REFRESH_NET = 2000 -VERSION = 1.4.1 +VERSION = "1.4.1" ALLOWED_HOSTS = ['*'] From db03c17252400f5eb28093e899424af9155760f2 Mon Sep 17 00:00:00 2001 From: Florian N Date: Mon, 3 Mar 2014 15:16:07 -0500 Subject: [PATCH 14/27] add contract/expand icons, small fixes --- README.md | 2 +- pydash/settings.py | 2 +- static/js/dashboard.js | 12 ++++++------ templates/main.html | 39 ++++++++++++++++++--------------------- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 30c95bf..8b43a6f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -pyDash - v1.4.1 +pyDash - v1.4.2 ====== A small web-based monitoring dashboard for your linux pc/server writen in Python and Django + Chart.js. diff --git a/pydash/settings.py b/pydash/settings.py index face6fd..ade20e6 100644 --- a/pydash/settings.py +++ b/pydash/settings.py @@ -36,7 +36,7 @@ TIME_JS_REFRESH = 30000 TIME_JS_REFRESH_LONG = 120000 TIME_JS_REFRESH_NET = 2000 -VERSION = "1.4.1" +VERSION = "1.4.2" ALLOWED_HOSTS = ['*'] diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 1a54f88..a2eb107 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -251,11 +251,11 @@ dashboard.getIps = function() { } //Expand-Contract div/table -jQuery(document).ready(function() { - jQuery(".widget-content").show(); - //toggle the componenet with class msg_body - jQuery(".widget-header").click(function() +$(document).ready(function() { + $(".widget-content").show(); + $(".widget-header").click(function() { - jQuery(this).next(".widget-content").slideToggle(500); + $(this).next(".widget-content").slideToggle(500); + $("i",this).toggleClass("icon-minus icon-plus"); }); -}); \ No newline at end of file +}); diff --git a/templates/main.html b/templates/main.html index 1362f5d..0d1859d 100644 --- a/templates/main.html +++ b/templates/main.html @@ -61,12 +61,10 @@
-
-

General Info

- +
+

General Info

-
@@ -87,8 +85,8 @@
-
-

CPU Usage %

+
+

CPU Usage %

@@ -108,9 +106,8 @@
-
- -

Memory Usage

+
+

Memory Usage

@@ -130,7 +127,7 @@
-

Disk Usage

+

Disk Usage

@@ -146,7 +143,7 @@
-

Load Average

+

Load Average

@@ -167,8 +164,8 @@
-
-

IP Adresses

+
+

IP Adresses

@@ -185,8 +182,8 @@
-
-

Internet Traffic

+
+

Internet Traffic

@@ -207,8 +204,8 @@
-
-

Disk Reads/Writes

+
+

Disk Reads/Writes

@@ -233,7 +230,7 @@
-

Online

+

Online

@@ -250,7 +247,7 @@
-

Netstat

+

Netstat

@@ -270,8 +267,8 @@
-
-

Processes

+
+

Processes

From dcf38c6c3a5faf08e4c5f66bb376871b6215a3e7 Mon Sep 17 00:00:00 2001 From: Florian N Date: Mon, 3 Mar 2014 20:47:05 -0500 Subject: [PATCH 15/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b43a6f..63dcb30 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ __[View Demo](http://pydash.hostechs.com/)__ pass: admin -![pyDash](https://www.yaktab.com/en/2btxew) +![pyDash](https://www.yaktab.com/en/2btxe) Installation From 9a4c4bd053d5b57ab44847c8cc03761ff8258a45 Mon Sep 17 00:00:00 2001 From: Florian N Date: Mon, 3 Mar 2014 20:47:36 -0500 Subject: [PATCH 16/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63dcb30..8b43a6f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ __[View Demo](http://pydash.hostechs.com/)__ pass: admin -![pyDash](https://www.yaktab.com/en/2btxe) +![pyDash](https://www.yaktab.com/en/2btxew) Installation From 875914a1c88f39c24139d57857a4717e7c965e8f Mon Sep 17 00:00:00 2001 From: Bitdeli Chef Date: Wed, 5 Mar 2014 15:40:39 +0000 Subject: [PATCH 17/27] Add a Bitdeli badge to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8b43a6f..93d1485 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,7 @@ Credits [Dashboard Template](http://www.egrappler.com/templatevamp-free-twitter-bootstrap-admin-template/), [Bootstrap](http://getbootstrap.com/), [Font Awesome](http://fontawesome.io/) + + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/k3oni/pydash/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + From 5aca01a7893b6378b8112874132c171d3b852e12 Mon Sep 17 00:00:00 2001 From: Florian N Date: Wed, 5 Mar 2014 20:42:51 -0500 Subject: [PATCH 18/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93d1485..cb7fe8a 100644 --- a/README.md +++ b/README.md @@ -69,5 +69,5 @@ Credits [Font Awesome](http://fontawesome.io/) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/k3oni/pydash/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +Follow [@hostechs](https://twitter.com/hostechs) on Twitter From 8878387d8acabb77246a7869dd75f39a9b3ea726 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sat, 8 Mar 2014 16:16:44 -0500 Subject: [PATCH 19/27] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cb7fe8a..e0e0121 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,4 @@ Credits Follow [@hostechs](https://twitter.com/hostechs) on Twitter +[![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/2630601/k3onipydash-on-GitHub "Flattr this") From 50c97558c1541bcc35175fd75ababa2b244a0976 Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 11 Mar 2014 22:20:08 -0400 Subject: [PATCH 20/27] Add free mem to graphs --- main/views.py | 2 +- pydash/settings.py | 5 ++-- static/css/dashboard.css | 16 +++++++++++ templates/main.html | 8 ++++-- usage/views.py | 60 ++++++++++++++++++++++++++++------------ 5 files changed, 67 insertions(+), 24 deletions(-) diff --git a/main/views.py b/main/views.py index cee502a..2cad2fe 100755 --- a/main/views.py +++ b/main/views.py @@ -248,7 +248,7 @@ def get_mem(): percent = (100 - ((freemem * 100) / allmem)) usage = (allmem - freemem) - mem_usage = {'usage': usage, 'percent': percent} + mem_usage = {'usage': usage, 'free': freemem, 'percent': percent} data = mem_usage diff --git a/pydash/settings.py b/pydash/settings.py index ade20e6..a064ebf 100644 --- a/pydash/settings.py +++ b/pydash/settings.py @@ -18,8 +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)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False @@ -36,7 +35,7 @@ TIME_JS_REFRESH = 30000 TIME_JS_REFRESH_LONG = 120000 TIME_JS_REFRESH_NET = 2000 -VERSION = "1.4.2" +VERSION = "1.4.3" ALLOWED_HOSTS = ['*'] diff --git a/static/css/dashboard.css b/static/css/dashboard.css index 86aad04..5ade332 100644 --- a/static/css/dashboard.css +++ b/static/css/dashboard.css @@ -403,3 +403,19 @@ h6.bigstats { padding: 0 0.3em; border-style: solid; } +.memf { + border-color: rgb(43,214,66); + margin: 0.5em; + border-style: solid; + border-width: 0 0 0 1em; + padding: 0 0.3em; + border-style: solid; +} +.memu { + border-color: rgb(249,134,33); + margin: 0.5em; + border-style: solid; + border-width: 0 0 0 1em; + padding: 0 0.3em; + border-style: solid; +} diff --git a/templates/main.html b/templates/main.html index 0d1859d..94c37ff 100644 --- a/templates/main.html +++ b/templates/main.html @@ -2,7 +2,7 @@ - + {% block title %}PyDash v{{ version }}{% endblock %} @@ -114,7 +114,11 @@

- + +
+ {% trans "Free" %} + {% trans "Used" %} +
diff --git a/usage/views.py b/usage/views.py index 7d896ba..3a58ac4 100755 --- a/usage/views.py +++ b/usage/views.py @@ -229,7 +229,9 @@ def memusage(request): """ Return Memory Usage in % and numeric """ - datasets = [] + datasets_free = [] + datasets_used = [] + cookie_memory = {} try: mem_usage = get_mem() @@ -242,26 +244,40 @@ def memusage(request): cookies = None if not cookies: - datasets.append(0) + datasets_free.append(0) + datasets_used.append(0) else: datasets = json.loads(cookies) - if len(datasets) > 10: - while datasets: - del datasets[0] - if len(datasets) == 10: + datasets_free = datasets[0] + datasets_used = datasets[1] + + if len(datasets_free) > 10: + while datasets_free: + del datasets_free[0] + if len(datasets_free) == 10: break - if len(datasets) <= 9: - datasets.append(int(mem_usage['usage'])) - if len(datasets) == 10: - datasets.append(int(mem_usage['usage'])) - del datasets[0] + if len(datasets_used) > 10: + while datasets_used: + del datasets_used[0] + if len(datasets_used) == 10: + break + if len(datasets_free) <= 9: + datasets_free.append(int(mem_usage['free'])) + if len(datasets_free) == 10: + datasets_free.append(int(mem_usage['free'])) + del datasets_free[0] + if len(datasets_used) <= 9: + datasets_used.append(int(mem_usage['usage'])) + if len(datasets_used) == 10: + datasets_used.append(int(mem_usage['usage'])) + del datasets_used[0] # Some fix division by 0 Chart.js - if len(datasets) == 10: - if sum(datasets) == 0: - datasets[9] += 0.1 - if sum(datasets) / 10 == datasets[0]: - datasets[9] += 0.1 + if len(datasets_free) == 10: + if sum(datasets_free) == 0: + datasets_free[9] += 0.1 + if sum(datasets_free) / 10 == datasets_free[0]: + datasets_free[9] += 0.1 memory = { 'labels': [""] * 10, @@ -271,15 +287,23 @@ def memusage(request): "strokeColor": "rgba(249,134,33,1)", "pointColor": "rgba(249,134,33,1)", "pointStrokeColor": "#fff", - "data": datasets + "data": datasets_used + }, + { + "fillColor": "rgba(43,214,66,0.5)", + "strokeColor": "rgba(43,214,66,1)", + "pointColor": "rgba(43,214,66,1)", + "pointStrokeColor": "#fff", + "data": datasets_free } ] } + cookie_memory = [datasets_free, datasets_used] data = json.dumps(memory) response = HttpResponse() response['Content-Type'] = "text/javascript" - response.cookies['memory_usage'] = datasets + response.cookies['memory_usage'] = cookie_memory response.write(data) return response From 6c0cc5addcdbc82ead977f6454bc75840cc1f1f9 Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 11 Mar 2014 22:20:54 -0400 Subject: [PATCH 21/27] Add free mem to graphs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0e0121..c6d8875 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -pyDash - v1.4.2 +pyDash - v1.4.3 ====== A small web-based monitoring dashboard for your linux pc/server writen in Python and Django + Chart.js. From 434afc663bd0f8238b14b39efebf5f1131c6c71b Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 11 Mar 2014 22:20:59 -0400 Subject: [PATCH 22/27] Update settings.py --- pydash/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydash/settings.py b/pydash/settings.py index a064ebf..1000368 100644 --- a/pydash/settings.py +++ b/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)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False From 08a9f6d6ec5fd84bc80d7449217e6675dbed35d5 Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 11 Mar 2014 22:49:23 -0400 Subject: [PATCH 23/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6d8875..a214873 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,6 @@ Credits [Font Awesome](http://fontawesome.io/) -Follow [@hostechs](https://twitter.com/hostechs) on Twitter +[![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) [![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/2630601/k3onipydash-on-GitHub "Flattr this") From 8ac0f09aecace2d8c21092eaaaa915adccd8c27f Mon Sep 17 00:00:00 2001 From: Florian N Date: Fri, 14 Mar 2014 14:57:13 -0400 Subject: [PATCH 24/27] Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a214873..882c970 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ -pyDash - v1.4.3 +pyDash - v1.4.3 | [![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) ====== + +[![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/2630601/k3onipydash-on-GitHub "Flattr this") + + A small web-based monitoring dashboard for your linux pc/server writen in Python and Django + Chart.js. The dashboard is built using only Python libraries available in the main Python distribution, trying to create a small list of dependencies without the need of installing many packages or libraries. @@ -67,8 +71,3 @@ Credits [Dashboard Template](http://www.egrappler.com/templatevamp-free-twitter-bootstrap-admin-template/), [Bootstrap](http://getbootstrap.com/), [Font Awesome](http://fontawesome.io/) - - -[![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) - -[![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/2630601/k3onipydash-on-GitHub "Flattr this") From 152536502cced2fc1ba610212c81b8dc20dc6fca Mon Sep 17 00:00:00 2001 From: Florian N Date: Fri, 14 Mar 2014 14:58:19 -0400 Subject: [PATCH 25/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 882c970..1cc2891 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -pyDash - v1.4.3 | [![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) +pyDash - v1.4.3 [![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) ====== From cf5a83e18e6b60dc12395fb858f9612ca185c25d Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 18 Mar 2014 21:10:51 -0400 Subject: [PATCH 26/27] change how we get IP data --- main/views.py | 46 +++++++++++++++++++++--------------------- pydash/settings.py | 4 ++-- static/js/dashboard.js | 4 ++-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/main/views.py b/main/views.py index 2cad2fe..f30e552 100755 --- a/main/views.py +++ b/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(): diff --git a/pydash/settings.py b/pydash/settings.py index 1000368..eca49ad 100644 --- a/pydash/settings.py +++ b/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 = ['*'] diff --git a/static/js/dashboard.js b/static/js/dashboard.js index a2eb107..ad0d12c 100644 --- a/static/js/dashboard.js +++ b/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, From b026af9c192edfe48a549fb5e304bc98c8acfcb5 Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 18 Mar 2014 21:13:57 -0400 Subject: [PATCH 27/27] change how we get IP data --- README.md | 2 +- pydash/settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1cc2891..90dc94f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -pyDash - v1.4.3 [![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) +pyDash - v1.4.4 [![Follow @hostechs](https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_32.png)](https://twitter.com/hostechs) [![View Profile](https://dlc1-s.licdn.com/sites/default/files/InBug-30px-R.png)](http://www.linkedin.com/in/hostechs/) ====== diff --git a/pydash/settings.py b/pydash/settings.py index eca49ad..b8942ff 100644 --- a/pydash/settings.py +++ b/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)23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af' +SECRET_KEY = '1)$crmowu-23tz@i2-d=7tb3t+1u&(pm!lnjyuarki^72h!3af' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False