##// END OF EJS Templates
system-info: expose inode limits and usage. Fixes #4282
marcink -
r1027:f516f8a4 default
parent child Browse files
Show More
@@ -46,6 +46,7 b' class TestGetServerInfo(object):'
46 expected['load'] = resp['result']['load']
46 expected['load'] = resp['result']['load']
47 expected['cpu'] = resp['result']['cpu']
47 expected['cpu'] = resp['result']['cpu']
48 expected['disk'] = resp['result']['disk']
48 expected['disk'] = resp['result']['disk']
49 expected['disk_inodes'] = resp['result']['disk_inodes']
49 expected['server_ip'] = '127.0.0.1:80'
50 expected['server_ip'] = '127.0.0.1:80'
50
51
51 assert_ok(id_, expected, given=response.body)
52 assert_ok(id_, expected, given=response.body)
@@ -60,6 +61,7 b' class TestGetServerInfo(object):'
60 expected['load'] = resp['result']['load']
61 expected['load'] = resp['result']['load']
61 expected['cpu'] = resp['result']['cpu']
62 expected['cpu'] = resp['result']['cpu']
62 expected['disk'] = resp['result']['disk']
63 expected['disk'] = resp['result']['disk']
64 expected['disk_inodes'] = resp['result']['disk_inodes']
63 expected['server_ip'] = '127.0.0.1:80'
65 expected['server_ip'] = '127.0.0.1:80'
64
66
65 assert_ok(id_, expected, given=response.body)
67 assert_ok(id_, expected, given=response.body)
@@ -891,6 +891,9 b' class ScmModel(BaseModel):'
891 from rhodecode.lib.vcs.backends.git import discover_git_version
891 from rhodecode.lib.vcs.backends.git import discover_git_version
892 from rhodecode.model.gist import GIST_STORE_LOC
892 from rhodecode.model.gist import GIST_STORE_LOC
893
893
894 def percentage(part, whole):
895 return 100 * float(part) / float(whole)
896
894 try:
897 try:
895 # cygwin cannot have yet psutil support.
898 # cygwin cannot have yet psutil support.
896 import psutil
899 import psutil
@@ -904,6 +907,7 b' class ScmModel(BaseModel):'
904 _boot_time = _NA
907 _boot_time = _NA
905 _cpu = _NA
908 _cpu = _NA
906 _disk = dict(percent=0, used=0, total=0, error='')
909 _disk = dict(percent=0, used=0, total=0, error='')
910 _disk_inodes = dict(percent=0, free=0, used=0, total=0, error='')
907 _load = {'1_min': _NA, '5_min': _NA, '15_min': _NA}
911 _load = {'1_min': _NA, '5_min': _NA, '15_min': _NA}
908
912
909 model = VcsSettingsModel()
913 model = VcsSettingsModel()
@@ -920,6 +924,19 b' class ScmModel(BaseModel):'
920 log.exception('Failed to fetch disk info')
924 log.exception('Failed to fetch disk info')
921 _disk = {'percent': 0, 'used': 0, 'total': 0, 'error': str(e)}
925 _disk = {'percent': 0, 'used': 0, 'total': 0, 'error': str(e)}
922
926
927 # disk inodes usage
928 try:
929 i_stat = os.statvfs(storage_path)
930
931 _disk_inodes['used'] = i_stat.f_ffree
932 _disk_inodes['free'] = i_stat.f_favail
933 _disk_inodes['total'] = i_stat.f_files
934 _disk_inodes['percent'] = percentage(
935 _disk_inodes['used'], _disk_inodes['total'])
936 except Exception as e:
937 log.exception('Failed to fetch disk inodes info')
938 _disk_inodes['error'] = str(e)
939
923 # memory
940 # memory
924 _memory = dict(psutil.virtual_memory()._asdict())
941 _memory = dict(psutil.virtual_memory()._asdict())
925 _memory['percent2'] = psutil._common.usage_percent(
942 _memory['percent2'] = psutil._common.usage_percent(
@@ -1068,6 +1085,7 b' class ScmModel(BaseModel):'
1068 'cpu': _cpu,
1085 'cpu': _cpu,
1069 'memory': _memory,
1086 'memory': _memory,
1070 'disk': _disk,
1087 'disk': _disk,
1088 'disk_inodes': _disk_inodes,
1071 'disk_archive': _disk_archive,
1089 'disk_archive': _disk_archive,
1072 'disk_gist': _disk_gist,
1090 'disk_gist': _disk_gist,
1073 'disk_index': _disk_index,
1091 'disk_index': _disk_index,
@@ -11,6 +11,7 b''
11 (_('Uptime'), c.uptime_age, ''),
11 (_('Uptime'), c.uptime_age, ''),
12 (_('Storage location'), c.storage, ''),
12 (_('Storage location'), c.storage, ''),
13 (_('Storage disk space'), "%s/%s, %s%% used%s" % (h.format_byte_size_binary(c.disk['used']), h.format_byte_size_binary(c.disk['total']),(c.disk['percent']), ' %s' % c.disk['error'] if 'error' in c.disk else ''), ''),
13 (_('Storage disk space'), "%s/%s, %s%% used%s" % (h.format_byte_size_binary(c.disk['used']), h.format_byte_size_binary(c.disk['total']),(c.disk['percent']), ' %s' % c.disk['error'] if 'error' in c.disk else ''), ''),
14 (_('Storage file limit (inodes)'), "%s/%s, %.1f%% used%s" % (c.disk_inodes['used'], c.disk_inodes['total'],(c.disk_inodes['percent']), ' %s' % c.disk_inodes['error'] if 'error' in c.disk_inodes else ''), ''),
14
15
15 (_('Search index storage'), c.index_storage, ''),
16 (_('Search index storage'), c.index_storage, ''),
16 (_('Search index size'), "%s %s" % (h.format_byte_size_binary(c.disk_index['used']), ' %s' % c.disk_index['error'] if 'error' in c.disk_index else ''), ''),
17 (_('Search index size'), "%s %s" % (h.format_byte_size_binary(c.disk_index['used']), ' %s' % c.disk_index['error'] if 'error' in c.disk_index else ''), ''),
General Comments 0
You need to be logged in to leave comments. Login now