[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

nap naparuba at gmail.com
Tue Feb 28 22:13:45 UTC 2012


The following commit has been merged in the debian/master branch:
commit 2260d1c3144199a66a50164eefd34089c0a77374
Author: nap <naparuba at gmail.com>
Date:   Sat Jan 14 14:50:40 2012 +0100

    Add : helper script for creating a sample service pack.

diff --git a/libexec/create_pack.py b/libexec/create_pack.py
new file mode 100755
index 0000000..aec6a94
--- /dev/null
+++ b/libexec/create_pack.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2009-2011 :
+#    Gabes Jean, naparuba at gmail.com
+#    Gerhard Lausser, Gerhard.Lausser at consol.de
+#    Gregory Starck, g.starck at gmail.com
+#    Hartmut Goebel, h.goebel at goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
+
+import sys
+import os
+
+
+
+def usage():
+    print "%s pack_name path" % sys.argv[0]
+    sys.exit(1)
+
+
+if len(sys.argv) < 2:
+    usage()
+
+
+
+pack_name = sys.argv[1]
+path = sys.argv[2]
+
+pack_path = os.path.join(path, pack_name)
+
+
+def create_file(f_name, content):
+    path = os.path.join(pack_path, f_name)
+    if not os.path.exists(path):
+        print "Writing file", path
+        f = open(path, 'w')
+        f.write(content)
+        f.close()
+
+
+
+if not os.path.exists(pack_path):
+    print "Creating", pack_path
+    os.mkdir(pack_path)
+    os.mkdir(os.path.join(pack_path, 'services'))
+
+# Now the templates.cfg creation
+templates = """
+define host{
+   name				%s
+   use				generic-host
+   check_command           	check_ping
+   register			0
+}
+""" % pack_name
+
+create_file('templates.cfg', templates)
+
+
+# Now the macros
+macros = """
+#Uncomment the line and change the name and value
+#$SAMPLEMACRO$=value
+"""
+
+create_file('macros.cfg', macros)
+
+# Now the sample discovery file
+discovery = """
+# Sample discovery rule. Uncomment it and edit the filter
+define discoveryrule {
+       discoveryrule_name       %s
+       creation_type            host
+       # Sample filter for getting port 80
+       #openports                ^80$
+       FILTER                   VALUE 
+       +use                     %s
+}
+""" % (pack_name, pack_name)
+
+create_file('discovery.cfg', discovery)
+
+
+# Now the commands
+commands = """
+# EDIT the command with the real one you want
+define command {
+       command_name     check_%s
+       command_line	$PLUGINSDIR$/check_%s -H $HOSTADDRESS$
+}
+""" % (pack_name, pack_name)
+
+create_file('commands.cfg', commands)
+
+
+# And a sample service
+service = """
+# This is a sample service, please change it!
+define service{
+   service_description    Sample-%s
+   use                    generic-service
+   register               0
+   host_name	          %s
+   check_command          check_%s
+}
+""" % (pack_name, pack_name, pack_name)
+
+create_file(os.path.join('services', 'sample.cfg'), service)
+

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list