From 8d108077f03f36982056862e6a98503c853be04a Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 27 Jun 2017 16:38:51 +0200 Subject: [PATCH 1/3] Bug #xxx: umc-diagnostic: new check `check_notifier_replication.py Original `check_ldap_replication.py` written by Julian Hupertz (with slight cleanup). --- .../plugins/check_notifier_replication.py | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py new file mode 100644 index 0000000..a4897fb --- /dev/null +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py @@ -0,0 +1,67 @@ +#!/usr/bin/python2.7 +# coding: utf-8 +# +# Univention Management Console module: +# System Diagnosis UMC module +# +# Copyright 2016-2017 Univention GmbH +# +# http://www.univention.de/ +# +# All rights reserved. +# +# The source code of this program is made available +# under the terms of the GNU Affero General Public License version 3 +# (GNU AGPL V3) as published by the Free Software Foundation. +# +# Binary versions of this program provided by Univention to you as +# well as other copyrighted, protected or trademarked materials like +# Logos, graphics, fonts, specific documentations and configurations, +# cryptographic keys etc. are subject to a license agreement between +# you and Univention and not subject to the GNU AGPL V3. +# +# In the case you use this program under the terms of the GNU AGPL V3, +# the program is provided 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 with the Debian GNU/Linux or Univention distribution in file +# /usr/share/common-licenses/AGPL-3; if not, see +# . + +from subprocess import Popen, PIPE, STDOUT +from univention.management.console.modules.diagnostic import Critical + +from univention.lib.i18n import Translation +_ = Translation('univention-management-console-module-diagnostic').translate + +title = _('Check for problems with ldap replication') +description = _('No problems found with ldap replication') + + +def run(): + process = Popen(["/usr/share/univention-directory-listener/get_notifier_id.py"], stdout=PIPE, stderr=STDOUT) + if process.returncode: + description = _("Calling /usr/share/univention-directory-listener/get_notifier_id.py faield") + raise Critical("\n".join([ + description, + "Returncode of process: %s" % (process.returncode) + ])) + stdout, stderr = process.communicate() + f = open("/var/lib/univention-directory-listener/notifier_id", "r") + s = f.read() + if stdout.rstrip() == s: + return + else: + description = _("Notifier ids are different.") + raise Critical("\n".join([ + description, + "Id from Master: %s" % (stdout.rstrip()), + "Id from local system: %s" % (s) + ])) + +if __name__ == '__main__': + from univention.management.console.modules.diagnostic import main + main() -- 2.7.4 From 62652f3f0e2cba2f4919fa5d34f67e1ea073d66e Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 27 Jun 2017 17:01:00 +0200 Subject: [PATCH 2/3] Bug #xxx: umc-diagnostic: simplify `check_notifier_replication.py` --- .../plugins/check_notifier_replication.py | 64 ++++++++++++++-------- 1 file changed, 42 insertions(+), 22 deletions(-) mode change 100644 => 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py old mode 100644 new mode 100755 index a4897fb..4a2c579 --- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_notifier_replication.py @@ -31,36 +31,56 @@ # /usr/share/common-licenses/AGPL-3; if not, see # . -from subprocess import Popen, PIPE, STDOUT -from univention.management.console.modules.diagnostic import Critical +import socket + +import univention.config_registry +from univention.management.console.modules.diagnostic import Warning from univention.lib.i18n import Translation _ = Translation('univention-management-console-module-diagnostic').translate -title = _('Check for problems with ldap replication') -description = _('No problems found with ldap replication') +title = _('Check for problems with UDN replication') +description = _('No problems found with UDN replication.') + +links = [{ + 'name': 'sdb', + 'href': _('http://sdb.univention.de/content/14/295/en/troubleshooting-listener__notifier.html'), + 'label': _('Univention Support Database - Troubleshooting: Listener-/Notifier') +}] + + +def get_id(master, cmd='GET_ID'): + sock = socket.create_connection((master, 6669)) + + sock.send('Version: 2\nCapabilities: \n\n') + sock.recv(100) + + sock.send('MSGID: 1\n{cmd}\n\n'.format(cmd=cmd)) + notifier_result = sock.recv(100).strip() + + (msg_id, notifier_id) = notifier_result.split('\n', 1) + return notifier_id def run(): - process = Popen(["/usr/share/univention-directory-listener/get_notifier_id.py"], stdout=PIPE, stderr=STDOUT) - if process.returncode: - description = _("Calling /usr/share/univention-directory-listener/get_notifier_id.py faield") - raise Critical("\n".join([ - description, - "Returncode of process: %s" % (process.returncode) - ])) - stdout, stderr = process.communicate() - f = open("/var/lib/univention-directory-listener/notifier_id", "r") - s = f.read() - if stdout.rstrip() == s: - return + configRegistry = univention.config_registry.ConfigRegistry() + configRegistry.load() + + try: + notifier_id = get_id(configRegistry.get('ldap/master')) + except socket.error: + raise Warning(_('Error retrieving notifier ID from the UDN.')) else: - description = _("Notifier ids are different.") - raise Critical("\n".join([ - description, - "Id from Master: %s" % (stdout.rstrip()), - "Id from local system: %s" % (s) - ])) + with open('/var/lib/univention-directory-listener/notifier_id') as fob: + id_from_file = fob.read().strip() + + if notifier_id != id_from_file: + ed = [ + _('Univention Directory Notifier ID and the locally stored version differ.'), + _('This might indicate an error or still processing transactions.') + ] + raise Warning('\n'.join(ed)) + if __name__ == '__main__': from univention.management.console.modules.diagnostic import main -- 2.7.4 From c68fb0b9c31b76b5b2d76990c55988a77864c230 Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 27 Jun 2017 17:06:56 +0200 Subject: [PATCH 3/3] Bug #xxx: umc-diagnostic: new check `check_notifier_replication.py` (po) --- .../umc/python/diagnostic/de.po | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po index affad86..ce019d9 100644 --- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: univention-management-console-module-diagnostic\n" -"Report-Msgid-Bugs-To: packages@univention.de\n" -"POT-Creation-Date: 2016-01-14 12:19+0100\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-27 17:06+0200\n" "PO-Revision-Date: \n" "Last-Translator: Univention GmbH \n" "Language-Team: Univention GmbH \n" @@ -27,6 +27,14 @@ msgstr "" msgid "Adjust to suggested limits" msgstr "An vorgeschlagene Limits anpassen" +#: umc/python/diagnostic/plugins/check_notifier_replication.py:42 +msgid "Check for problems with UDN replication" +msgstr "Überprüfe Probleme mit der UDN Replikation" + +#: umc/python/diagnostic/plugins/check_notifier_replication.py:72 +msgid "Error retrieving notifier ID from the UDN." +msgstr "Fehler beim Abrufen der letzten Transaktions ID vom UDN." + #: umc/python/diagnostic/plugins/gateway.py:11 msgid "Gateway is not reachable" msgstr "Gateway ist nicht erreichbar" @@ -97,6 +105,10 @@ msgstr "" msgid "Nameserver(s) are not responsive" msgstr "Nameserver sind nicht ansprechbar" +#: umc/python/diagnostic/plugins/check_notifier_replication.py:43 +msgid "No problems found with UDN replication." +msgstr "Keine Prolbleme mit der UDN Replikation gefunden." + #: umc/python/diagnostic/plugins/package_status.py:11 msgid "Package status corrupt" msgstr "Paketstatus korrupt" @@ -249,6 +261,11 @@ msgstr "" "an Samba-Servern unmöglich, Dateioperationen (Kopieren, Verschieben) auf " "Freigaben kann fehlschlagen, uvm.)" +#: umc/python/diagnostic/plugins/check_notifier_replication.py:80 +msgid "This might indicate an error or still processing transactions." +msgstr "" +"Dies mag auf einen Fehler oder noch ausstehende Transaktionen hinweisen." + #: umc/python/diagnostic/plugins/proxy.py:83 #, python-format msgid "" @@ -260,6 +277,22 @@ msgstr "" "dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die " "ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen." +#: umc/python/diagnostic/plugins/check_notifier_replication.py:79 +msgid "Univention Directory Notifier ID and the locally stored version differ." +msgstr "" +"Univention Directory Notifier ID und die lokal gespeicherte Version " +"unterscheiden sich." + +#: umc/python/diagnostic/plugins/check_notifier_replication.py:48 +msgid "Univention Support Database - Troubleshooting: Listener-/Notifier" +msgstr "" + +#: umc/python/diagnostic/plugins/check_notifier_replication.py:47 +msgid "" +"http://sdb.univention.de/content/14/295/en/troubleshooting-" +"listener__notifier.html" +msgstr "" + #: umc/python/diagnostic/plugins/package_status.py:28 msgid "some" msgstr "einigen" -- 2.7.4