Browse Source

Merge pull request #3 from gzog/movapp

Converted pydash to a django app.
windows^2
Florian N 12 years ago
parent
commit
e2e74ea195
  1. 90
      README.md
  2. 0
      example/example/__init__.py
  3. 135
      example/example/settings.py
  4. 4
      example/example/urls.py
  5. 4
      example/example/wsgi.py
  6. 2
      example/manage.py
  7. 1
      example/pydash
  8. 81
      pydash/services.py
  9. 151
      pydash/settings.py
  10. 0
      pydash/static/css/bootstrap-responsive.min.css
  11. 0
      pydash/static/css/bootstrap.min.css
  12. 0
      pydash/static/css/dashboard.css
  13. 0
      pydash/static/css/font-awesome.css
  14. 0
      pydash/static/css/fonts.css
  15. 0
      pydash/static/css/signin.css
  16. 0
      pydash/static/css/style.css
  17. 0
      pydash/static/fonts/MTP_ySUJH_bn48VBG8sNSnhCUOGz7vYGh680lGh-uXM.woff
  18. 0
      pydash/static/fonts/MTP_ySUJH_bn48VBG8sNSonF5uFdDttMLvmWuJdhhgs.ttf
  19. 0
      pydash/static/fonts/PRmiXeptR36kaC0GEAetxi8cqLH4MEiSE0ROcU-qHOA.ttf
  20. 0
      pydash/static/fonts/PRmiXeptR36kaC0GEAetxn5HxGBcBvicCpTp6spHfNo.woff
  21. 0
      pydash/static/fonts/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff
  22. 0
      pydash/static/fonts/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf
  23. 0
      pydash/static/fonts/fontawesome-webfont.eot
  24. 0
      pydash/static/fonts/fontawesome-webfont.svg
  25. 0
      pydash/static/fonts/fontawesome-webfont.ttf
  26. 0
      pydash/static/fonts/fontawesome-webfont.woff
  27. 0
      pydash/static/fonts/glyphicons-halflings-regular.eot
  28. 0
      pydash/static/fonts/glyphicons-halflings-regular.svg
  29. 0
      pydash/static/fonts/glyphicons-halflings-regular.ttf
  30. 0
      pydash/static/fonts/glyphicons-halflings-regular.woff
  31. 0
      pydash/static/fonts/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff
  32. 0
      pydash/static/fonts/xjAJXh38I15wypJXxuGMBp0EAVxt0G0biEntp43Qt6E.ttf
  33. 0
      pydash/static/img/asc.gif
  34. 0
      pydash/static/img/bg.gif
  35. 0
      pydash/static/img/desc.gif
  36. 0
      pydash/static/img/favicon.ico
  37. 0
      pydash/static/img/icons-sa7c41345d9.png
  38. 0
      pydash/static/js/Chart.min.js
  39. 0
      pydash/static/js/base.js
  40. 0
      pydash/static/js/bootstrap-multiselect.js
  41. 0
      pydash/static/js/bootstrap.js
  42. 0
      pydash/static/js/bootstrap.min.js
  43. 22
      pydash/static/js/dashboard.js
  44. 0
      pydash/static/js/excanvas.js
  45. 0
      pydash/static/js/jquery.dataTables.min.js
  46. 0
      pydash/static/js/jquery.js
  47. 0
      pydash/templates/base_auth.html
  48. 2
      pydash/templates/login.html
  49. 0
      pydash/templates/logout.html
  50. 65
      pydash/templates/main.html
  51. 46
      pydash/urls.py
  52. 111
      pydash/views.py
  53. 0
      usage/__init__.py

90
README.md

