View | Details | Raw Unified | Return to bug 35859
Collapse All | Expand All

(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/disk_usage.py (-2 / +148 lines)
Line 0    Link Here 
0
- 
1
#!/usr/bin/python2.7
1
--
2
# coding: utf-8
3
#
4
# Univention Management Console module:
5
#  System Diagnosis UMC module
6
#
7
# Copyright 2017 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
34
import psutil
35
36
import univention.config_registry
37
from univention.management.console.modules.diagnostic import Warning, Critical
38
39
from univention.lib.i18n import Translation
40
_ = Translation('univention-management-console-module-diagnostic').translate
41
42
title = _('Check free disk space')
43
description = _('Enough free disk space available.')
44
45
DISK_USAGE_THRESHOLD = 90
46
47
48
def mount_points():
49
	for dp in psutil.disk_partitions():
50
		yield dp.mountpoint
51
52
53
def high_disk_usage():
54
	high = ((mp, psutil.disk_usage(mp).percent) for mp in mount_points())
55
	return {mp: pc for (mp, pc) in high if pc > DISK_USAGE_THRESHOLD}
56
57
58
def local_repository_exists():
59
	configRegistry = univention.config_registry.ConfigRegistry()
60
	configRegistry.load()
61
	return configRegistry.is_true('local/repository', False)
62
63
64
def is_varlog_own_partition():
65
	mp = set(mount_points())
66
	return '/var' in mp or '/var/log' in mp
67
68
69
def high_log_levels():
70
	def is_high(variable, default):
71
		return lambda ucr: int(ucr.get(variable, default)) > default
72
73
	def is_on(variable):
74
		return lambda ucr: ucr.is_true(variable, False)
75
76
	checks = (
77
		is_high('connector/debug/function', 0),
78
		is_high('connector/debug/level', 2),
79
		is_high('samba/debug/level', 33),
80
		is_high('directory/manager/cmd/debug/level', 0),
81
		is_high('dns/debug/level', 0),
82
		is_high('dns/dlz/debug/level', 0),
83
		is_high('ldap/debug/level', 0),
84
		is_high('listener/debug/level', 2),
85
		is_high('mail/postfix/ldaptable/debuglevel', 0),
86
		is_high('notifier/debug/level', 1),
87
		is_high('nscd/debug/level', 0),
88
		is_high('stunnel/debuglevel', 4),
89
		is_high('umc/module/debug/level', 2),
90
		is_high('umc/server/debug/level', 2),
91
		is_high('grub/loglevel', 0),
92
		is_high('mail/postfix/smtp/tls/loglevel', 0),
93
		is_high('mail/postfix/smtpd/tls/loglevel', 0),
94
		is_on('kerberos/defaults/debug'),
95
		is_on('mail/postfix/smtpd/debug'),
96
		is_on('samba4/sysvol/sync/debug'),
97
		is_on('aml/idp/ldap/debug'),
98
		is_on('saml/idp/log/debug/enabled'),
99
		is_on('pdate/check/boot/debug'),
100
		is_on('update/check/cron/debug'),
101
		lambda ucr: ucr.get('apache2/loglevel', 'warn') in ('notice', 'info', 'debug')
102
	)
103
104
	configRegistry = univention.config_registry.ConfigRegistry()
105
	configRegistry.load()
106
	return any(check(configRegistry) for check in checks)
107
108
109
def solutions():
110
	yield _('You may want to uninstall software via {appcenter:appcenter}.')
111
	if not is_varlog_own_partition():
112
		yield _('You may want to move /var/log to another disk or storage.')
113
	if local_repository_exists():
114
		yield _('You may want to move the local repository to another server.')
115
	yield _('You may want to exchange the hard drive.')
116
117
118
def run():
119
	high = high_disk_usage()
120
	tmpl = _('- Disk for mountpoint %(mp)s is %(pc)s%% full.')
121
	disk_errors = [tmpl % {'mp': mp, 'pc': pc} for (mp, pc) in high.iteritems()]
122
123
	problem_on_root = '/' in high
124
	problem_on_varlog = '/var/log' in high or '/var' in high or \
125
		(problem_on_root and not is_varlog_own_partition())
126
127
	if disk_errors:
128
		umc_modules = [{'module': 'appcenter', 'flavor': 'appcenter'}]
129
		error_descriptions = [_('Some disks are nearly full:')]
130
		error_descriptions.extend(disk_errors)
131
132
		if problem_on_root:
133
			error_descriptions.append('\n'.join(solutions()))
134
135
		if problem_on_varlog and high_log_levels():
136
			lvl_errors = (_('You have configured some high log levels.'),
137
				_('You may want to reset them via {ucr}.'))
138
			umc_modules.append({'module': 'ucr'})
139
			error_descriptions.append(' '.join(lvl_errors))
140
141
		if problem_on_root:
142
			raise Critical('\n'.join(error_descriptions), umc_modules=umc_modules)
143
		raise Warning('\n'.join(error_descriptions), umc_modules=umc_modules)
144
145
146
if __name__ == '__main__':
147
	from univention.management.console.modules.diagnostic import main
148
	main()
2
.../umc/python/diagnostic/de.po                    | 47 +++++++++++++++++++++-
149
.../umc/python/diagnostic/de.po                    | 47 +++++++++++++++++++++-
3
1 file changed, 45 insertions(+), 2 deletions(-)
150
1 file changed, 45 insertions(+), 2 deletions(-)
(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po (-3 / +45 lines)
 Lines 2-9    Link Here 
2
msgid ""
2
msgid ""
3
msgstr ""
3
msgstr ""
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
5
"Report-Msgid-Bugs-To: \n"
6
"POT-Creation-Date: 2016-01-14 12:19+0100\n"
6
"POT-Creation-Date: 2017-06-06 17:08+0200\n"
7
"PO-Revision-Date: \n"
7
"PO-Revision-Date: \n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
 Lines 17-22   msgstr "" Link Here 
17
msgid "%d of the configured nameservers are not responding to DNS queries."
17
msgid "%d of the configured nameservers are not responding to DNS queries."
18
msgstr "%d der konfigurierten Nameserver anworten nicht auf DNS-Anfragen."
18
msgstr "%d der konfigurierten Nameserver anworten nicht auf DNS-Anfragen."
19
19
20
#: umc/python/diagnostic/plugins/disk_usage.py:120
21
#, python-format
22
msgid "- Disk for mountpoint %(mp)s is %(pc)s%% full."
23
msgstr "- Festplatte für Moint Point %(mp)s ist %(pc)s%% voll."
24
20
#: umc/python/diagnostic/plugins/nameserver.py:46
25
#: umc/python/diagnostic/plugins/nameserver.py:46
21
msgid "A timeout occurred while reaching the nameserver (is it online?)."
26
msgid "A timeout occurred while reaching the nameserver (is it online?)."
22
msgstr ""
27
msgstr ""
 Lines 27-32   msgstr "" Link Here 
27
msgid "Adjust to suggested limits"
32
msgid "Adjust to suggested limits"
28
msgstr "An vorgeschlagene Limits anpassen"
33
msgstr "An vorgeschlagene Limits anpassen"
29
34
35
#: umc/python/diagnostic/plugins/disk_usage.py:42
36
msgid "Check free disk space"
37
msgstr "Überprüfe freien Festplatten Platz"
38
39
#: umc/python/diagnostic/plugins/disk_usage.py:43
40
msgid "Enough free disk space available."
41
msgstr "Außreichend freier Festplatten Platz vorhanden."
42
30
#: umc/python/diagnostic/plugins/gateway.py:11
43
#: umc/python/diagnostic/plugins/gateway.py:11
31
msgid "Gateway is not reachable"
44
msgid "Gateway is not reachable"
32
msgstr "Gateway ist nicht erreichbar"
45
msgstr "Gateway ist nicht erreichbar"
 Lines 137-142   msgstr "SSH-Verbindung zu anderem UCS Server fehlgeschlagen!" Link Here 
137
msgid "Security limits exceeded"
150
msgid "Security limits exceeded"
138
msgstr "Sicherheitslimits überschritten"
151
msgstr "Sicherheitslimits überschritten"
139
152
153
#: umc/python/diagnostic/plugins/disk_usage.py:129
154
msgid "Some disks are nearly full:"
155
msgstr "Einige Festplatten sind beinahe voll:"
156
140
#: umc/python/diagnostic/__init__.py:262
157
#: umc/python/diagnostic/__init__.py:262
141
msgid "Test again"
158
msgid "Test again"
142
msgstr "Erneut testen"
159
msgstr "Erneut testen"
 Lines 260-265   msgstr "" Link Here 
260
"dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die "
277
"dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die "
261
"ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen."
278
"ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen."
262
279
280
#: umc/python/diagnostic/plugins/disk_usage.py:136
281
msgid "You have configured some high log levels."
282
msgstr "Sie haben erhöhten Detailgrad für Logmeldungen eingestellt."
283
284
#: umc/python/diagnostic/plugins/disk_usage.py:115
285
msgid "You may want to exchange the hard drive."
286
msgstr "Sie können die Festplatte austauschen."
287
288
#: umc/python/diagnostic/plugins/disk_usage.py:112
289
msgid "You may want to move /var/log to another disk or storage."
290
msgstr ""
291
"Sie können /var/log auf eine andere Festplatte oder Speicher verschieben."
292
293
#: umc/python/diagnostic/plugins/disk_usage.py:114
294
msgid "You may want to move the local repository to another server."
295
msgstr "Sie können lokale Repositorys auf einen anderen Server auslagern."
296
297
#: umc/python/diagnostic/plugins/disk_usage.py:137
298
#, python-brace-format
299
msgid "You may want to reset them via {ucr}."
300
msgstr "Sie können sie per {ucr} zurück setzen."
301
302
#: umc/python/diagnostic/plugins/disk_usage.py:110
303
msgid "You may want to uninstall software via {appcenter:appcenter}."
304
msgstr "Sie können per {appcenter:appcenter} Software entfernen."
305
263
#: umc/python/diagnostic/plugins/package_status.py:28
306
#: umc/python/diagnostic/plugins/package_status.py:28
264
msgid "some"
307
msgid "some"
265
msgstr "einigen"
308
msgstr "einigen"
266
- 

Return to bug 35859