From 50c97558c1541bcc35175fd75ababa2b244a0976 Mon Sep 17 00:00:00 2001 From: Florian N Date: Tue, 11 Mar 2014 22:20:08 -0400 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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