@ -5,15 +5,12 @@ pyDash - v1.4.4 [![Follow @hostechs](https://dev.twitter.com/sites/default/file
[![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.
A reusable django app for monitoring your linux server.
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.
Supported Python versions:
Current dependencies:
- == Django 1.6.1
- == Python 2.x
- Python 2.x
__[View Demo](http://pydash.hostechs.com/)__
@ -27,25 +24,92 @@ __[View Demo](http://pydash.hostechs.com/)__
Installation
============
###[Installing pyDash](https://github.com/k3oni/pydash/wiki)
Clone the repository to your pc and copy the pydash folder to your django application.
Make sure that ``django.contrib.auth`` is installed and working.
Open your project's ``settings.py`` and add ``pydash`` to ``INSTALLED_APPS``:
INSTALLED_APPS = (
'pydash',
)
Open your project's ``urls.py`` and include the ``pydash`` urls.
urlpatterns = patterns('',
(r'^pydash/', include('pydash.urls')),
)
Make sure ``AppDirectoriesFinder`` is enabled in your ``STATICFILES_FINDERS``:
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
Before deploying to a live server, run the following command in order to collect the static files stored in pydash's directory:
$ python manage.py collectstatic
Settings
========
###[pyDash settings](https://github.com/k3oni/pydash/wiki/Settings)
There are 3 different refresh settings which are measured in `miliseconds`:
TIME_JS_REFRESH = 30000 #30 seconds
TIME_JS_REFRESH_LONG = 120000 #120 seconds
TIME_JS_REFRESH_NET = 2000 #2 seconds
If you wish to override the default settings, simply set those fields with the new values in your application's ``settings.py`` file.
The refresh settings for each table are as follows:
Memory Usage - TIME_JS_REFRESH
Load Average - TIME_JS_REFRESH
CPU Usage - TIME_JS_REFRESH
Traffic Usage - TIME_JS_REFRESH_NET
Disk Reads/Writes - TIME_JS_REFRESH_NET
Uptime - TIME_JS_REFRESH_LONG
Disk Usage - TIME_JS_REFRESH_LONG
Online Users - TIME_JS_REFRESH_LONG
Processes - TIME_JS_REFRESH_LONG
Netstat - TIME_JS_REFRESH_LONG
Remote data retrieval
=====================
###[pyDash remote data retrieval](https://github.com/k3oni/pydash/wiki/Remote-data-retreival)
pyDash allows you to retrieve data remotely.
Data is returned in JSON and can be easily retrieved as long as the user agent has been authenticated by the web application. For more information about how sessions are managed in Django, please click [here](https://docs.djangoproject.com/en/1.6/topics/http/sessions/).
pyDash has a list of short URLs which you can use to retrieve the specific data:
/info/uptime/ - Uptime
/info/platform/hostname/ - Hostname
/info/platform/osname/ - OS Name
/info/platform/kernel/ - Kernel
/info/getcpus/cpucount/ - Number of CPU cores
/info/getcpus/cputype/ - Type/Name of CPU
/info/memory/ - Memory Usage
/info/cpuusage/ - CPU Usage in percentage(%), free and used
/info/getdisk/ - Disk Usage
/info/getusers/ - Online Users
/info/getips/ - IP Addresses
/info/gettraffic/ - Internet Traffic
/info/getdiskio/ - Disk Reads/Writes
/info/proc/ - Running Processes
/info/loadaverage/ - Load Average
/info/getnetstat/ - Netstat
To see the format of the JSON returned, you can access any of the URLs from your browser, e.g. `http://demo.pydash.net/info/uptime/` .
OS Support
==========
pyDash was tested and runs under the following OSs:
pyDash was tested and runs under the following OSes:
- Centos
- Fedora
- Ubuntu
@ -55,7 +119,7 @@ pyDash was tested and runs under the following OSs:
- Arch Linux
Might work under others, but didn't get to test any other OSs just yet.
It might work under others, but it hasn't been tested yet.
@ -68,6 +132,6 @@ License
Credits
=======
[Dashboard Template](http://www.egrappler.com/templatevamp-free-twitter-bootstrap-admin-template/),
[Bootstrap](http://getbootstrap.com/),
[Dashboard Template](http://www.egrappler.com/templatevamp-free-twitter-bootstrap-admin-template/),
[Bootstrap](http://getbootstrap.com/),
[Font Awesome](http://fontawesome.io/)

main/__init__.py → example/example/__init__.py

135
example/example/settings.py

@ -0,0 +1,135 @@
"""
Django settings for pydash project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SITE_ID = 1
# Quick-start development settings - unsuitable for production
# 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'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ADMINS = (
)
MANAGERS = ADMINS
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Add pydash here
'pydash'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'example.urls'
WSGI_APPLICATION = 'example.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3')
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_ROOT = os.path.join(os.path.dirname(__file__), '..', 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
try:
from local_settings import *
except ImportError:
pass

4
example/example/urls.py

@ -0,0 +1,4 @@
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^pydash/', include('pydash.urls')))

pydash/wsgi.py → example/example/wsgi.py

manage.py → example/manage.py

1
example/pydash

@ -0,0 +1 @@
../pydash

main/views.py → pydash/services.py

151
pydash/settings.py

@ -1,143 +1,8 @@
"""
Django settings for pydash project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SITE_ID = 1
# Quick-start development settings - unsuitable for production
# 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'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
TEMPLATE_DEBUG = False
ADMINS = (
)
MANAGERS = ADMINS
#All refresh values are in miliseconds, 1 second = 1000 miliseconds
#Adjust accordingly as you wish
TIME_JS_REFRESH = 30000
TIME_JS_REFRESH_LONG = 120000
TIME_JS_REFRESH_NET = 2000
VERSION = "1.4.4"
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
#'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
#'django.contrib.sites',
'django.contrib.staticfiles',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'pydash.urls'
WSGI_APPLICATION = 'pydash.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3')
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_ROOT = os.path.join(os.path.dirname(__file__), '..', 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
try:
from local_settings import *
except ImportError:
pass
from django.conf import settings
# All of the refresh values are in miliseconds, 1 second = 1000 miliseconds
# Adjust accordingly as you wish, preferably in your application's settings.py.
TIME_JS_REFRESH = getattr(settings, 'TIME_JS_REFRESH', 30000)
TIME_JS_REFRESH_LONG = getattr(settings, 'TIME_JS_REFRESH_LONG', 120000)
TIME_JS_REFRESH_NET = getattr(settings, 'TIME_JS_REFRESH_NET', 2000)
_VERSION = '1.4.4'

static/css/bootstrap-responsive.min.css → pydash/static/css/bootstrap-responsive.min.css

static/css/bootstrap.min.css → pydash/static/css/bootstrap.min.css

static/css/dashboard.css → pydash/static/css/dashboard.css

static/css/font-awesome.css → pydash/static/css/font-awesome.css

static/css/fonts.css → pydash/static/css/fonts.css

static/css/signin.css → pydash/static/css/signin.css

static/css/style.css → pydash/static/css/style.css

static/fonts/MTP_ySUJH_bn48VBG8sNSnhCUOGz7vYGh680lGh-uXM.woff → pydash/static/fonts/MTP_ySUJH_bn48VBG8sNSnhCUOGz7vYGh680lGh-uXM.woff

static/fonts/MTP_ySUJH_bn48VBG8sNSonF5uFdDttMLvmWuJdhhgs.ttf → pydash/static/fonts/MTP_ySUJH_bn48VBG8sNSonF5uFdDttMLvmWuJdhhgs.ttf

static/fonts/PRmiXeptR36kaC0GEAetxi8cqLH4MEiSE0ROcU-qHOA.ttf → pydash/static/fonts/PRmiXeptR36kaC0GEAetxi8cqLH4MEiSE0ROcU-qHOA.ttf

static/fonts/PRmiXeptR36kaC0GEAetxn5HxGBcBvicCpTp6spHfNo.woff → pydash/static/fonts/PRmiXeptR36kaC0GEAetxn5HxGBcBvicCpTp6spHfNo.woff

static/fonts/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff → pydash/static/fonts/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff

static/fonts/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf → pydash/static/fonts/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf

static/fonts/fontawesome-webfont.eot → pydash/static/fonts/fontawesome-webfont.eot

static/fonts/fontawesome-webfont.svg → pydash/static/fonts/fontawesome-webfont.svg

static/fonts/fontawesome-webfont.ttf → pydash/static/fonts/fontawesome-webfont.ttf

static/fonts/fontawesome-webfont.woff → pydash/static/fonts/fontawesome-webfont.woff

static/fonts/glyphicons-halflings-regular.eot → pydash/static/fonts/glyphicons-halflings-regular.eot

static/fonts/glyphicons-halflings-regular.svg → pydash/static/fonts/glyphicons-halflings-regular.svg

static/fonts/glyphicons-halflings-regular.ttf → pydash/static/fonts/glyphicons-halflings-regular.ttf

static/fonts/glyphicons-halflings-regular.woff → pydash/static/fonts/glyphicons-halflings-regular.woff

static/fonts/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff → pydash/static/fonts/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff

static/fonts/xjAJXh38I15wypJXxuGMBp0EAVxt0G0biEntp43Qt6E.ttf → pydash/static/fonts/xjAJXh38I15wypJXxuGMBp0EAVxt0G0biEntp43Qt6E.ttf

static/img/asc.gif → pydash/static/img/asc.gif

static/img/bg.gif → pydash/static/img/bg.gif

static/img/desc.gif → pydash/static/img/desc.gif

static/img/favicon.ico → pydash/static/img/favicon.ico

static/img/icons-sa7c41345d9.png → pydash/static/img/icons-sa7c41345d9.png

static/js/Chart.min.js → pydash/static/js/Chart.min.js

static/js/base.js → pydash/static/js/base.js

static/js/bootstrap-multiselect.js → pydash/static/js/bootstrap-multiselect.js

static/js/bootstrap.js → pydash/static/js/bootstrap.js

static/js/bootstrap.min.js → pydash/static/js/bootstrap.min.js

static/js/dashboard.js → pydash/static/js/dashboard.js

static/js/excanvas.js → pydash/static/js/excanvas.js

static/js/jquery.dataTables.min.js → pydash/static/js/jquery.dataTables.min.js

static/js/jquery.js → pydash/static/js/jquery.js

templates/base_auth.html → pydash/templates/base_auth.html

templates/login.html → pydash/templates/login.html

templates/logout.html → pydash/templates/logout.html

templates/main.html → pydash/templates/main.html

46
pydash/urls.py

@ -1,35 +1,21 @@
from django.conf.urls import patterns, url
from django.conf import settings
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'pydash.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'main.views.index', name='index'),
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'},
url(r'^$', 'pydash.views.index', name='index'),
url(r'login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'},
name='login'),
url(r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'logout.html'},
url(r'logout/$', 'django.contrib.auth.views.logout', {'template_name': 'logout.html'},
name='logout'),
url(r'^main/$', 'main.views.getall', name='main'),
url(r'^info/uptime/$', 'usage.views.uptime', name='uptime'),
url(r'^info/memory/$', 'usage.views.memusage', name='memusage'),
url(r'^info/cpuusage/$', 'usage.views.cpuusage', name='cpuusage'),
url(r'^info/getdisk/$', 'usage.views.getdisk', name='getdisk'),
url(r'^info/getusers/$', 'usage.views.getusers', name='getusers'),
url(r'^info/getips/$', 'usage.views.getips', name='getips'),
url(r'^info/gettraffic/$', 'usage.views.gettraffic', name='gettraffic'),
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'))
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}))
url(r'info/uptime/$', 'pydash.views.uptime', name='uptime'),
url(r'info/memory/$', 'pydash.views.memusage', name='memusage'),
url(r'info/cpuusage/$', 'pydash.views.cpuusage', name='cpuusage'),
url(r'info/getdisk/$', 'pydash.views.getdisk', name='getdisk'),
url(r'info/getusers/$', 'pydash.views.getusers', name='getusers'),
url(r'info/getips/$', 'pydash.views.getips', name='getips'),
url(r'info/gettraffic/$', 'pydash.views.gettraffic', name='gettraffic'),
url(r'info/proc/$', 'pydash.views.getproc', name='getproc'),
url(r'info/getdiskio/$', 'pydash.views.getdiskio', name='getdiskio'),
url(r'info/loadaverage/$', 'pydash.views.loadaverage', name='loadaverage'),
url(r'info/platform/([\w\-\.]+)/$', 'pydash.views.platform', name='platform'),
url(r'info/getcpus/([\w\-\.]+)/$', 'pydash.views.getcpus', name='getcpus'),
url(r'info/getnetstat/$', 'pydash.views.getnetstat', name='getnetstat'))

usage/views.py → pydash/views.py

0
usage/__init__.py

Loading…
Cancel
Save