Permalink
Browse files

* Initial import to Git

  • Loading branch information...
Alex de Landgraaf
Alex de Landgraaf committed Mar 20, 2010
0 parents commit 34cecc8d2f99474f7543999d6cb495dd98afc76f
Showing 893 changed files with 130,394 additions and 0 deletions.
12 LICENSE
@@ -0,0 +1,12 @@
+BSD 3-clause license: http://www.opensource.org/licenses/bsd-license.php
+
+Copyright (c) 2010, Alex de Landgraaf
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120 README
@@ -0,0 +1,120 @@
+
+Welcome to Django Bingo!
+
+Django Bingo is a collection of Django applications that together allows you to provide professional dashboards and
+(in the future) other types of reporting to your users. It is licensed under the BSD license, the same as Django.
+
+Django Bingo isn't a full-blown "Business Intelligence" suite. Yet. It does allow you to plot your data into pretty
+graphs, which is probably what most people see as BI. ETL, Data warehousing? You'll have to roll your own for now!
+
+WARNING: This software is mostly a dump of ideas and code. It is neither neat nor secure. It might gobble up your kitten.
+
+==== Install to an existing project ====
+
+ * Copy the following application directories to your project:
+
+ - querybuilder
+ - dashboard
+
+ * Copy the media/dashboard directory to your own media directory (ie. it should be accessable via settings.MEDIA_URL).
+ This provides the various javascript libraries and css.
+
+ * Add 'querybuilder' and 'dashboard' to your INSTALLED_APPS in settings.py. Also add 'django.contrib.auth' if you haven't
+ yet done so as we use it for restricting access to your pretty dashboard.
+
+ * Add the following URLs to your top-level url.py:
+
+ (r'^querybuilder/', include('querybuilder.urls')),
+ (r'^dashboard/', include('dashboard.urls')),
+ (r'^accounts/login/$', 'django.contrib.auth.views.login'),
+ (r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'),
+ (r'^accounts/profile/$', 'django.views.generic.simple.redirect_to', {'url': '/'}),
+
+ * You can now access the Django Bingo dashboard:
+
+ www.mydjangoinstall.com/dashboard/
+
+ * By default you need to be logged in to view the dashboard. To enter design-mode and modify the dashboard you require
+ a superuser account. In the future we'll do this via auth.permissions.
+
+==== Use Django Bingo as a separate project ====
+
+You might have noticed that Django Bingo includes a project of its own. This allows you to try out Django Bingo
+directly, without having to install it to your existing project.
+
+To use this project, either run python manage.py runserver or modify your web server to run Django Bingo via django.wsgi.
+You will have to do a python manage.py syncdb first to initialize an SQLite database.
+
+The following simple applications are provided so you can experiment right away:
+
+ Ping - pings a number of hosts in a round-robin fashion and stores the responses.
+ Add hosts to PingHosts via /admin/ping
+ To run: 'python action_daemon_ping.py'
+
+ Status - stores various system status data
+ To run: 'python action_daemon_status.py'
+
+You will need to run one of these scripts for a while to collect a bit of data. Plotting an empty database isn't fun.
+You might need to modify the provided settings.py for your environment, YMMV.
+
+In the future we'll provide a pre-configured dashboard for both applications. For now, these are merely useful for
+generating test-data.
+
+Note: run do_env.sh to set up the 'env' virtualenv directory, very useful if you require multiple versions of Python
+libraries.
+
+==== Setting up a dashboard automagically ====
+
+The easiest way is to enter design-mode, add a dashboard and initialize it using the
+"Initialize dashboard from application" button. This provides a simple wizard to auto-configure a number of graphs
+and tables for a selection of models. It probably isn't what you want, but it does set up a number of queries via
+the Query Builder and hooks these up to elements in the Dashboard application. See it as a starting point for now.
+
+==== Dashboard design mode ====
+
+Drag-and-drop elements and hit 'Apply layout' to change your dashboard.
+
+'Add element' to create a new Graph or Table. You'll probably need to set up a Data Selection for this element first.
+
+Use the 'edit' link below each element to modify the element and its underlying Data Selection.
+
+==== Excel output ====
+
+Included in contrib is the excellent xlwt library. Install it if you want Excel output, see querybuilder/excel.py for
+details.
+
+== Background ==
+
+==== Query builder ====
+
+The query builder application is used to set up queries (DataSelection objects) with which you can retrieve QuerySets
+from other Django applications. It works without having to write any code, the configuration of a query is stored
+directly in the database.
+
+Each DataSelection has a number of DataColumns. These are usually auto-generated from your Django application by
+introspecting the models, but you can also specify your own (if you want). By calling 'get_data()' on your DataSelection
+you obtain the QuerySet you specified.
+
+You might have a Manager that you would like to use for your model. Query builder doesn't introspect Managers yet, but
+if you specify a 'manager_method' for a DataSelection it will be used instead of 'Model.objects.all()'. In the future
+query builder will become even smarter, for instance by allowing you to query databases without requiring a Django
+application associated to it.
+
+==== Dashboard ====
+
+The dashboard application uses Query Builder for generating graphs and tables. Various options are available for both
+types of elements, and periodically refreshing elements is also possible. The Table element currently also provides
+embedded mini-graphs, providing you with sparklines and barplots within a table.
+
+In the future more types of elements will be available.
+
+== Further details ==
+
+See docs for an overview and screenshots!
+
+Contact me via email (alex-bingo at aperte dot nl) or check out aperte-it.com (my company website) and alextreme.org.
+
+
+
+
+
No changes.
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+from django.core.management import setup_environ
+import settings
+setup_environ(settings)
+import time
+import ping.ping as pinger
+import logging
+
+from ping.models import PingHost, PingResult
+
+while True:
+ ping_hosts = PingHost.objects.filter(active = True)
+ time.sleep(5)
+ for ping_host in ping_hosts:
+ logging.debug(u"Pinging: " + ping_host.hostname)
+ result = pinger.ping(ping_host.hostname)
+ if result != False:
+ logging.debug(u"Ping success:")
+ logging.debug(result)
+ p_result = PingResult(min_delay = result[0], avg_delay = result[1], max_delay = result[2], stddev = result[3])
+ p_result.host = ping_host
+ p_result.save()
+ else:
+ logging.debug(u"Ping failed!")
+ time.sleep(2)
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+from django.core.management import setup_environ
+import settings
+setup_environ(settings)
+import time
+import logging
+import statgrab
+
+from status.models import *
+
+kb = 1024
+mb = kb * kb
+
+while True:
+ ### Host data ###
+
+ cpu = statgrab.sg_get_cpu_percents()
+ load = statgrab.sg_get_load_stats()
+ host = statgrab.sg_get_host_info()
+ mem = statgrab.sg_get_mem_stats()
+ hs = HostStats(hostname = host['hostname'], uptime = host['uptime'], arch = host['platform'], min1 = str(load['min1']), min5 = str(load['min5']), min15 = str(load['min15']), mem_total = mem['total'] / mb, mem_free = (mem['cache'] + mem['free']) / mb, mem_used = mem['used'] / mb)
+ hs.save()
+ ### FS data ###
+
+ filesystems = statgrab.sg_get_fs_stats()
+ for fs in filesystems:
+ fs_stat = FilesystemStats(device = fs['device_name'], used_perc = str(float(fs['used']) / float(fs['size']) * 100.0), size = fs['size'] / mb, used = fs['used'] / mb, avail = fs['avail'] / mb, fs_type = fs['fs_type'])
+ fs_stat.save()
+ ### Network data ###
+ statgrab.sg_get_network_io_stats()
+ time.sleep(1) # Collect data over 1 second
+ diff = statgrab.sg_get_network_io_stats_diff()
+ netstats = statgrab.sg_get_network_iface_stats()
+ for iface in diff:
+ for netstat in netstats:
+ if iface['interface_name'] == netstat['interface_name']:
+ ns = NetworkStats(interface = iface['interface_name'], up = netstat['up'], tx = iface['tx'] / kb, rx = iface['rx'] / kb)
+ ns.save()
+ time.sleep(1)
Oops, something went wrong.

0 comments on commit 34cecc8

Please sign in to comment.