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.
This commit is contained in:
Marcin Kuzminski 2016-11-18 00:35:04 +01:00
parent c5ddd016be
commit 66e3dcc71d
3 changed files with 34 additions and 0 deletions

View file

@ -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']

View file

@ -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

View file

@ -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)(),