diff options
Diffstat (limited to 'reports/brpt')
28 files changed, 727 insertions, 0 deletions
diff --git a/reports/brpt/__init__.py b/reports/brpt/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/reports/brpt/__init__.py diff --git a/reports/brpt/__init__.pyc b/reports/brpt/__init__.pyc Binary files differnew file mode 100644 index 000000000..57e9107ae --- /dev/null +++ b/reports/brpt/__init__.pyc diff --git a/reports/brpt/manage.py b/reports/brpt/manage.py new file mode 100755 index 000000000..5e78ea979 --- /dev/null +++ b/reports/brpt/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/reports/brpt/reports/__init__.py b/reports/brpt/reports/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/reports/brpt/reports/__init__.py diff --git a/reports/brpt/reports/__init__.pyc b/reports/brpt/reports/__init__.pyc Binary files differnew file mode 100644 index 000000000..1d697e5f3 --- /dev/null +++ b/reports/brpt/reports/__init__.pyc diff --git a/reports/brpt/reports/models.py b/reports/brpt/reports/models.py new file mode 100644 index 000000000..ac3506214 --- /dev/null +++ b/reports/brpt/reports/models.py @@ -0,0 +1,128 @@ +from django.db import models +#from timedelta import timedelta +from datetime import datetime, timedelta +# Create your models here. +KIND_CHOICES = ( + ('ConfigFile', 'ConfigFile'), + ('Package', 'Package'), + ('Service', 'Service'), + ('SymLink', 'SymLink'), + ('Directory', 'Directory'), + ('Permissions','Permissions'), +) + +class Client(models.Model): + #This exists for clients that are no longer in the repository even! (timeless) + creation = models.DateTimeField() + name = models.CharField(maxlength=128) + def __str__(self): + return self.name + + class Admin: + pass + + +class Metadata(models.Model): + client = models.ForeignKey(Client) + timestamp = models.DateTimeField() + #INSERT magic interface to Metadata HERE + def __str__(self): + return self.timestamp + +class Repository(models.Model): + timestamp = models.DateTimeField() + #INSERT magic interface to any other config info here... + def __str__(self): + return self.timestamp + + +#models each client-interaction +class Interaction(models.Model): + client = models.ForeignKey(Client, related_name="interactions", core=True) + timestamp = models.DateTimeField()#Timestamp for this record + state = models.CharField(maxlength=32)#good/bad/modified/etc + repo_revision = models.IntegerField()#you got it. the repo in use at time of client interaction + client_version = models.CharField(maxlength=32)#really simple; version of client running + pingable = models.BooleanField()#This is (was-pingable)status as of last attempted interaction + goodcount = models.IntegerField()#of good config-items we store this number, because we don't count the + totalcount = models.IntegerField()#of total config-items specified--grab this from metadata instead? + + def __str__(self): + return "With " + self.client.name + " @ " + self.timestamp.isoformat() + + def percentgood(self): + return (self.goodcount/self.totalcount)*100 + + def percentbad(self): + return (self.totalcount-self.goodcount)/(self.totalcount) + + def isclean(self): + if (self.bad_items.count() == 0 and self.extra_items.count() == 0 and self.goodcount == self.totalcount): + #if (self.state == "good"): + return True + else: + return False + + def isstale(self): + if (self == self.client.interactions.order_by('-timestamp')[0]):#Is Mostrecent + if(datetime.now()-self.timestamp > timedelta(hours=25) ): + return True + else: + return False + else: + #Search for subsequent Interaction for this client + #Check if it happened more than 25 hrs ago. + if (self.client.interactions.filter(timestamp__gt=self.timestamp) + .order_by('timestamp')[0].timestamp - self.timestamp > timedelta(hours=25)): + return True + else: + return False + + + class Admin: + list_display = ('client', 'timestamp', 'state') + list_filter = ['client', 'timestamp'] + pass + + + + +class Modified(models.Model): + interaction = models.ForeignKey(Interaction, related_name="modified_items", edit_inline=models.STACKED) + name = models.CharField(maxlength=128, core=True)#name of modified thing. + kind = models.CharField(maxlength=16, choices=KIND_CHOICES)#Service/Package/ConfgFile... + how = models.CharField(maxlength=256) + def __str__(self): + return self.name + + + +class Extra(models.Model): + interaction = models.ForeignKey(Interaction, related_name="extra_items", edit_inline=models.STACKED) + name = models.CharField(maxlength=128, core=True)#name of Extra thing. + kind = models.CharField(maxlength=16, choices=KIND_CHOICES)#Service/Package/ConfgFile... + why = models.CharField(maxlength=256)#current state of some thing... + def __str__(self): + return self.name + + + +class Bad(models.Model): + interaction = models.ForeignKey(Interaction, related_name="bad_items", edit_inline=models.STACKED) + name = models.CharField(maxlength=128, core=True)#name of bad thing. + kind = models.CharField(maxlength=16, choices=KIND_CHOICES)#Service/Package/ConfgFile... + reason = models.CharField(maxlength=256)#that its bad... + def __str__(self): + return self.name + + +#performance metrics, models a performance-metric-item +class Performance(models.Model): + interaction = models.ForeignKey(Interaction, related_name="performance_items", edit_inline=models.STACKED) + metric = models.CharField(maxlength=128, core=True) + value = models.FloatField(max_digits=32, decimal_places=16) + def __str__(self): + return self.metric + + + diff --git a/reports/brpt/reports/models.pyc b/reports/brpt/reports/models.pyc Binary files differnew file mode 100644 index 000000000..5d2c3cd75 --- /dev/null +++ b/reports/brpt/reports/models.pyc diff --git a/reports/brpt/reports/templates/base.html b/reports/brpt/reports/templates/base.html new file mode 100644 index 000000000..db242864e --- /dev/null +++ b/reports/brpt/reports/templates/base.html @@ -0,0 +1,46 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>{% block title %}Bcfg2 Reporting System{% endblock %}</title> + <link rel="stylesheet" type="text/css" href="/site_media/boxypastel.css" /> + <link rel="stylesheet" type="text/css" href="/site_media/base.css" /> + <script type="text/javascript" src="/site_media/main.js"> + </script> + {% block extra_header_info %}{% endblock %} +</head> + +<body> + <div id="header"> + <div id="branding"> + <h1>Bcfg2 Reporting System</h1> + </div> + <div id="user-tools">...Reporting into the future...</div> + </div> + <div id="sidebar"> + {% block sidebar %} + <ul class="sidebar"> + <li><a href="/" class="sidebar">Home</a></li> + <li><a href="/clients/" class="sidebar">Clients</a></li> + <li> + <a href="/displays/" class="sidebar">Displays</a> + <ul class="sidebar-level2"> + <li><a href="/displays/sys-view/" class="sidebar">System</a></li> + <li><a href="/displays/summary/" class="sidebar">Summary</a></li> + <li><a href="/displays/timing/" class="sidebar">Timing</a></li> + </ul> + </li> + </ul> + {% endblock %} + </div> + + <div id="content-main"> + <div id="container"> + {% block pagebanner %}{% endblock %} + {% block content %}{% endblock %} + + <br /><br /><p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p> + </div> + </div> +</body> +</html>
\ No newline at end of file diff --git a/reports/brpt/reports/templates/clients/client-nodebox.html b/reports/brpt/reports/templates/clients/client-nodebox.html new file mode 100644 index 000000000..12b53d899 --- /dev/null +++ b/reports/brpt/reports/templates/clients/client-nodebox.html @@ -0,0 +1,62 @@ +{% if client %} + <a name="{{client.name}}"></a> + <div class="nodebox" name="{{client.name}}"> + <span class="notebox">Time Ran: {{interaction.timestamp}}</span> + <span class="configbox">(-Insert Profile Name Here-)</span> + + <table class="invisitable"> + <tr><td width="43%"><h2>Node: <span class="nodename"> + <a href="/clients/{{client.name}}/{{interaction.id}}">{{client.name}}</a></span></h2></td> + <td width="23%"> + {% if interaction.repo_revision %}Revision: {{interaction.repo_revision}}{% endif %} + </td> + <td width="33%"><div class="statusborder"> + <div class="greenbar" style="width: {{interaction.percentgood}}%;"> </div> + <div class="redbar" style="width: {{interaction.percentbad}}%;"> </div> + </div> + </td></tr> + </table> + {% if interaction.isclean %} + <div class="clean"> + <span class="nodelisttitle">Node is clean; Everything has been satisfactorily configured.</span> + </div> + {% endif %} + {% if interaction.isstale %} + <div class="warning"> + <span class="nodelisttitle">This node did not run within the last 24 hours-- it may be out of date.</span> + </div> + {% endif %} + {% if interaction.bad_items.all %} + <div class="bad"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('{{client.name}}-bad');" title="Click to expand" class="commentLink">{{interaction.bad_items.count}}</a> items did not verify and are considered Dirty.<br /></span> + <div class="items" id="{{client.name}}-bad"><ul class="plain"> + {% for bad in interaction.bad_items.all %} {% comment %}HOWDOI? order_by('kind', 'name'){% endcomment %} + <li><strong>{{bad.kind}}: </strong><tt>{{bad.name}}</tt></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if interaction.modified_items.all %} + <div class="modified"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('{{client.name}}-modified');" title="Click to expand" class="commentLink">{{interaction.modified_items.count}}</a> items were modified in the last run.<br /></span> + <div class="items" id="{{client.name}}-modified"><ul class="plain"> + {% for modified in interaction.modified_items.all %} {% comment %}HOWDOI? order_by('kind', 'name'){% endcomment %} + <li><strong>{{modified.kind}}: </strong><tt>{{modified.name}}</tt></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if interaction.extra_items.all %} + <div class="extra"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('{{client.name}}-extra');" title="Click to expand" class="commentLink">{{interaction.extra_items.count}}</a> extra configuration elements on the node.<br /></span> + <div class="items" id="{{client.name}}-extra"><ul class="plain"> + {% for extra in interaction.extra_items.all %} {% comment %}HOWDOI? order_by('kind', 'name'){% endcomment %} + <li><strong>{{extra.kind}}: </strong><tt>{{extra.name}}</tt></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + </div> +{% else %} + <p>No record could be found for this client.</p> +{% endif %} diff --git a/reports/brpt/reports/templates/clients/detail.html b/reports/brpt/reports/templates/clients/detail.html new file mode 100644 index 000000000..4ac2123c1 --- /dev/null +++ b/reports/brpt/reports/templates/clients/detail.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %}Info for: {{client.name}}{% endblock %} + +{% block content %} +<b>Select time: </b> +<select name=quick onChange="MM_jumpMenu('parent',this,0)"> + {% for i in client.interactions.all %} + <option {% ifequal i.id interaction.id %}selected {% endifequal %} value="/clients/{{client.name}}/{{i.id}}/"> {{i.timestamp}} + {% endfor %} +</select> + +{% include "clients/client-nodebox.html" %} +{% endblock %} diff --git a/reports/brpt/reports/templates/clients/index.html b/reports/brpt/reports/templates/clients/index.html new file mode 100644 index 000000000..a474667b3 --- /dev/null +++ b/reports/brpt/reports/templates/clients/index.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block title %}Client Index Listing{% endblock %} + +{% block content %} +{% if client_list %} + <ul> + {% for client in client_list %} + <li><a href="{{client.name}}/">{{ client.name }}</a></li> + {% endfor %} + </ul> +{% else %} + <p>No client records are available.</p> +{% endif %} +{% endblock %} diff --git a/reports/brpt/reports/templates/displays/index.html b/reports/brpt/reports/templates/displays/index.html new file mode 100644 index 000000000..5d1d3bf76 --- /dev/null +++ b/reports/brpt/reports/templates/displays/index.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block title %}Display Index Listing{% endblock %} +{% block pagebanner %} + <div class="header"> + <h1>BCFG Display Index</h1> + {% comment %} <span class="notebox">Report Run @ {% now "F j, Y P"%}</span>{% endcomment %} + </div> + <br/> +{% endblock %} + +{% block content %} +<ul> +<li><a href="/displays/sys-view/">System View</a></li> +<li><a href="/displays/summary/">Summary Only</a></li> +<li><a href="/displays/timing/">Timing</a></li> +</ul> +{% endblock %} diff --git a/reports/brpt/reports/templates/displays/summary-block-direct-links.html b/reports/brpt/reports/templates/displays/summary-block-direct-links.html new file mode 100644 index 000000000..a218e12b6 --- /dev/null +++ b/reports/brpt/reports/templates/displays/summary-block-direct-links.html @@ -0,0 +1,7 @@ +{% extends "displays/summary-block.html" %} +{% block linkprefix1 %}/clients/{% endblock %} +{% block linkprefix2 %}/clients/{% endblock %} +{% block linkprefix3 %}/clients/{% endblock %} +{% block linkprefix4 %}/clients/{% endblock %} +{% block linkprefix5 %}/clients/{% endblock %} +{% block linkprefix6 %}/clients/{% endblock %}
\ No newline at end of file diff --git a/reports/brpt/reports/templates/displays/summary-block.html b/reports/brpt/reports/templates/displays/summary-block.html new file mode 100644 index 000000000..3632cc870 --- /dev/null +++ b/reports/brpt/reports/templates/displays/summary-block.html @@ -0,0 +1,90 @@ +{% load django_templating_sigh %} + + <div class="nodebox"> + <h2>Summary:</h2> + <p class="indented">{{client_list|length }} Nodes were included in your report.</p> + {% if clean_client_list %} + <div class="clean"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('goodsummary');" title="Click to Expand" class="commentLink">{{clean_client_list|length}}</a> nodes are clean.<br /></span> + <div class="items" id="goodsummary"><ul class="plain"> + {% for client in clean_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="{% block linkprefix1 %}#{% endblock %}{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if bad_client_list %} + <div class="bad"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('badsummary');" title="Click to Expand" class="commentLink">{{bad_client_list|length}}</a> nodes are bad.<br /></span> + <div class="items" id="badsummary"><ul class="plain"> + {% for client in bad_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="{% block linkprefix2 %}#{% endblock %}{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if modified_client_list %} + <div class="modified"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('modifiedsummary');" title="Click to Expand" class="commentLink">{{modified_client_list|length}}</a> nodes were modified in the previous run.<br /></span> + <div class="items" id="modifiedsummary"><ul class="plain"> + {% for client in modified_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="{% block linkprefix3 %}#{% endblock %}{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if extra_client_list %} + <div class="extra"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('extrasummary');" title="Click to Expand" class="commentLink">{{extra_client_list|length}}</a> nodes have extra configuration. (includes both good and bad nodes)<br /></span> + <div class="items" id="extrasummary"><ul class="plain"> + {% for client in extra_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="{% block linkprefix4 %}#{% endblock %}{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if stale_up_client_list %} + <div class="warning"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('vstalesummary');" title="Click to Expand" class="commentLink">{{stale_up_client_list|length}}</a> nodes did not run within the last 24 hours but were pingable.<br /></span> + <div class="items" id="vstalesummary"><ul class="plain"> + {% for client in stale_up_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="{% block linkprefix5 %}#{% endblock %}{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if stale_all_client_list %} + <div class="all-warning"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('stalesummary');" title="Click to Expand" class="commentLink">{{stale_all_client_list|length}}</a> nodes did not run within the last 24 hours. (includes nodes up and down)<br /></span> + <div class="items" id="stalesummary"><ul class="plain"> + {% for client in stale_all_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="{% block linkprefix6 %}#{% endblock %}{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + {% if down_client_list %} + <div class="down"> + <span class="nodelisttitle"><a href="javascript:toggleLayer('unpingablesummary');" title="Click to Expand" class="commentLink">{{down_client_list|length}}</a> nodes were down.<br /></span> + <div class="items" id="unpingablesummary"><ul class="plain"> + {% for client in down_client_list %} + {% set_interaction "foo" %} + <li><b>Node: </b></tt> + <tt><a href="#{{client.name}}">{{client.name}}</a></tt><span class="mini-date">{{interaction.timestamp}}</span></li> + {% endfor %} + </ul></div> + </div> + {% endif %} + </div>
\ No newline at end of file diff --git a/reports/brpt/reports/templates/displays/summary.html b/reports/brpt/reports/templates/displays/summary.html new file mode 100644 index 000000000..f3c3c1339 --- /dev/null +++ b/reports/brpt/reports/templates/displays/summary.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %}Display Index Listing{% endblock %} +{% block pagebanner %} + <div class="header"> + <h1>BCFG Clients Summary</h1> + <span class="notebox">Report Run @ {% now "F j, Y P"%}</span> + </div> + <br/> +{% endblock %} + +{% block content %} + {% include "displays/summary-block-direct-links.html" %} +{% endblock %} diff --git a/reports/brpt/reports/templates/displays/sys_view.html b/reports/brpt/reports/templates/displays/sys_view.html new file mode 100644 index 000000000..bf80f545d --- /dev/null +++ b/reports/brpt/reports/templates/displays/sys_view.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} +{% load django_templating_sigh %} + +{% block title %}System-View Display{% endblock %} +{% block pagebanner %} + <div class="header"> + <h1>BCFG Performance Timings</h1> + <span class="notebox">Report Run @ {% now "F j, Y P"%}</span> + </div> + <br/> +{% endblock %} +{% block content %} + {% include "displays/summary-block.html" %} + {% for client in client_list %} + {% set_interaction "foo" %} + {% include "clients/client-nodebox.html" %} + {% endfor %} +{% endblock %} diff --git a/reports/brpt/reports/templates/displays/timing.html b/reports/brpt/reports/templates/displays/timing.html new file mode 100644 index 000000000..c3573851a --- /dev/null +++ b/reports/brpt/reports/templates/displays/timing.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + +{% block extra_header_info %} +<script type="text/javascript" src="/site_media/sorttable.js"> +</script>{% endblock%} +{% comment %} THIS ABOVE PART MAY BE SITE DEPENDENT-- CHANGE {% endcomment %} +{% block title %}Display Index Listing{% endblock %} + +{% block content %} + <div class="header"> + <h1>BCFG Performance Timings</h1> + <span class="notebox">Report Run @ {% now "F j, Y P"%}</span> + </div> + <br/> + <center> + <table id="t1" class="sortable"> + <tr> + <th class="sortable">Hostname</th> + <th class="sortable">Parse</th> + <th class="sortable">Probe</th> + <th class="sortable">Inventory</th> + <th class="sortable">Install</th> + <th class="sortable">Config</th> + <th class="sortable">Total</th> + </tr> + {% for dict_unit in stats_list %} + <tr> + <td class="sortable"><a href="/clients/{{dict_unit.name}}/">{{dict_unit.name}}</a></td> + <td class="sortable">{{dict_unit.parse}}</td> + <td class="sortable">{{dict_unit.probe}}</td> + <td class="sortable">{{dict_unit.inventory}}</td> + <td class="sortable">{{dict_unit.install}}</td> + <td class="sortable">{{dict_unit.config}}</td> + <td class="sortable">{{dict_unit.total}}</td> + </tr> + {% endfor %} + </table> + </center> +{% endblock %}
\ No newline at end of file diff --git a/reports/brpt/reports/templates/index.html b/reports/brpt/reports/templates/index.html new file mode 100644 index 000000000..002a3f770 --- /dev/null +++ b/reports/brpt/reports/templates/index.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block pagebanner %} + <div class="header"> + <h1>BCFG Reports</h1> + {% comment %} <span class="notebox">Report Run @ {% now "F j, Y P"%}</span>{% endcomment %} + </div> + <br/> +{% endblock %} +{% block content %} +<h1>Welcome to the Bcfg2 Reporting System</h1> +<p> +Please use the links at the left to navigate. +</p> +{% endblock %} diff --git a/reports/brpt/reports/templatetags/__init__.py b/reports/brpt/reports/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/reports/brpt/reports/templatetags/__init__.py diff --git a/reports/brpt/reports/templatetags/__init__.pyc b/reports/brpt/reports/templatetags/__init__.pyc Binary files differnew file mode 100644 index 000000000..c1161f868 --- /dev/null +++ b/reports/brpt/reports/templatetags/__init__.pyc diff --git a/reports/brpt/reports/templatetags/django_templating_sigh.py b/reports/brpt/reports/templatetags/django_templating_sigh.py new file mode 100644 index 000000000..146b2e0f9 --- /dev/null +++ b/reports/brpt/reports/templatetags/django_templating_sigh.py @@ -0,0 +1,24 @@ +from django import template +from brpt.reports.models import Client, Interaction, Bad, Modified, Extra + +register = template.Library() + +def set_interaction(parser, token): + try: + # Splitting by None == splitting by spaces. + tag_name, format_string = token.contents.split(None, 1) + except ValueError: + raise template.TemplateSyntaxError, "%r tag requires an argument" % token.contents[0] + if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): + raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name + return SetInteraction(format_string[1:-1]) + + +class SetInteraction(template.Node): + def __init__(self, times): + self.times = times#do soemthing to select different interaction with host + def render(self, context): + context['interaction'] = context['client'].interactions.order_by('-timestamp')[0] + return '' + +register.tag('set_interaction', set_interaction) diff --git a/reports/brpt/reports/templatetags/django_templating_sigh.pyc b/reports/brpt/reports/templatetags/django_templating_sigh.pyc Binary files differnew file mode 100644 index 000000000..f985dbdd8 --- /dev/null +++ b/reports/brpt/reports/templatetags/django_templating_sigh.pyc diff --git a/reports/brpt/reports/views.py b/reports/brpt/reports/views.py new file mode 100644 index 000000000..2edf43e1c --- /dev/null +++ b/reports/brpt/reports/views.py @@ -0,0 +1,121 @@ +# Create your views here. +#from django.shortcuts import get_object_or_404, render_to_response +from django.template import Context, loader +from django.http import HttpResponseRedirect, HttpResponse +from django.shortcuts import render_to_response, get_object_or_404 +from brpt.reports.models import Client, Interaction, Bad, Modified, Extra +from datetime import datetime + + +def index(request): + return render_to_response('index.html') + +def client_index(request): + client_list = Client.objects.all().order_by('name') + return render_to_response('clients/index.html',{'client_list': client_list}) + +def client_detail(request, hostname = -1, pk = -1): + #SETUP error pages for when you specify a client or interaction that doesn't exist + client = get_object_or_404(Client, name=hostname) + if(pk == -1): + interaction = client.interactions.order_by('-timestamp')[0] + else: + interaction = client.interactions.get(pk=pk) + + return render_to_response('clients/detail.html',{'client': client, 'interaction': interaction}) + +def display_sys_view(request): + client_lists = prepare_client_lists(request) + return render_to_response('displays/sys_view.html', client_lists) + +def display_summary(request): + client_lists = prepare_client_lists(request) + return render_to_response('displays/summary.html', client_lists) + +def display_timing(request): + #We're going to send a list of dictionaries. Each dictionary will be a row in the table + #+------+-------+----------------+-----------+---------+----------------+-------+ + #| name | parse | probe download | inventory | install | cfg dl & parse | total | + #+------+-------+----------------+-----------+---------+----------------+-------+ + client_list = Client.objects.all().order_by('-name') + stats_list = [] + #if we have stats for a client, go ahead and add it to the list(wrap in TRY) + for client in client_list:#Go explicitly to an interaction ID! (new item in dictionary) + performance_items = client.interactions.order_by('-timestamp')[0].performance_items#allow this to be selectable(hist) + dict_unit = {} + try: + dict_unit["name"] = client.name #node name + except: + dict_unit["name"] = "n/a" + try: + dict_unit["parse"] = performance_items.get(metric="config_parse").value - performance_items.get(metric="config_download").value #parse + except: + dict_unit["parse"] = "n/a" + try: + dict_unit["probe"] = performance_items.get(metric="probe_upload").value - performance_items.get(metric="start").value #probe + except: + dict_unit["probe"] = "n/a" + try: + dict_unit["inventory"] = performance_items.get(metric="inventory").value - performance_items.get(metric="initialization").value #inventory + except: + dict_unit["inventory"] = "n/a" + try: + dict_unit["install"] = performance_items.get(metric="install").value - performance_items.get(metric="inventory").value #install + except: + dict_unit["install"] = "n/a" + try: + dict_unit["config"] = performance_items.get(metric="config_parse").value - performance_items.get(metric="probe_upload").value#config download & parse + except: + dict_unit["config"] = "n/a" + try: + dict_unit["total"] = performance_items.get(metric="finished").value - performance_items.get(metric="start").value #total + except: + dict_unit["total"] = "n/a" + + #make sure all is formatted as such: #.## + stats_list.append(dict_unit) + + + return render_to_response('displays/timing.html',{'client_list': client_list, 'stats_list': stats_list}) + +def display_index(request): + return render_to_response('displays/index.html') + +def prepare_client_lists(request): + client_list = Client.objects.all().order_by('name')#change this to order by interaction's state + clean_client_list = [] + bad_client_list = [] + extra_client_list = [] + modified_client_list = [] + stale_up_client_list = [] + stale_all_client_list = [] + down_client_list = [] + for client in client_list:#but we need clientlist for more than just this loop + i = client.interactions.order_by('-timestamp')[0] +# if i.state == 'good': + if i.isclean(): + clean_client_list.append(client) + else: + bad_client_list.append(client) + if i.isstale(): + if i.pingable: + stale_up_client_list.append(client) + stale_all_client_list.append(client) + else: + stale_all_client_list.append(client) + if not i.pingable: + down_client_list.append(client) + if len(i.modified_items.all()) > 0: + modified_client_list.append(client) + if len(i.extra_items.all()) > 0: + extra_client_list.append(client) + + #if the list is empty set it to None? + return {'client_list': client_list, + 'clean_client_list': clean_client_list, + 'bad_client_list': bad_client_list, + 'extra_client_list': extra_client_list, + 'modified_client_list': modified_client_list, + 'stale_up_client_list': stale_up_client_list, + 'stale_all_client_list': stale_all_client_list, + 'down_client_list': down_client_list} diff --git a/reports/brpt/reports/views.pyc b/reports/brpt/reports/views.pyc Binary files differnew file mode 100644 index 000000000..0b163a1be --- /dev/null +++ b/reports/brpt/reports/views.pyc diff --git a/reports/brpt/settings.py b/reports/brpt/settings.py new file mode 100644 index 000000000..bcdcdbd0b --- /dev/null +++ b/reports/brpt/settings.py @@ -0,0 +1,75 @@ +# Django settings for brpt project. + + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + ('Joey Hagedorn', 'hagedorn@mcs.anl.gov'), +) + +MANAGERS = ADMINS + +DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. +DATABASE_NAME = '/Users/joey/anl-mcs/dev/bcfg2/reports/brpt-db' # Or path to database file if using sqlite3. +DATABASE_USER = '' # Not used with sqlite3. +DATABASE_PASSWORD = '' # Not used with sqlite3. +DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. +DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +# Local time zone for this installation. All choices can be found here: +# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE +TIME_ZONE = 'America/Chicago' + +# Language code for this installation. All choices can be found here: +# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes +# http://blogs.law.harvard.edu/tech/stories/storyReader$15 +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = '' + +# URL that handles the media served from MEDIA_ROOT. +# Example: "http://media.lawrence.com" +MEDIA_URL = '' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'eb5+y%oy-qx*2+62vv=gtnnxg1yig_odu0se5$h0hh#pc*lmo7' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', +# 'django.template.loaders.eggs.load_template_source', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.middleware.doc.XViewMiddleware', +) + +ROOT_URLCONF = 'brpt.urls' + +TEMPLATE_DIRS = ( + # Put strings here, like "/home/html/django_templates". + # Always use forward slashes, even on Windows. +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'brpt.reports' +) diff --git a/reports/brpt/settings.pyc b/reports/brpt/settings.pyc Binary files differnew file mode 100644 index 000000000..393fe8e27 --- /dev/null +++ b/reports/brpt/settings.pyc diff --git a/reports/brpt/urls.py b/reports/brpt/urls.py new file mode 100644 index 000000000..3f284cc6c --- /dev/null +++ b/reports/brpt/urls.py @@ -0,0 +1,30 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('', + # Example: + # (r'^brpt/', include('brpt.apps.foo.urls.foo')), + (r'^/*$','brpt.reports.views.index'), + (r'^clients/(?P<hostname>\S+)/(?P<pk>\d+)/$', 'brpt.reports.views.client_detail'), + (r'^clients/(?P<hostname>\S+)/$', 'brpt.reports.views.client_detail'), + (r'^clients/(?P<hostname>\S+)$', 'brpt.reports.views.client_detail'), + #hack because hostnames have periods and we still want to append slash + (r'^clients/$','brpt.reports.views.client_index'), + + (r'^displays/sys-view/$','brpt.reports.views.display_sys_view'), + (r'^displays/summary/$','brpt.reports.views.display_summary'), + (r'^displays/timing/$','brpt.reports.views.display_timing'), + (r'^displays/$','brpt.reports.views.display_index'), + + # Uncomment this for admin: + (r'^admin/', include('django.contrib.admin.urls')), + + + + + #Remove this when not doing DEVELOPMENT + #and i quote: + #Using this method is inefficient and insecure. Do not use this in a production setting. Use this only for development. + (r'^site_media/(.*)$', 'django.views.static.serve', {'document_root': '/Users/joey/anl-mcs/dev/bcfg2/reports/site_media/'}), + + +) diff --git a/reports/brpt/urls.pyc b/reports/brpt/urls.pyc Binary files differnew file mode 100644 index 000000000..0bf6eff8b --- /dev/null +++ b/reports/brpt/urls.pyc |