Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated docu,config

The shiny module is now a full-fledged 'simple drop-in' module where you can simply
throw in your modules and the backend will use them happily,
supports now rabbithole,irc(dummy),mail and snmp_users
Added README file, updated TODO and VERSION file to new versions, new ideas
  • Loading branch information...
commit 781ce19fba113811d09800127cbfba032891adca 1 parent dc3546a
Felix Richter authored
View
29 README.md
@@ -0,0 +1,29 @@
+Shiny Web Frontend Module
+=======================
+
+The shiny module is a simple module which provides a way to visualize data
+with the help of a few lines of python code and a template if you want.
+
+Example
+======
+A shiny submodule normally contains 2 parts:
+1. The template (e.g. Mustache) in _templates/example.mustache_
+<html><head><title>Example Submodule</title></head>
+<body>{{NAME}}
+{{#list}}
+{{listitem}}<br/>
+{{/list}}
+</body></html>
+2. The python module in _src/modules/example.py_
+ import pystache
+ dispatch=['sample_type'] #type of message you want to receive
+ path='example' #the path on the webserver (http://localhost/example)
+ #template_name='' # if you want other extraordinary templates
+ def process(self): # self is the shiny class (see code for all cool stuff it has)
+ # you can do all the weird stuff you want, return what the user should
+ # see at the end
+ return pystache.render(self.templates['example'],self.stats['example'])
+
+After you dropped these two files you are already finished.
+If you want other exchanges to listen on, add them to _conf/config.json_
+(this is important because otherwise the exchange won't be polled for data)
View
3  TODO
@@ -0,0 +1,3 @@
+- take exchanges instead of types for the stats
+- think of something how to automate the necessary exchanges allocation
+- think of a way to add mongodb? (simply derive from MongoBackend should do it)
View
2  VERSION
@@ -1 +1 @@
-+++++++[>+++++++>+++++++<<-]>.>---.<-.
++++++++[>+++++++>+++++++<<-]>.>---.<+++.
View
12 config/example.json
@@ -9,12 +9,20 @@
"exchanges": {
"mail_stats": {
"in": {
- "exchange": "mail_stats"
+ "exchange": "mail_stats",
+ "type" : "fanout"
+ }
+ },
+ "rabbithole": {
+ "in": {
+ "exchange": "rabbithole",
+ "type" : "fanout"
}
},
"snmp_src": {
"in": {
- "exchange": "snmp_src"
+ "exchange": "snmp_src",
+ "type" : "fanout"
}
}
}
View
4 src/main.py
@@ -29,7 +29,9 @@ def cb (ch,method,header,body):
print 'Something just fuckin happened ' + str(e)
raise e
for i in amqp:
- i.consume(cb)
+ log.debug('registering new consumer ' +str(i.name))
+
+ i.consume(cb,i.qname)
print "waiting for messages"
try:
amqp[0].start_loop()
View
2  src/modules/rabbithole.py
@@ -10,7 +10,7 @@ def process(self):
stache = { 'infos' : [] }
stache['timestamp'] = data['timestamp']
del data['timestamp']
- for k,v in data:
+ for k,v in data.items():
stache['infos'].append( { 'key' : k , 'value' : v.replace('\n','<br/>') } )
data['timestamp'] = stache['timestamp']
View
4 src/shiny.py
@@ -33,8 +33,10 @@ def __init__(self,MODULE_NAME,conf=None):
cherrypy.server.__dict__.update(self.config[MODULE_NAME]["http"])
def process(self,stats):
+ #TODO think about what you wanted to do gawddamn!
log.debug("Received Stats: " + str(stats))
- self.stats[stats['type']] = stats['data']
+ self.stats[stats['type']] = stats['data'] #TODO do not use the type, but the actual exchange where the data comes from
+
self.stats[stats['type']]['timestamp'] = datetime.now().ctime()
def create_connection(self):
Please sign in to comment.
Something went wrong with that request. Please try again.