# HG changeset patch # User Marcin Kuzminski # Date 2016-11-17 23:35:04 # Node ID c43085bc8aeb95e9ccce5b6c2d87b54be69381ac # Parent c96fec2030f1693dd3e7becf54a363d8fe073bef system-info: added info about temporary storage. - temporary storage is used by Mercurial and other parts of the system. knowing it's limitations is important to know. diff --git a/rhodecode/api/tests/test_get_server_info.py b/rhodecode/api/tests/test_get_server_info.py --- a/rhodecode/api/tests/test_get_server_info.py +++ b/rhodecode/api/tests/test_get_server_info.py @@ -46,6 +46,7 @@ class TestGetServerInfo(object): expected['load'] = resp['result']['load'] expected['cpu'] = resp['result']['cpu'] expected['storage'] = resp['result']['storage'] + expected['storage_temp'] = resp['result']['storage_temp'] expected['storage_inodes'] = resp['result']['storage_inodes'] expected['server'] = resp['result']['server'] @@ -61,6 +62,7 @@ class TestGetServerInfo(object): expected['load'] = resp['result']['load'] expected['cpu'] = resp['result']['cpu'] expected['storage'] = resp['result']['storage'] + expected['storage_temp'] = resp['result']['storage_temp'] expected['storage_inodes'] = resp['result']['storage_inodes'] expected['server'] = resp['result']['server'] diff --git a/rhodecode/controllers/admin/settings.py b/rhodecode/controllers/admin/settings.py --- a/rhodecode/controllers/admin/settings.py +++ b/rhodecode/controllers/admin/settings.py @@ -613,6 +613,9 @@ class SettingsController(BaseController) (_('Archive cache storage location'), val('storage_archive')['path'], state('storage_archive')), (_('Archive cache info'), val('storage_archive')['text'], state('storage_archive')), + (_('Temp storage location'), val('storage_temp')['path'], state('storage_temp')), + (_('Temp storage info'), val('storage_temp')['text'], state('storage_temp')), + (_('Search info'), val('search')['text'], state('search')), (_('Search location'), val('search')['location'], state('search')), ('', '', ''), # spacer diff --git a/rhodecode/lib/system_info.py b/rhodecode/lib/system_info.py --- a/rhodecode/lib/system_info.py +++ b/rhodecode/lib/system_info.py @@ -367,6 +367,34 @@ def storage_gist(): return SysInfoRes(value=value, state=state, human_value=human_value) +def storage_temp(): + import tempfile + from rhodecode.lib.helpers import format_byte_size_binary + + path = tempfile.gettempdir() + value = dict(percent=0, used=0, total=0, items=0, path=path, text='') + state = STATE_OK_DEFAULT + + if not psutil: + return SysInfoRes(value=value, state=state) + + try: + value.update(dict(psutil.disk_usage(path)._asdict())) + except Exception as e: + log.exception('Failed to fetch temp dir info') + state = {'message': str(e), 'type': STATE_ERR} + + human_value = value.copy() + human_value['used'] = format_byte_size_binary(value['used']) + human_value['total'] = format_byte_size_binary(value['total']) + human_value['text'] = "{}/{}, {}% used".format( + format_byte_size_binary(value['used']), + format_byte_size_binary(value['total']), + value['percent']) + + return SysInfoRes(value=value, state=state, human_value=human_value) + + def search_info(): import rhodecode from rhodecode.lib.index import searcher_from_config @@ -595,6 +623,7 @@ def get_system_info(environ): 'storage_inodes': SysInfo(storage_inodes)(), 'storage_archive': SysInfo(storage_archives)(), 'storage_gist': SysInfo(storage_gist)(), + 'storage_temp': SysInfo(storage_temp)(), 'search': SysInfo(search_info)(),