[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:13:34 UTC 2012
The following commit has been merged in the debian/master branch:
commit 2c4c33cff199a27f27df6d42460b85c259359f5e
Author: Naparuba <naparuba at gmail.com>
Date: Fri Jan 13 16:37:52 2012 +0100
Add : skongui can now dump the discovered hosts in pending.
diff --git a/shinken/daemons/skonfdaemon.py b/shinken/daemons/skonfdaemon.py
index b0e2f8c..b934c7b 100644
--- a/shinken/daemons/skonfdaemon.py
+++ b/shinken/daemons/skonfdaemon.py
@@ -60,6 +60,11 @@ sys.path.insert(0, bottle_dir)
bottle.TEMPLATE_PATH.append(os.path.join(bottle_dir, 'views'))
bottle.TEMPLATE_PATH.append(bottle_dir)
+try:
+ from pymongo.connection import Connection
+except ImportError:
+ Connection = None
+
# Interface for the other Arbiter
@@ -514,6 +519,7 @@ class Skonf(Daemon):
logger.log("Warning : an external module queue got a problem '%s'" % str(exp))
break
+
# We wait (block) for arbiter to send us something
def wait_for_master_death(self):
logger.log("Waiting for master death")
@@ -526,7 +532,6 @@ class Skonf(Daemon):
if not arb.spare:
master_timeout = arb.check_interval * arb.max_check_attempts
logger.log("I'll wait master for %d seconds" % master_timeout)
-
while not self.interrupted:
elapsed, _, tcdiff = self.handleRequests(timeout)
@@ -596,6 +601,8 @@ class Skonf(Daemon):
for i in xrange(1, 3):
self.create_and_launch_worker()
+ self.init_db()
+
# Launch the data thread"
self.workersmanager_thread = threading.Thread(None, self.workersmanager, 'httpthread')
self.workersmanager_thread.start()
@@ -865,3 +872,18 @@ class Skonf(Daemon):
# Ok, all is good. Start it!
w.start()
+
+
+ # TODO : fix hard coded server/database
+ def init_db(self):
+ if not Connection:
+ logger.log('ERROR : you need the pymongo lib for running skonfui. Please install it')
+ sys.exit(2)
+
+ con = Connection('localhost')
+ self.db = con.shinken
+
+
+ # TODO : code this!
+ def check_auth(self, login, password):
+ return True
diff --git a/shinken/discovery/discoverymanager.py b/shinken/discovery/discoverymanager.py
index e7b746d..dccfec2 100644
--- a/shinken/discovery/discoverymanager.py
+++ b/shinken/discovery/discoverymanager.py
@@ -109,7 +109,7 @@ class DiscoveryManager:
server = mod.server
database = mod.database
self.dbconnection = Connection(server)
- self.db = getattr(self.dbconnection, 'database')
+ self.db = getattr(self.dbconnection, database)
print "Connection to Mongodb:%s:%s is OK" % (server, database)
except Exception, exp:
logger.log('Error in database init : %s' % exp)
@@ -392,5 +392,7 @@ class DiscoveryManager:
return
print "Saving in database", d
+ d['_id'] = host
table.save(d)
print "saved"
+ del d['_id']
diff --git a/shinken/webui/plugins_skonf/newhosts/newhosts.py b/shinken/webui/plugins_skonf/newhosts/newhosts.py
index 864b59f..e8e69ed 100644
--- a/shinken/webui/plugins_skonf/newhosts/newhosts.py
+++ b/shinken/webui/plugins_skonf/newhosts/newhosts.py
@@ -25,6 +25,8 @@
from shinken.webui.bottle import redirect
from shinken.util import to_bool
+
+
### Will be populated by the UI with it's own value
app = None
@@ -65,6 +67,12 @@ def get_scans():
print "Got scans"
return {'app' : app}
+def get_results():
+ print "Looking for hosts in pending aprouval"
+ cur = app.db.discovered_hosts.find({})
+ pending_hosts = [h for h in cur]
+ return {'app' : app, 'pending_hosts' : pending_hosts}
+
# This is the dict teh webui will try to "load".
# *here we register one page with both adresses /dummy/:arg1 and /dummy/, both addresses
@@ -77,5 +85,6 @@ def get_scans():
pages = {get_newhosts : { 'routes' : ['/newhosts'], 'view' : 'newhosts', 'static' : True},
get_launch : { 'routes' : ['/newhosts/launch'], 'view' : 'newhosts_launch', 'static' : True, 'method' : 'POST'},
get_scans : { 'routes' : ['/newhosts/scans'], 'view' : 'newhosts_scans', 'static' : True},
+ get_results : { 'routes' : ['/newhosts/results'], 'view' : 'newhosts_results', 'static' : True},
}
diff --git a/shinken/webui/plugins_skonf/newhosts/views/newhosts_scans.tpl b/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
similarity index 71%
copy from shinken/webui/plugins_skonf/newhosts/views/newhosts_scans.tpl
copy to shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
index 489dbac..e89c623 100644
--- a/shinken/webui/plugins_skonf/newhosts/views/newhosts_scans.tpl
+++ b/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
@@ -3,3 +3,6 @@
<div> <h1> Discover your new hosts </h1> </div>
Here are the results :
+
+%for h in pending_hosts:
+ <br/>{{h}}
\ No newline at end of file
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list