system-info: added ulimit to system info.

This commit is contained in:
Marcin Kuzminski 2018-03-30 15:35:55 +02:00
parent c8bd6381f6
commit 3667868099
2 changed files with 29 additions and 1 deletions

View file

@ -123,6 +123,9 @@ class AdminSystemInfoSettingsView(BaseAppView):
(_('Uptime'), val('uptime')['text'], state('uptime')),
('', '', ''), # spacer
# ulimit
(_('Ulimit'), val('ulimit')['text'], state('ulimit')),
# Repo storage
(_('Storage location'), val('storage')['path'], state('storage')),
(_('Storage info'), val('storage')['text'], state('storage')),

View file

@ -23,6 +23,7 @@ import os
import sys
import time
import platform
import subprocess32
import pkg_resources
import logging
@ -140,6 +141,29 @@ def platform_type():
return SysInfoRes(value=value)
def ulimit_info():
data = {}
text = 'ulimit -a unavailable'
try:
result = subprocess32.check_output(
['ulimit -a'], timeout=10, stderr=subprocess32.STDOUT,
shell=True)
for line in result.splitlines():
key, val = line.split(' ', 1)
data[key.strip()] = val.strip()
text = ', '.join('{}:{}'.format(k,v) for k,v in data.items())
except Exception:
log.exception('ulimit check problem')
value = {
'ulimit': data,
'text': text,
}
return SysInfoRes(value=value)
def uptime():
from rhodecode.lib.helpers import age, time_to_datetime
from rhodecode.translation import TranslationString
@ -687,6 +711,7 @@ def usage_info():
return SysInfoRes(value=value)
def get_system_info(environ):
environ = environ or {}
return {
@ -699,7 +724,7 @@ def get_system_info(environ):
'platform': SysInfo(platform_type)(),
'server': SysInfo(server_info, environ=environ)(),
'database': SysInfo(database_info)(),
'ulimit': SysInfo(ulimit_info)(),
'storage': SysInfo(storage)(),
'storage_inodes': SysInfo(storage_inodes)(),
'storage_archive': SysInfo(storage_archives)(),