##// 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 46 expected['load'] = resp['result']['load']
47 47 expected['cpu'] = resp['result']['cpu']
48 48 expected['disk'] = resp['result']['disk']
49 expected['disk_inodes'] = resp['result']['disk_inodes']
49 50 expected['server_ip'] = '127.0.0.1:80'
50 51
51 52 assert_ok(id_, expected, given=response.body)
@@ -60,6 +61,7 b' class TestGetServerInfo(object):'
60 61 expected['load'] = resp['result']['load']
61 62 expected['cpu'] = resp['result']['cpu']
62 63 expected['disk'] = resp['result']['disk']
64 expected['disk_inodes'] = resp['result']['disk_inodes']
63 65 expected['server_ip'] = '127.0.0.1:80'
64 66
65 67 assert_ok(id_, expected, given=response.body)
@@ -891,6 +891,9 b' class ScmModel(BaseModel):'
891 891 from rhodecode.lib.vcs.backends.git import discover_git_version
892 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 897 try:
895 898 # cygwin cannot have yet psutil support.
896 899 import psutil
@@ -904,6 +907,7 b' class ScmModel(BaseModel):'
904 907 _boot_time = _NA
905 908 _cpu = _NA
906 909 _disk = dict(percent=0, used=0, total=0, error='')
910 _disk_inodes = dict(percent=0, free=0, used=0, total=0, error='')
907 911 _load = {'1_min': _NA, '5_min': _NA, '15_min': _NA}
908 912
909 913 model = VcsSettingsModel()
@@ -920,6 +924,19 b' class ScmModel(BaseModel):'
920 924 log.exception('Failed to fetch disk info')
921 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 940 # memory
924 941 _memory = dict(psutil.virtual_memory()._asdict())
925 942 _memory['percent2'] = psutil._common.usage_percent(
@@ -1068,6 +1085,7 b' class ScmModel(BaseModel):'
1068 1085 'cpu': _cpu,
1069 1086 'memory': _memory,
1070 1087 'disk': _disk,
1088 'disk_inodes': _disk_inodes,
1071 1089 'disk_archive': _disk_archive,
1072 1090 'disk_gist': _disk_gist,
1073 1091 'disk_index': _disk_index,
@@ -11,6 +11,7 b''
11 11 (_('Uptime'), c.uptime_age, ''),
12 12 (_('Storage location'), c.storage, ''),
13 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 16 (_('Search index storage'), c.index_storage, ''),
16 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