From git at mathias-kettner.de Wed Dec 2 14:43:26 2015 From: git at mathias-kettner.de (git version control) Date: Wed, 02 Dec 2015 14:43:26 +0100 Subject: [omd-commits] OMD Git: omd: Make sure that on RH the OMD startscript is running as latest as possible Message-ID: <20151202134326.D91968070A@mail.mathias-kettner.de> Module: omd Branch: master Commit: 6ee952061ed8cfaa27efc30cf472d68b03d527bf URL: http://omdistro.org/projects/omd/repository/revisions/6ee952061ed8cfaa27efc30cf472d68b03d527bf Author: Mathias Kettner Date: Wed Dec 2 14:43:24 2015 +0100 Commiter: Mathias Kettner Date: Wed Dec 2 14:43:24 2015 +0100 Make sure that on RH the OMD startscript is running as latest as possible This fixed race conditions with NTP --- packages/omd/omd.init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/omd/omd.init b/packages/omd/omd.init index 8829b8f..97b7672 100755 --- a/packages/omd/omd.init +++ b/packages/omd/omd.init @@ -1,5 +1,8 @@ #!/bin/sh # Startskript for OMD sites +# chkconfig: - 98 1 +# description: OMD Open Monitoring Distribution + ### BEGIN INIT INFO # Provides: omd From git at mathias-kettner.de Tue Dec 15 14:10:08 2015 From: git at mathias-kettner.de (git version control) Date: Tue, 15 Dec 2015 14:10:08 +0100 Subject: [omd-commits] OMD Git: omd: shinken: install hashlib only for old centos versions. newer centos have their own Message-ID: <20151215131008.D2144800BD@mail.mathias-kettner.de> Module: omd Branch: master Commit: 264aaeaf22c531744db8412256e7169419b8769a URL: http://omdistro.org/projects/omd/repository/revisions/264aaeaf22c531744db8412256e7169419b8769a Author: Gerhard Lausser Date: Tue Dec 15 14:09:00 2015 +0100 Commiter: Gerhard Lausser Date: Tue Dec 15 14:09:00 2015 +0100 shinken: install hashlib only for old centos versions. newer centos have their own --- packages/shinken/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shinken/Makefile b/packages/shinken/Makefile index e8034e4..d75ab31 100644 --- a/packages/shinken/Makefile +++ b/packages/shinken/Makefile @@ -144,7 +144,7 @@ install: $(MAKE) installpymongo $(MAKE) installmongodb echo "distro is " $(DISTRO_NAME) - if [ $(DISTRO_NAME) = "CENTOS" ]; then \ + if [ $(DISTRO_NAME) = "CENTOS" ] && [ $(DISTRO_VERSION) = "5" ]; then \ $(MAKE) installctypes; \ $(MAKE) installhashlib; \ fi From git at mathias-kettner.de Tue Dec 15 14:10:08 2015 From: git at mathias-kettner.de (git version control) Date: Tue, 15 Dec 2015 14:10:08 +0100 Subject: [omd-commits] OMD Git: omd: Merge branch 'master' of mathias-kettner.de:omd Message-ID: <20151215131008.E667480054@mail.mathias-kettner.de> Module: omd Branch: master Commit: 037d3d66f397204b437344582ea4a7e9cbf04b19 URL: http://omdistro.org/projects/omd/repository/revisions/037d3d66f397204b437344582ea4a7e9cbf04b19 Author: Gerhard Lausser Date: Tue Dec 15 14:09:35 2015 +0100 Commiter: Gerhard Lausser Date: Tue Dec 15 14:09:35 2015 +0100 Merge branch 'master' of mathias-kettner.de:omd --- From git at mathias-kettner.de Fri Dec 18 08:41:12 2015 From: git at mathias-kettner.de (git version control) Date: Fri, 18 Dec 2015 08:41:12 +0100 Subject: [omd-commits] OMD Git: omd: FIX: Fixed streamed "omd restore" resulting in an exception Message-ID: <20151218074112.39F0980461@mail.mathias-kettner.de> Module: omd Branch: master Commit: d4e692be71d8ce53c888912ad31aebd029a2fc6e URL: http://omdistro.org/projects/omd/repository/revisions/d4e692be71d8ce53c888912ad31aebd029a2fc6e Author: Lars Michelsen Date: Fri Dec 18 07:48:57 2015 +0100 Commiter: Lars Michelsen Date: Fri Dec 18 08:41:07 2015 +0100 FIX: Fixed streamed "omd restore" resulting in an exception --- Changelog | 2 ++ packages/omd/omd | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Changelog b/Changelog index 54109f4..c5f6fa1 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,8 @@ This file documents the revision history for the Open Monitoring Distribution 1.40 (not yet released) + - omd: + - FIX: Fixed streamed "omd restore" resulting in an exception - Apache: - Removed the shared mode (only one system wide apache process). This mode was not used widely and it was a pain to maintain it, diff --git a/packages/omd/omd b/packages/omd/omd index bd0c849..7aa2b41 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -3186,8 +3186,17 @@ def main_backup(args, options={}): fh = file(dest, 'w') tar = tarfile.open(fileobj=fh, mode='w:gz') - tar.add(g_sitedir, g_sitename) - tar.close() + try: + # Add the version symlink as first file to be able to + # check a) the sitename and b) the version before reading + # the whole tar archive. Important for streaming. + # The file is added twice to get the first for validation + # and the second for excration during restore. + tar.add(g_sitedir + "/version", g_sitename + "/version") + tar.add(g_sitedir, g_sitename) + tar.close() + except IOError, e: + bail_out("Failed to perform backup: %s" % e) def main_restore(args, options={}): global g_sitename @@ -3211,25 +3220,25 @@ def main_restore(args, options={}): tar = tarfile.open(fileobj=fh, mode=tar_mode) - # Get the first file of the tar archive (expecting site directory) - sitename = tar.next().name + # Get the first file of the tar archive. Expecting /version symlink + # for validation reasons. + site_tarinfo = tar.next() + sitename, version_name = site_tarinfo.name.split("/", 1) + + if version_name == "version": + version = site_tarinfo.linkname.split('/')[-1] + else: + bail_out("Failed to detect version of backed up site.") + + if not version_exists(version): + bail_out("You need to have version %s installed to be able to restore " + "this backup." % version) # Restore site with its original name, or specify a new one new_sitename = sitename if len(args) == 2: new_sitename = args[0] - # Read the needed OMD version from the site - version = None - for tarinfo in tar: - if tarinfo.name == '%s/version' % sitename: - version = tarinfo.linkname.split('/')[-1] - if not version: - bail_out("Failed to detect version of backed up site.") - - if not version_exists(version): - bail_out("You need to have version %s installed to be able to restore this backup." % version) - g_sitename = new_sitename g_sitedir = site_dir(new_sitename) @@ -3249,7 +3258,8 @@ def main_restore(args, options={}): os.system('omd stop %s' % g_sitename) unmount_tmpfs(g_sitename, kill = "kill" in options) - sys.stdout.write("Restoring site %s from %s...\n" % (g_sitename, source == '-' and 'stdin' or source)) + sys.stdout.write("Restoring site %s from %s...\n" % + (g_sitename, source == '-' and 'stdin' or source)) sys.stdout.flush() if not reuse: @@ -3257,7 +3267,7 @@ def main_restore(args, options={}): gid = options.get("gid") useradd(g_sitename, uid, gid) # None for uid/gid means: let Linux decide else: - sys.stdout.write("Deleting existing site data...") + sys.stdout.write("Deleting existing site data...\n") shutil.rmtree(g_sitedir) ok() @@ -3267,6 +3277,8 @@ def main_restore(args, options={}): for tarinfo in tar: # remove leading site name from paths tarinfo.name = '/'.join(tarinfo.name.split('/')[1:]) + if opt_verbose: + sys.stdout.write("Restoring %s...\n" % tarinfo.name) if tarinfo.issym() or tarinfo.islnk(): parts = tarinfo.linkname.split('/') if parts[0] == sitename: From git at mathias-kettner.de Fri Dec 18 08:41:12 2015 From: git at mathias-kettner.de (git version control) Date: Fri, 18 Dec 2015 08:41:12 +0100 Subject: [omd-commits] OMD Git: omd: Improved "omd restore" error handling Message-ID: <20151218074112.56C72802D3@mail.mathias-kettner.de> Module: omd Branch: master Commit: 72a8f21b9088430c009a88195725af2545355d69 URL: http://omdistro.org/projects/omd/repository/revisions/72a8f21b9088430c009a88195725af2545355d69 Author: Lars Michelsen Date: Fri Dec 18 07:51:33 2015 +0100 Commiter: Lars Michelsen Date: Fri Dec 18 08:41:07 2015 +0100 Improved "omd restore" error handling --- Changelog | 2 ++ packages/omd/omd | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index c5f6fa1..ce024b1 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,8 @@ This file documents the revision history for the Open Monitoring Distribution 1.40 (not yet released) - omd: - FIX: Fixed streamed "omd restore" resulting in an exception + - FIX: Improved "omd restore" error handling in case of trying + to restore invalid backup files - Apache: - Removed the shared mode (only one system wide apache process). This mode was not used widely and it was a pain to maintain it, diff --git a/packages/omd/omd b/packages/omd/omd index 7aa2b41..b8a2f60 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -3218,7 +3218,10 @@ def main_restore(args, options={}): else: bail_out("The backup archive does not exist.") - tar = tarfile.open(fileobj=fh, mode=tar_mode) + try: + tar = tarfile.open(fileobj=fh, mode=tar_mode) + except tarfile.ReadError, e: + bail_out("Failed to open the backup: %s" % e) # Get the first file of the tar archive. Expecting /version symlink # for validation reasons. From git at mathias-kettner.de Fri Dec 18 08:41:12 2015 From: git at mathias-kettner.de (git version control) Date: Fri, 18 Dec 2015 08:41:12 +0100 Subject: [omd-commits] OMD Git: omd: omd: Improved error message when trying omd action as non site user Message-ID: <20151218074112.6A56B803FC@mail.mathias-kettner.de> Module: omd Branch: master Commit: fd8ea6449fe90b352a0f1d851fb397a4d2a4aef9 URL: http://omdistro.org/projects/omd/repository/revisions/fd8ea6449fe90b352a0f1d851fb397a4d2a4aef9 Author: Lars Michelsen Date: Fri Dec 18 07:57:08 2015 +0100 Commiter: Lars Michelsen Date: Fri Dec 18 08:41:07 2015 +0100 omd: Improved error message when trying omd action as non site user --- Changelog | 1 + packages/omd/omd | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index ce024b1..1ce15b3 100644 --- a/Changelog +++ b/Changelog @@ -5,6 +5,7 @@ This file documents the revision history for the Open Monitoring Distribution - FIX: Fixed streamed "omd restore" resulting in an exception - FIX: Improved "omd restore" error handling in case of trying to restore invalid backup files + - Improved error message when trying omd action as non site user - Apache: - Removed the shared mode (only one system wide apache process). This mode was not used widely and it was a pain to maintain it, diff --git a/packages/omd/omd b/packages/omd/omd index b8a2f60..a7eda95 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -2286,6 +2286,11 @@ def call_scripts(phase): sys.stdout.write('Errors: %s\n' % stderr) +def check_site_user(site_must_exist): + if g_sitename != None and site_must_exist and not site_exists(g_sitename): + bail_out("omd: You need to execute omd as root or site user.") + + #. # .--Commands------------------------------------------------------------. # | ____ _ | @@ -3673,8 +3678,7 @@ if needs_site > 0: else: g_sitename = site_name() -if g_sitename != None and site_must_exist and not site_exists(g_sitename): - bail_out("omd: no such site: %s" % g_sitename) +check_site_user(site_must_exist) # Commands operating on an existing site *must* run omd in # the same version as the site has! Sole exception: update. From git at mathias-kettner.de Fri Dec 18 08:41:12 2015 From: git at mathias-kettner.de (git version control) Date: Fri, 18 Dec 2015 08:41:12 +0100 Subject: [omd-commits] OMD Git: omd: omd: Printing usage info in case of unknown command Message-ID: <20151218074112.7EB5580466@mail.mathias-kettner.de> Module: omd Branch: master Commit: a1670e5c48fb62a41d082608bf53b2aace09a7ac URL: http://omdistro.org/projects/omd/repository/revisions/a1670e5c48fb62a41d082608bf53b2aace09a7ac Author: Lars Michelsen Date: Fri Dec 18 08:01:10 2015 +0100 Commiter: Lars Michelsen Date: Fri Dec 18 08:41:07 2015 +0100 omd: Printing usage info in case of unknown command --- Changelog | 1 + packages/omd/omd | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 1ce15b3..0093e97 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ This file documents the revision history for the Open Monitoring Distribution - FIX: Improved "omd restore" error handling in case of trying to restore invalid backup files - Improved error message when trying omd action as non site user + - Printing usage info in case of unknown command - Apache: - Removed the shared mode (only one system wide apache process). This mode was not used widely and it was a pain to maintain it, diff --git a/packages/omd/omd b/packages/omd/omd index a7eda95..6757194 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -3655,7 +3655,9 @@ for c, only_root, no_suid, needs_site, site_must_exist, confirm, argumentlist, \ break if not found: - bail_out("omd: no such command: %s" % command) + sys.stderr.write("omd: no such command: %s\n" % command) + main_help() + sys.exit(1) if os.getuid() != 0 and only_root: bail_out("omd: root permissions are needed for this command.") From git at mathias-kettner.de Wed Dec 30 19:08:38 2015 From: git at mathias-kettner.de (git version control) Date: Wed, 30 Dec 2015 19:08:38 +0100 Subject: [omd-commits] OMD Git: omd: omd backup: Can use --no-rrds, --no-logs or --no-past now Message-ID: <20151230180838.A0BF78409C@mail.mathias-kettner.de> Module: omd Branch: master Commit: 18e4780f3ad836c45fdac7b49b58722e86e5e83a URL: http://omdistro.org/projects/omd/repository/revisions/18e4780f3ad836c45fdac7b49b58722e86e5e83a Author: Lars Michelsen Date: Wed Dec 30 19:07:06 2015 +0100 Commiter: Lars Michelsen Date: Wed Dec 30 19:07:06 2015 +0100 omd backup: Can use --no-rrds,--no-logs or --no-past now Can be used to exclude RRDs and/or the monitoring history from the backup. These options can be used to make the backup/restore procedure faster and reduces the size of the backup, but it is not a complete backup. --- Changelog | 4 ++++ packages/omd/omd | 45 ++++++++++++++++++++++++++++++++++++--------- packages/omd/omd.8 | 20 ++++++++++++++++++-- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/Changelog b/Changelog index 502ee71..a1f0a36 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,10 @@ This file documents the revision history for the Open Monitoring Distribution to restore invalid backup files - FIX: Added missing but documented --conflict flag to "omd restore" - FIX: Skipping partially created sites during omd start/stop/restart + - omd backup: Can use --no-rrds,--no-logs or --no-past now to + exclude RRDs and/or the monitoring history from the backup. These + options can be used to make the backup/restore procedure faster + and reduces the size of the backup, but it is not a complete backup. - Improved error message when trying omd action as non site user - Printing usage info in case of unknown command - Apache: diff --git a/packages/omd/omd b/packages/omd/omd index c552a6b..93994a2 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -24,7 +24,8 @@ # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. -import sys, os, shutil, pwd, grp, re, time, pprint, tty, termios, traceback, tarfile +import sys, os, shutil, pwd, grp, re, time, pprint, tty, termios, traceback +import tarfile, fnmatch from subprocess import * OMD_VERSION = "1.30" @@ -3176,7 +3177,29 @@ def main_su(args, options={}): bail_out("Cannot open a shell for user %s" % g_sitename) -def backup_site_to_tarfile(fh): +def backup_site_files_to_tarfile(tar, options): + exclude = get_exclude_patterns(options) + + def filter_files(filename): + for glob_pattern in exclude: + # patterns are relative to site dir, filename is full path. + # strip of the g_sitedir prefix from full path + if fnmatch.fnmatch(filename[len(g_sitedir)+1:], glob_pattern): + return True # exclude this file + return False + + if not exclude: + tar.add(g_sitedir, g_sitename) + else: + try: + tar.add(g_sitedir, g_sitename, exclude=filter_files) + except TypeError: + bail_out("You can not exclude files from your backup using your " + "Python version %s. You may need to update." % + ".".join(map(str, sys.version_info[:3]))) + + +def backup_site_to_tarfile(fh, options): tar = tarfile.open(fileobj=fh, mode='w:gz') try: # Add the version symlink as first file to be able to @@ -3185,7 +3208,7 @@ def backup_site_to_tarfile(fh): # The file is added twice to get the first for validation # and the second for excration during restore. tar.add(g_sitedir + "/version", g_sitename + "/version") - tar.add(g_sitedir, g_sitename) + backup_site_files_to_tarfile(tar, options) tar.close() except IOError, e: bail_out("Failed to perform backup: %s" % e) @@ -3211,7 +3234,7 @@ def main_backup(args, options={}): dest = g_orig_wd + '/' + dest fh = file(dest, 'w') - backup_site_to_tarfile(fh) + backup_site_to_tarfile(fh, options) def main_restore(args, options={}): @@ -3330,6 +3353,12 @@ def main_restore(args, options={}): finalize_site("restore", "apache-reload" in options) +exclude_options = [ + ( "no-rrds", None, False, "do not copy RRD files (performance data"), + ( "no-logs", None, False, "do not copy log files"), + ( "no-past", "N", False, "do not copy RRD file and log files"), +] + commands = [ # command The id of the command @@ -3453,10 +3482,8 @@ commands = [ ( "cp", True, False, 1, 1, False, "NEWNAME", lambda args, opts: main_mv_or_cp("cp", args, opts), [ ( "uid", "u", True, "create site user with UID ARG" ), ( "gid", "g", True, "create site group with GID ARG" ), - ( "reuse", None, False, "do not create a site user, reuse existing one" ), - ( "no-rrds", None, False, "do not copy RRD files (performance data"), - ( "no-logs", None, False, "do not copy log files"), - ( "no-past", "N", False, "do not copy RRD file and log files"), + ( "reuse", None, False, "do not create a site user, reuse existing one" ) + ] + exclude_options + [ ( "conflict", None, True, "non-interactive conflict resolution. ARG is install, keepold, abort or ask"), ( "tmpfs-size", "t", True, "specify the maximum size of the tmpfs (defaults to 50% of RAM), examples: 500M, 20G, 60%"), ( "apache-reload", False, False, "Issue a reload of the system apache instead of a restart"), @@ -3518,7 +3545,7 @@ commands = [ ""), ( "backup", False, True, 1, 1, False, "SITE [-|ARCHIVE_PATH]", main_backup, - [ ], + exclude_options, "Create a backup tarball of a site, writing it to a file or stdout", ""), diff --git a/packages/omd/omd.8 b/packages/omd/omd.8 index 69d02a2..151d006 100644 --- a/packages/omd/omd.8 +++ b/packages/omd/omd.8 @@ -366,18 +366,34 @@ using it (have a directory in it as current directory are have an open file in i If you specify \fB--kill\fP, then omd will kill processes using the filesystem using \fBfuser -k\fP. .TP -.B omd backup [SITE] [-|TARBALL_PATH] +.B omd backup [OPTIONS] [SITE] [-|TARBALL_PATH] Creates a backup tarball containing the whole site. When executing this command as root, you need to specify the name of the site, otherwise your current site will be used. You need to provide either a path where the tarball will be created or specify \fB-\fP for streaming the tarball to stdout. +The following options can be used: + +\fB--no-rrds\fP Do not copy any performance data from the past. This +includes RRD and XML files created by PNP4Nagios as well as journal +files from the RRD caching daemon. This option usually greatly speeds +up the copying. + +\fB--no-logs\fP Do not copy any logfiles from the past. This +include the Nagios logfiles, which bear the historical events. While +this does speed up the copying, the new site will have no history +of past events. + +The option \fB-N\fP or \fB--no-past\fP combines both \fB--no-rrds\fP and \fB--no-logs\fP. +This is very useful especially for copies that are created for testing +purposes. + The site needs to be stopped to be able to create the backup. During the backup the ramdisk filesystem (tmpfs) of the site will be unmounted. It's contents are not saved in the tarball. .TP -.B omd restore [SITE] [-|TARBALL_PATH] +.B omd restore [OPTIONS] [SITE] [-|TARBALL_PATH] Restores a backup which was previously created with \fBomd backup\fP. This command is only available as root user at the moment. From git at mathias-kettner.de Wed Dec 30 19:08:38 2015 From: git at mathias-kettner.de (git version control) Date: Wed, 30 Dec 2015 19:08:38 +0100 Subject: [omd-commits] OMD Git: omd: omd: Improved error handling of invalid tarballs during restore Message-ID: <20151230180838.B0A148409B@mail.mathias-kettner.de> Module: omd Branch: master Commit: 75d4a47d501e1335feb0ad84aeec8d2d266764e2 URL: http://omdistro.org/projects/omd/repository/revisions/75d4a47d501e1335feb0ad84aeec8d2d266764e2 Author: Lars Michelsen Date: Sun Dec 20 22:15:29 2015 +0100 Commiter: Lars Michelsen Date: Sun Dec 20 22:15:35 2015 +0100 omd: Improved error handling of invalid tarballs during restore --- packages/omd/omd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/omd/omd b/packages/omd/omd index 8ace3e1..74455e0 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -3231,7 +3231,11 @@ def main_restore(args, options={}): # Get the first file of the tar archive. Expecting /version symlink # for validation reasons. site_tarinfo = tar.next() - sitename, version_name = site_tarinfo.name.split("/", 1) + try: + sitename, version_name = site_tarinfo.name.split("/", 1) + except ValueError: + bail_out("Failed to detect version of backed up site. " + "Maybe the backup is from an incompatible version.") if version_name == "version": version = site_tarinfo.linkname.split('/')[-1] From git at mathias-kettner.de Wed Dec 30 19:08:38 2015 From: git at mathias-kettner.de (git version control) Date: Wed, 30 Dec 2015 19:08:38 +0100 Subject: [omd-commits] OMD Git: omd: omd: Some small refactorings Message-ID: <20151230180838.BDEBC84098@mail.mathias-kettner.de> Module: omd Branch: master Commit: ee07b2ab17b05d3a1eba927cd66fa7a0d8b1438a URL: http://omdistro.org/projects/omd/repository/revisions/ee07b2ab17b05d3a1eba927cd66fa7a0d8b1438a Author: Lars Michelsen Date: Wed Dec 30 18:43:48 2015 +0100 Commiter: Lars Michelsen Date: Wed Dec 30 18:43:48 2015 +0100 omd: Some small refactorings --- packages/omd/omd | 72 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/packages/omd/omd b/packages/omd/omd index 6350a1d..c552a6b 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -2721,6 +2721,26 @@ def set_conflict_option(options): bail_out("Argument to --conflict must be one of ask, install, keepold and abort.") +def get_exclude_patterns(options): + excludes = [] + if "no-rrds" in options or "no-past" in options: + excludes.append("var/pnp4nagios/perfdata/*") + excludes.append("var/pnp4nagios/spool/*") + excludes.append("var/rrdcached/*") + excludes.append("var/pnp4nagios/states/*") + + if "no-logs" in options or "no-past" in options: + excludes.append("var/log/*/*") + excludes.append("var/nagios/nagios.log") + excludes.append("var/nagios/archive/") + excludes.append("var/pnp4nagios/log/*") + excludes.append("var/pnp4nagios/perfdata.dump") + excludes.append("var/mkeventd/history/*") + excludes.append("var/check_mk/core/history") + excludes.append("var/check_mk/core/archive/*") + return excludes + + def main_mv_or_cp(what, args, options={}): set_conflict_option(options) action = what == "mv" and "rename" or "copy" @@ -2772,24 +2792,9 @@ def main_mv_or_cp(what, args, options={}): # Make exact file-per-file copy with same user but already new name if not reuse: os.mkdir(site_dir(new)) + addopts = "" - excludes = [] - if "no-rrds" in options or "no-past" in options: - excludes.append("var/pnp4nagios/perfdata/*") - excludes.append("var/pnp4nagios/spool/*") - excludes.append("var/rrdcached/*") - excludes.append("var/pnp4nagios/states/*") - if "no-logs" in options or "no-past" in options: - excludes.append("var/log/*/*") - excludes.append("var/nagios/nagios.log") - excludes.append("var/nagios/archive/") - excludes.append("var/pnp4nagios/log/*") - excludes.append("var/pnp4nagios/perfdata.dump") - excludes.append("var/mkeventd/history/*") - excludes.append("var/check_mk/core/history") - excludes.append("var/check_mk/core/archive/*") - - for p in excludes: + for p in get_exclude_patterns(options): addopts += " --exclude '/%s'" % p if opt_verbose: @@ -3170,10 +3175,23 @@ def main_su(args, options={}): except OSError: bail_out("Cannot open a shell for user %s" % g_sitename) -def main_backup(args, options={}): - global g_sitename - global g_sitedir +def backup_site_to_tarfile(fh): + tar = tarfile.open(fileobj=fh, mode='w:gz') + try: + # Add the version symlink as first file to be able to + # check a) the sitename and b) the version before reading + # the whole tar archive. Important for streaming. + # The file is added twice to get the first for validation + # and the second for excration during restore. + tar.add(g_sitedir + "/version", g_sitename + "/version") + tar.add(g_sitedir, g_sitename) + tar.close() + except IOError, e: + bail_out("Failed to perform backup: %s" % e) + + +def main_backup(args, options={}): if len(args) == 0: bail_out("You need to provide either a path to the destination " "file or \"-\" for backup to stdout.") @@ -3193,18 +3211,8 @@ def main_backup(args, options={}): dest = g_orig_wd + '/' + dest fh = file(dest, 'w') - tar = tarfile.open(fileobj=fh, mode='w:gz') - try: - # Add the version symlink as first file to be able to - # check a) the sitename and b) the version before reading - # the whole tar archive. Important for streaming. - # The file is added twice to get the first for validation - # and the second for excration during restore. - tar.add(g_sitedir + "/version", g_sitename + "/version") - tar.add(g_sitedir, g_sitename) - tar.close() - except IOError, e: - bail_out("Failed to perform backup: %s" % e) + backup_site_to_tarfile(fh) + def main_restore(args, options={}): global g_sitename From git at mathias-kettner.de Wed Dec 30 19:08:38 2015 From: git at mathias-kettner.de (git version control) Date: Wed, 30 Dec 2015 19:08:38 +0100 Subject: [omd-commits] OMD Git: omd: FIX: Added missing but documented --conflict flag to " omd restore" Message-ID: <20151230180838.CB8ED8409A@mail.mathias-kettner.de> Module: omd Branch: master Commit: 8a9d16b862331808834e68834f0e7f8367176187 URL: http://omdistro.org/projects/omd/repository/revisions/8a9d16b862331808834e68834f0e7f8367176187 Author: Lars Michelsen Date: Sun Dec 20 22:05:33 2015 +0100 Commiter: Lars Michelsen Date: Sun Dec 20 22:05:33 2015 +0100 FIX: Added missing but documented --conflict flag to "omd restore" --- Changelog | 1 + packages/omd/omd | 1 + 2 files changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 0093e97..b49c2a2 100644 --- a/Changelog +++ b/Changelog @@ -5,6 +5,7 @@ This file documents the revision history for the Open Monitoring Distribution - FIX: Fixed streamed "omd restore" resulting in an exception - FIX: Improved "omd restore" error handling in case of trying to restore invalid backup files + - FIX: Added missing but documented --conflict flag to "omd restore" - Improved error message when trying omd action as non site user - Printing usage info in case of unknown command - Apache: diff --git a/packages/omd/omd b/packages/omd/omd index 6757194..8ace3e1 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -3513,6 +3513,7 @@ commands = [ ( "reuse", None, False, "do not create a site user, reuse existing one" ), ( "kill", None, False, "kill processes of site when reusing an existing one before restoring" ), ( "apache-reload", False, False, "Issue a reload of the system apache instead of a restart"), + ( "conflict", None, True, "non-interactive conflict resolution. ARG is install, keepold, abort or ask"), ( "tmpfs-size", "t", True, "specify the maximum size of the tmpfs (defaults to 50% of RAM)"), ], "Restores the backup of a site to an existing site or creates a new site", From git at mathias-kettner.de Wed Dec 30 19:08:38 2015 From: git at mathias-kettner.de (git version control) Date: Wed, 30 Dec 2015 19:08:38 +0100 Subject: [omd-commits] OMD Git: omd: omd: FIX: Skipping partially created sites during omd start/ stop/restart Message-ID: <20151230180838.E579C84097@mail.mathias-kettner.de> Module: omd Branch: master Commit: 972c6127222a25f684ff3fe33d5d4beb309de5b3 URL: http://omdistro.org/projects/omd/repository/revisions/972c6127222a25f684ff3fe33d5d4beb309de5b3 Author: Lars Michelsen Date: Wed Dec 30 18:33:08 2015 +0100 Commiter: Lars Michelsen Date: Wed Dec 30 18:33:08 2015 +0100 omd: FIX: Skipping partially created sites during omd start/stop/restart --- Changelog | 1 + packages/omd/omd | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index b49c2a2..502ee71 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ This file documents the revision history for the Open Monitoring Distribution - FIX: Improved "omd restore" error handling in case of trying to restore invalid backup files - FIX: Added missing but documented --conflict flag to "omd restore" + - FIX: Skipping partially created sites during omd start/stop/restart - Improved error message when trying omd action as non site user - Printing usage info in case of unknown command - Apache: diff --git a/packages/omd/omd b/packages/omd/omd index 74455e0..6350a1d 100644 --- a/packages/omd/omd +++ b/packages/omd/omd @@ -3096,7 +3096,10 @@ def main_init_action(command, args, options={}): if not g_sitename: exit_states = [] for site in all_sites(): - if only_version and site_version(site) != only_version: + v = site_version(site) + if v == None: # skip partially created sites + continue + if only_version and v != only_version: continue # Skip disabled sites completely if site_is_disabled(site):