Permalink
Browse files

Merge branch 'master' of github.com:rep/hpfeeds

  • Loading branch information...
rep committed Jun 1, 2011
2 parents a699ad6 + 6c605ee commit 9c11be75def0c48e26f4ea513f1795afac3fc6ac
Showing with 84 additions and 4 deletions.
  1. +13 −0 webif/models.py
  2. +17 −0 webif/templates/404.html
  3. +17 −0 webif/templates/500.html
  4. +15 −2 webif/templates/index.html
  5. +16 −0 webif/update-stats.py
  6. +6 −2 webif/views.py
View
@@ -21,3 +21,16 @@ class AuthKey(Document):
def __unicode__(self):
return '<AK: {0}{1}>'.format(self.identifier, ' ('+self.comment+')' if self.comment else '')
+class Chanstat(Document):
+ name = StringField(required=True, unique=True)
+ total = IntField(required=True, default=0)
+ sourcecount = IntField(required=True, default=0)
+ hour = IntField(required=True, default=0)
+ day = IntField(required=True, default=0)
+ week = IntField(required=True, default=0)
+
+class Publog(Document):
+ tstamp = DateTimeField(required=True)
+ chan = StringField(required=True)
+ identifier = StringField(max_length=20, required=True)
+
View
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+{% load tabs %}
+{% block menubar %}
+{{ block.super }}
+{% endblock %}
+
+{% block content %}
+ <div>
+ <h1>
+ <div class="subtitle">Error</div>
+ Page not found
+ </h1>
+<br />
+<p>Page not found.</p>
+ </div>
+{% endblock %}
+
View
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+{% load tabs %}
+{% block menubar %}
+{{ block.super }}
+{% endblock %}
+
+{% block content %}
+ <div>
+ <h1>
+ <div class="subtitle">Error</div>
+ Internal Server Error
+ </h1>
+<br />
+<p>Internal Server Error.</p>
+ </div>
+{% endblock %}
+
View
@@ -17,8 +17,21 @@ <h1>
<p>To support multiple data sources and sinks per user we manage the Authkeys in this webinterface after a quick login with a user account. User accounts are only needed for the webinterface - to use the data feed channels, only Authkeys are necessary. Different Authkeys can be granted distinct access rights for channels.</p>
</div>
- <div style="float:left;width:220px;">
- <h3 style="text-align:right;">Statistics</h3>
+<div style="float:left;width:220px;">
+ <h3 style="">Statistics</h3>
+ <div style="float:right">{{ stats.glastopf_dorks.total }}</div>
+ Glastopf dorks:<br />
+ <div style="float:right">{{ stats.mwcapture.total }}</div>
+ Malware captures:<br />
+ <div style="float:right">{{ stats.mwcapture.hour }}</div>
+ ... last hour:<br />
+ <div style="float:right">{{ stats.mwcapture.day }}</div>
+ ... last day:<br />
+ <div style="float:right">{{ stats.mwcapture.week }}</div>
+ ... last week:<br />
+ <div style="float:right">{{ stats.mwbinary_sensorunique.total }}</div>
+ Sensor-unique binaries:<br />
+
<br clear="all">
<a style="font-size:13px;" href="ex/">Statistics sink »</a>
View
@@ -0,0 +1,16 @@
+import os
+import datetime
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+import settings
+from models import Chanstat, Publog
+
+
+cs = Chanstat.objects.all()
+for i in cs:
+ i.hour = Publog.objects.filter(chan=i.name, tstamp__gte=datetime.datetime.now()-datetime.timedelta(0,3600)).count()
+ i.day = Publog.objects.filter(chan=i.name, tstamp__gte=datetime.datetime.now()-datetime.timedelta(1)).count()
+ i.week = Publog.objects.filter(chan=i.name, tstamp__gte=datetime.datetime.now()-datetime.timedelta(7)).count()
+ i.save()
+
View
@@ -13,7 +13,7 @@
from django.db.models import Q
from hpfeedauth import User
-from models import AuthKey, TagRights
+from models import AuthKey, TagRights, Chanstat
def getchanaxs(user):
channelaxs = collections.defaultdict(set)
@@ -354,5 +354,9 @@ def editak(request, ak):
return render_to_response('editak.html', {'form': caf, 'ak': akobj, 'axs': straxs}, context_instance=RequestContext(request))
def index(request):
- return render_to_response('index.html', {}, context_instance=RequestContext(request))
+ cs = Chanstat.objects.all()
+ stats = dict([(i.name, i) for i in cs])
+ for i in cs: stats.update({i.name.replace('-', '_'): i})
+
+ return render_to_response('index.html', {'cs': cs, 'stats': stats}, context_instance=RequestContext(request))

0 comments on commit 9c11be7

Please sign in to comment.