[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
David GUENAULT
dguenault at monitoring-fr.org
Tue Feb 28 22:15:45 UTC 2012
The following commit has been merged in the debian/master branch:
commit 6c60fb271d7dd15e3b66a1c015734578975bfc6c
Author: David GUENAULT <dguenault at monitoring-fr.org>
Date: Mon Jan 23 08:08:05 2012 +0100
Started to implement the new livestatus module
diff --git a/contrib/alternative-installation/shinken-install/shinken.conf b/contrib/alternative-installation/shinken-install/shinken.conf
index 65f1f4c..fd23480 100644
--- a/contrib/alternative-installation/shinken-install/shinken.conf
+++ b/contrib/alternative-installation/shinken-install/shinken.conf
@@ -32,6 +32,8 @@ export KEEPDAYSLOG=7
# default retention module (pickle|mongodb)
# work only if ENABLEOPTPKGS
export RETENTIONMODULE=${RETENTIONMODULE:-"pickle"}
+export LOGSTORE=${LOGSTORE:-"sqlite"}
+export MONGOSERVER=${MONGOSERVER:-"localhost"}
# FOR CES INTEGRATION
export IF="eth0" # local iface
export ADDPOLLERS="poller-2=172.16.1.2"
diff --git a/contrib/alternative-installation/shinken-install/shinken.sh b/contrib/alternative-installation/shinken-install/shinken.sh
index 6f1250c..2413d6e 100755
--- a/contrib/alternative-installation/shinken-install/shinken.sh
+++ b/contrib/alternative-installation/shinken-install/shinken.sh
@@ -581,6 +581,10 @@ function sinstall(){
cp $TARGET/bin/init.d/shinken* /etc/init.d/
mkdir -p $TARGET/var/archives
enableretention
+ if [ "$LOGSTORE" == "mongo" ]
+ then
+ enablemongologs
+ fi
fix
cecho "+------------------------------------------------------------------------------" green
cecho "| shinken is now installed on your server " green
@@ -838,6 +842,18 @@ function fixforfan(){
fi
}
+# ENABLE MONGO STORAGE FOR LOGS
+function enablemongologs(){
+ cecho " > Enable mongodb log storage" green
+ export PYTHONPATH=$TARGET
+ export PY="$(pythonver)"
+ result=$($PY $TARGET/contrib/alternative-installation/shinken-install/tools/skonf.py -a macros -f $TARGET/contrib/alternative-installation/shinken-install/tools/macros/enable_log_mongo.macro -d $MONGOSERVER)
+ if [ $? -ne 0 ]
+ then
+ cecho " > There was an error while trying to enable mongo log storage ($result)" red
+ exit 2
+ fi
+}
function enablendodb(){
cecho " > FIX shinken ndo configuration" green
diff --git a/contrib/alternative-installation/shinken-install/tools/macros/enable_log_mongo.macro b/contrib/alternative-installation/shinken-install/tools/macros/enable_log_mongo.macro
new file mode 100644
index 0000000..9b01585
--- /dev/null
+++ b/contrib/alternative-installation/shinken-install/tools/macros/enable_log_mongo.macro
@@ -0,0 +1,7 @@
+# Enable log storage to mongodb
+# ARG1 : mongodb server FQDN or IP address
+setconfigfile __PREFIX__/etc/shinken-specific.cfg
+delparam database_file from modules where module_name=Livestatus
+setparam modules=mongologs from modules where module_name=Livestatus
+setparam mongodb_uri=mongodb://__ARG1__:27017 from modules where module_name=mongologs
+writeconfig
diff --git a/contrib/alternative-installation/shinken-install/tools/skonf.py b/contrib/alternative-installation/shinken-install/tools/skonf.py
index e6a67bd..f56ab9a 100755
--- a/contrib/alternative-installation/shinken-install/tools/skonf.py
+++ b/contrib/alternative-installation/shinken-install/tools/skonf.py
@@ -55,6 +55,7 @@ def usage():
print " - cloneobject : clone an object (currently only pollers are suported"
print " - showconfig : display configuration of object"
print " - setparam : set directive value for an object"
+ print " - delparam : remove directive for an object"
print " - getdirective : get a directive value from an object"
print " * configfile : full path to the shinken-specific.cfg file"
print " * objectype : configuration object type on which the action apply"
@@ -79,7 +80,7 @@ def main():
sys.exit(2)
for o, a in opts:
if o == "-a":
- actions=["setparam","showconfig","addobject","getdirective","getaddresses","delobject","cloneobject","macros","sync","control","deploy"]
+ actions=["setparam","delparam","showconfig","addobject","getdirective","getaddresses","delobject","cloneobject","macros","sync","control","deploy"]
if a in actions:
action=a
else:
@@ -156,6 +157,18 @@ def main():
sys.exit(2)
else:
sys.exit(0)
+ if action == "delparam":
+ result,content = delparam(config,objectype,directive,filters)
+ print content
+ if not result:
+ print content
+ sys.exit(2)
+ else:
+ result,content = writeconfig(config,configfile)
+ if not result:
+ sys.exit(2)
+ else:
+ sys.exit(0)
elif action == "macros":
if directive != "":
result,content = domacros(configfile,directive.split(','))
@@ -287,6 +300,7 @@ def domacros(configfile,args=[]):
"delete":r"(?P<object>\w+) where (?P<clauses>.*)",
"showconfig":r"(?P<object>\w+)",
"setparam":r"(?P<directive>\w+)=(?P<value>.*) from (?P<object>\w+) where (?P<clauses>.*)",
+ "delparam":r"(?P<directive>\w+)=(?P<value>.*) from (?P<object>\w+) where (?P<clauses>.*)",
"getdirective":r"(?P<directives>\w+) from (?P<object>\w+) where (?P<clauses>.*)",
"control":r"(?P<action>\w+)",
"writeconfig":r"",
@@ -353,6 +367,10 @@ def domacros(configfile,args=[]):
code,message = setparam(config,result.group('object'),result.group('directive'),result.group('value'),result.group('clauses'))
if not code:
if maction == "stop" :return (code,message)
+ elif command == "delparam":
+ code,message = delparam(config,result.group('object'),result.group('directive'),result.group('clauses'))
+ if not code:
+ if maction == "stop" :return (code,message)
else:
if command == "writeconfig":
code,message = writeconfig(config,configfile)
@@ -824,6 +842,41 @@ def setparam(config,objectype,directive,value,filters):
return (True,message)
else:
return (False, "Unknown object type %s" % (o))
+
+def delparam(config,objectype,directive,filters):
+ import re
+ dfilters={}
+ if len(filters) > 0:
+ t=filters.split(',')
+ for i in range(len(t)):
+ (k,v)=t[i].split('=')
+ dfilters[k]=v
+
+ if config.has_key(objectype):
+ max=len(config[objectype])
+ filterok=0
+ for i in range(max):
+ filterok=0
+ for (d,v) in dfilters.items():
+ filterok=filterok+1
+ if config[objectype][i].has_key(d):
+ if config[objectype][i][d] != v:
+ filterok=filterok-1
+ else:
+ filterok=filterok-1
+ if filterok == len(dfilters):
+ """ if directive exist remove it ! """
+ if config[objectype][i].has_key(directive):
+ """ config[objectype][i][directive]=value"""
+ config[objectype][i].pop(directive)
+ print config[objectype][i]
+ message = "Removed directive %s from %s" % (directive,objectype)
+ else:
+ message = "Nothing to remove"
+ return (True,message)
+ else:
+ return (False, "Unknown object type %s" % (o))
+
def loadconfig(configfile):
try:
c=Config()
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list