summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--reports/brpt/reports/models.py6
-rw-r--r--reports/brpt/reports/models.pycbin6518 -> 6661 bytes
-rw-r--r--reports/brpt/reports/templatetags/django_templating_sigh.py3
-rw-r--r--reports/brpt/reports/views.py27
-rw-r--r--reports/brpt/reports/views.pycbin4247 -> 4485 bytes
5 files changed, 26 insertions, 10 deletions
diff --git a/reports/brpt/reports/models.py b/reports/brpt/reports/models.py
index 211e83da8..3330189b0 100644
--- a/reports/brpt/reports/models.py
+++ b/reports/brpt/reports/models.py
@@ -3,6 +3,7 @@ from django.db import models
from datetime import datetime, timedelta
# Create your models here.
KIND_CHOICES = (
+ #These are the kinds of config elements
('ConfigFile', 'ConfigFile'),
('Package', 'Package'),
('Service', 'Service'),
@@ -11,6 +12,7 @@ KIND_CHOICES = (
('Permissions','Permissions'),
)
REASON_CHOICES = (
+ #these are the possible reasons there can be a problem with a node:
('', 'No Reason'),
('O','Owner'),
('P','Permissions'),
@@ -81,7 +83,7 @@ class Interaction(models.Model):
return False
def isstale(self):
- if (self == self.client.interactions.order_by('-timestamp')[0]):#Is Mostrecent
+ if (self == self.client.interactions.latest('timestamp')):#Is Mostrecent
if(datetime.now()-self.timestamp > timedelta(hours=25) ):
return True
else:
@@ -100,6 +102,8 @@ class Interaction(models.Model):
list_display = ('client', 'timestamp', 'state')
list_filter = ['client', 'timestamp']
pass
+ class Meta:
+ get_latest_by = 'timestamp'
diff --git a/reports/brpt/reports/models.pyc b/reports/brpt/reports/models.pyc
index d68f2d7aa..8eba495c3 100644
--- a/reports/brpt/reports/models.pyc
+++ b/reports/brpt/reports/models.pyc
Binary files differ
diff --git a/reports/brpt/reports/templatetags/django_templating_sigh.py b/reports/brpt/reports/templatetags/django_templating_sigh.py
index e05c6e118..0765d272b 100644
--- a/reports/brpt/reports/templatetags/django_templating_sigh.py
+++ b/reports/brpt/reports/templatetags/django_templating_sigh.py
@@ -18,7 +18,8 @@ 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.latest('timestamp')
+ #context['interaction'] = context['client'].interactions.latest('timestamp')
+ context['interaction'] = context['client_interaction_dict'][context['client'].id]
return ''
register.tag('set_interaction', set_interaction)
diff --git a/reports/brpt/reports/views.py b/reports/brpt/reports/views.py
index 14cb42588..fe6842f1b 100644
--- a/reports/brpt/reports/views.py
+++ b/reports/brpt/reports/views.py
@@ -21,7 +21,7 @@ def client_detail(request, hostname = -1, pk = -1):
interaction = client.interactions.latest('timestamp')
else:
interaction = client.interactions.get(pk=pk)
-
+
return render_to_response('clients/detail.html',{'client': client, 'interaction': interaction})
def display_sys_view(request):
@@ -41,40 +41,47 @@ def display_timing(request):
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)
+# performance_items = client.interactions.latest().performance_items.all()#allow this to be selectable(hist)
+ d = {}
+ #Best List Comprehension Ever!
+ [d.update({x:y}) for x,y in [a.values() for a in client.interactions.latest().performance_items.all().values('metric','value')]]
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
+ dict_unit["parse"] = d["config_parse"] - d["config_download"] #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
+ dict_unit["probe"] = d["probe_upload"] - d["start"] #probe
except:
dict_unit["probe"] = "n/a"
try:
- dict_unit["inventory"] = performance_items.get(metric="inventory").value - performance_items.get(metric="initialization").value #inventory
+ dict_unit["inventory"] = d["inventory"] - d["initialization"] #inventory
except:
dict_unit["inventory"] = "n/a"
try:
- dict_unit["install"] = performance_items.get(metric="install").value - performance_items.get(metric="inventory").value #install
+ dict_unit["install"] = d["install"] - d["inventory"] #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
+ dict_unit["config"] = d["config_parse"] - d["probe_upload"]#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
+ dict_unit["total"] = d["finished"] - d["start"] #total
except:
dict_unit["total"] = "n/a"
#make sure all is formatted as such: #.##
stats_list.append(dict_unit)
+ from django.db import connection
+ for q in connection.queries:
+ print q
return render_to_response('displays/timing.html',{'client_list': client_list, 'stats_list': stats_list})
@@ -83,6 +90,7 @@ def display_index(request):
def prepare_client_lists(request):
client_list = Client.objects.all().order_by('name')#change this to order by interaction's state
+ client_interaction_dict = {}
clean_client_list = []
bad_client_list = []
extra_client_list = []
@@ -92,6 +100,7 @@ def prepare_client_lists(request):
down_client_list = []
for client in client_list:#but we need clientlist for more than just this loop
i = client.interactions.latest('timestamp')
+ client_interaction_dict[client.id] = i
# if i.state == 'good':
if i.isclean():
clean_client_list.append(client)
@@ -105,6 +114,7 @@ def prepare_client_lists(request):
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:
@@ -112,6 +122,7 @@ def prepare_client_lists(request):
#if the list is empty set it to None?
return {'client_list': client_list,
+ 'client_interaction_dict':client_interaction_dict,
'clean_client_list': clean_client_list,
'bad_client_list': bad_client_list,
'extra_client_list': extra_client_list,
diff --git a/reports/brpt/reports/views.pyc b/reports/brpt/reports/views.pyc
index e65db3249..8c4d9d7a8 100644
--- a/reports/brpt/reports/views.pyc
+++ b/reports/brpt/reports/views.pyc
Binary files differ