From f6509836066d8746c53824a65e14d6b7e3584d11 Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Thu, 1 Jun 2017 14:41:12 +0200 Subject: [PATCH 1/3] Bug #337628: umc-diagnostic: new check check_update_sites This is the original check by Julian Hupertz, written as part of his masters thesis. --- .../diagnostic/plugins/check_update_sites.py | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py new file mode 100644 index 0000000..6cf64c8 --- /dev/null +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py @@ -0,0 +1,63 @@ +#!/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 +# . + +import requests +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 errors with update sites') +description = _('No new problems were found while connecting to updates sites') + + +def run(): + ucr = univention.config_registry.ConfigRegistry() + ucr.load() + description_items = [] + sites = ucr.get("repository/credentials/Univention Software Repository/uris").split(" ") + for site in sites: + uri = "https://%s" % (site) + code = requests.get(uri).status_code + if not code == 200: + description_items.append("Errorcode %s during connecting to %s" % (code, uri)) + if len(description_items) > 0: + description = "\n".join(description_items) + raise Warning(description) + + +if __name__ == '__main__': + from univention.management.console.modules.diagnostic import main + main() -- 2.7.4 From 4d1f281f9319520be2d9886d0e6d1e4db72a6608 Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Thu, 1 Jun 2017 16:01:19 +0200 Subject: [PATCH 2/3] Bug #337628: umc-diagnostic: simplify new check check_update_sites --- .../diagnostic/plugins/check_update_sites.py | 56 +++++++++++++++------- 1 file changed, 40 insertions(+), 16 deletions(-) mode change 100644 => 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py old mode 100644 new mode 100755 index 6cf64c8..b21ccf3 --- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_update_sites.py @@ -31,31 +31,55 @@ # /usr/share/common-licenses/AGPL-3; if not, see # . -import requests -import univention.config_registry +import socket +import urlparse +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 errors with update sites') -description = _('No new problems were found while connecting to updates sites') +title = _('Check resolving repository servers') +description = _('No problems were found while resolving update respositories.') +links = [{ + 'name': 'sdb', + 'href': _('http://sdb.univention.de/1298'), + 'label': _('Univention Support Database - DNS Server on DC does not resolve external names') +}] + + +def repositories(): + configRegistry = univention.config_registry.ConfigRegistry() + configRegistry.load() + + if configRegistry.is_true('repository/online', True): + yield configRegistry.get('repository/online/server', 'updates.software-univention.de/') + yield configRegistry.get('repository/app_center/server', 'appcenter.software-univention.de') + + +def test_resolve(url): + parsed = urlparse.urlsplit(url if '//' in url else '//' + url) + try: + socket.getaddrinfo(parsed.hostname, parsed.scheme) + except socket.gaierror: + return False + return True + + +def unresolvable_repositories(): + for repository in repositories(): + if not test_resolve(repository): + yield repository def run(): - ucr = univention.config_registry.ConfigRegistry() - ucr.load() - description_items = [] - sites = ucr.get("repository/credentials/Univention Software Repository/uris").split(" ") - for site in sites: - uri = "https://%s" % (site) - code = requests.get(uri).status_code - if not code == 200: - description_items.append("Errorcode %s during connecting to %s" % (code, uri)) - if len(description_items) > 0: - description = "\n".join(description_items) - raise Warning(description) + error_descriptions = [_('The following FQDNs were not resolvable:')] + unresolvable = list(unresolvable_repositories()) + if unresolvable: + error_descriptions.extend(unresolvable) + error_descriptions.append(_('Please see {sdb} for troubleshooting DNS problems.')) + raise Warning(description='\n'.join(error_descriptions)) if __name__ == '__main__': -- 2.7.4 From 52fce3c58b60d445dc3b062c25a3af263cdeca7a Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Thu, 1 Jun 2017 16:09:22 +0200 Subject: [PATCH 3/3] Bug #337628: umc-diagnostic: simplify new check check_update_sites (po) --- .../umc/python/diagnostic/de.po | 31 ++++++++++++++++++++-- 1 file changed, 29 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..e455649 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-01 16:16+0200\n" "PO-Revision-Date: \n" "Last-Translator: Univention GmbH \n" "Language-Team: Univention GmbH \n" @@ -27,6 +27,10 @@ msgstr "" msgid "Adjust to suggested limits" msgstr "An vorgeschlagene Limits anpassen" +#: umc/python/diagnostic/plugins/check_update_sites.py:43 +msgid "Check resolving repository servers" +msgstr "Überprüfe DNS Auflösung der Repository Server" + #: umc/python/diagnostic/plugins/gateway.py:11 msgid "Gateway is not reachable" msgstr "Gateway ist nicht erreichbar" @@ -97,6 +101,10 @@ msgstr "" msgid "Nameserver(s) are not responsive" msgstr "Nameserver sind nicht ansprechbar" +#: umc/python/diagnostic/plugins/check_update_sites.py:44 +msgid "No problems were found while resolving update respositories." +msgstr "Es wurden keine Probleme beim Auflösen der Repository-Server gefunden." + #: umc/python/diagnostic/plugins/package_status.py:11 msgid "Package status corrupt" msgstr "Paketstatus korrupt" @@ -125,6 +133,11 @@ msgstr "" "Der SSH Host-Key in /root/.ssh/known_hosts des entfernten Rechners muss auf " "%(fqdn)s repariert werden." +#: umc/python/diagnostic/plugins/check_update_sites.py:81 +#, python-brace-format +msgid "Please see {sdb} for troubleshooting DNS problems." +msgstr "Siehe {sdb} für Problemhilfe bei DNS Problemen." + #: umc/python/diagnostic/plugins/proxy.py:15 msgid "Proxy server failure" msgstr "Proxy-Server-Fehler" @@ -141,6 +154,10 @@ msgstr "Sicherheitslimits überschritten" msgid "Test again" msgstr "Erneut testen" +#: umc/python/diagnostic/plugins/check_update_sites.py:77 +msgid "The following FQDNs were not resolvable:" +msgstr "Die folgenden FQDNs waren nicht auflösbar:" + #: umc/python/diagnostic/plugins/ssh_connection.py:48 msgid "" "The following list shows the affected remote servers and the reason for the " @@ -260,6 +277,16 @@ 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_update_sites.py:48 +msgid "" +"Univention Support Database - DNS Server on DC does not resolve external " +"names" +msgstr "" + +#: umc/python/diagnostic/plugins/check_update_sites.py:47 +msgid "http://sdb.univention.de/1298" +msgstr "" + #: umc/python/diagnostic/plugins/package_status.py:28 msgid "some" msgstr "einigen" -- 2.7.4