Skip to content
Snippets Groups Projects
Commit 7337d015 authored by Jan Mach's avatar Jan Mach
Browse files

Improved system status view in Hawat.

System status now displays internal daemon component counters. Current implementation is however proof-of-concept only, because it will not display correctly counters for paralelized daemon modules. (Redmine issue: #4218)
parent 9c33c5ff
No related branches found
No related tags found
No related merge requests found
......@@ -103,6 +103,11 @@ class ViewView(hawat.base.HawatSimpleView):
controller_cfg.get('cronjobs', {})
)
context['mentat_runlogs'] = mentat.system.analyze_runlog_files(
flask.current_app.config['MENTAT_PATHS']['path_run'],
limit = 20
)
context['mentat_status'] = mentat.system.system_status(
context['mentat_modules'],
context['mentat_cronjobs'],
......
......@@ -121,13 +121,28 @@
{{ mentat_status['modules'][modname][1] }}
</span>
</p>
{%- if modname in mentat_status['log_files'] %}
{%- if modname in mentat_status['runlog_files'] %}
{%- for rlf_key, rlf_data in mentat_status['runlog_files'][modname].items() %}
<p>
<strong>{{ gettext('Module log file:')}}</strong><br>
<em>{{ gettext('File:') }}</em> {{ mentat_status['log_files'][modname]['path'] }} |
<em>{{ gettext('Size:') }}</em> {{ babel_format_bytes(mentat_status['log_files'][modname]['size'], 'B') }} |
<em>{{ gettext('Last modification at:') }}</em> {{ babel_format_datetime(mentat_status['log_files'][modname]['mtime']) }} ({{ gettext('before') }} {{ babel_format_timedelta(get_datetime_utc() - mentat_status['log_files'][modname]['mtime']) }})
<strong>{{ gettext('Module runlog file:')}}</strong><br>
<em>{{ gettext('PID:') }}</em> {{ rlf_data['data']['pid'] }} |
<em>{{ gettext('File:') }}</em> {{ rlf_data['path'] }} |
<em>{{ gettext('Size:') }}</em> {{ babel_format_bytes(rlf_data['size'], 'B') }} |
<em>{{ gettext('Last modification at:') }}</em> {{ babel_format_datetime(rlf_data['mtime']) }} ({{ gettext('before') }} {{ babel_format_timedelta(get_datetime_utc() - rlf_data['mtime']) }})
<table>
{%- for component_stats in rlf_data['data']['statistics']['components']|dictsort %}
{%- for stats_counter in component_stats[1]|dictsort %}
{%- if stats_counter[1] is number %}
<tr>
<td>{{ component_stats[0] }}.{{ stats_counter[0] }}</td>
<td>&nbsp;&nbsp;<span class="badge">{{ stats_counter[1] }}</span></td>
</tr>
{%- endif %}
{%- endfor %}
{%- endfor %}
</table>
</p>
{%- endfor %}
{%- endif %}
{%- if modname in mentat_status['pid_files'] %}
<p>
......@@ -149,6 +164,14 @@
<em>{{ gettext('Process:') }}</em> {{ psdata['process'] }} {{ psdata['exec'] }}{% if psdata['args'] %}{{ psdata['args'] }}{% endif %}
{%- if not loop.last %}<br>{%- endif %}
{%- endfor %}
</p>
{%- endif %}
{%- if modname in mentat_status['log_files'] %}
<p>
<strong>{{ gettext('Module log file:')}}</strong><br>
<em>{{ gettext('File:') }}</em> {{ mentat_status['log_files'][modname]['path'] }} |
<em>{{ gettext('Size:') }}</em> {{ babel_format_bytes(mentat_status['log_files'][modname]['size'], 'B') }} |
<em>{{ gettext('Last modification at:') }}</em> {{ babel_format_datetime(mentat_status['log_files'][modname]['mtime']) }} ({{ gettext('before') }} {{ babel_format_timedelta(get_datetime_utc() - mentat_status['log_files'][modname]['mtime']) }})
</p>
{%- endif %}
{%- if not loop.last %}<hr>{%- endif %}
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2018-09-03 19:41+0200\n"
"POT-Creation-Date: 2018-09-04 17:57+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -406,12 +406,13 @@ msgstr ""
#: blueprints/reports/templates/reports/show.html:204
#: blueprints/settings_reporting/templates/settings_reporting/show.html:17
#: blueprints/settings_reporting/templates/settings_reporting/show.html:262
#: blueprints/status/templates/status/view.html:129
#: blueprints/status/templates/status/view.html:139
#: blueprints/status/templates/status/view.html:131
#: blueprints/status/templates/status/view.html:154
#: blueprints/status/templates/status/view.html:174
#: blueprints/status/templates/status/view.html:183
#: blueprints/status/templates/status/view.html:209
#: blueprints/status/templates/status/view.html:227
#: blueprints/status/templates/status/view.html:197
#: blueprints/status/templates/status/view.html:206
#: blueprints/status/templates/status/view.html:232
#: blueprints/status/templates/status/view.html:250
#: blueprints/users/templates/users/show.html:16
#: blueprints/users/templates/users/show.html:18
#: blueprints/users/templates/users/show.html:199
......@@ -2631,7 +2632,7 @@ msgstr ""
msgid "System performance pluggable module"
msgstr ""
#: blueprints/performance/__init__.py:200 blueprints/status/__init__.py:147
#: blueprints/performance/__init__.py:200 blueprints/status/__init__.py:152
msgid "Status overview"
msgstr ""
......@@ -3221,7 +3222,7 @@ msgstr ""
msgid "System status"
msgstr ""
#: blueprints/status/__init__.py:131
#: blueprints/status/__init__.py:136
msgid "System status pluggable module"
msgstr ""
......@@ -3265,7 +3266,7 @@ msgid "Real-time message processing modules"
msgstr ""
#: blueprints/status/templates/status/view.html:82
#: blueprints/status/templates/status/view.html:160
#: blueprints/status/templates/status/view.html:183
msgid "Cronjob message post-processing modules"
msgstr ""
......@@ -3274,70 +3275,78 @@ msgid "Messages:"
msgstr ""
#: blueprints/status/templates/status/view.html:119
#: blueprints/status/templates/status/view.html:164
#: blueprints/status/templates/status/view.html:187
msgid "Module status:"
msgstr ""
#: blueprints/status/templates/status/view.html:126
#: blueprints/status/templates/status/view.html:171
msgid "Module log file:"
#: blueprints/status/templates/status/view.html:127
msgid "Module runlog file:"
msgstr ""
#: blueprints/status/templates/status/view.html:127
#: blueprints/status/templates/status/view.html:137
#: blueprints/status/templates/status/view.html:128
#: blueprints/status/templates/status/view.html:151
#: blueprints/status/templates/status/view.html:163
#: blueprints/status/templates/status/view.html:213
#: blueprints/status/templates/status/view.html:247
#: blueprints/status/templates/status/view.html:266
msgid "PID:"
msgstr ""
#: blueprints/status/templates/status/view.html:129
#: blueprints/status/templates/status/view.html:152
#: blueprints/status/templates/status/view.html:172
#: blueprints/status/templates/status/view.html:180
#: blueprints/status/templates/status/view.html:207
#: blueprints/status/templates/status/view.html:225
#: blueprints/status/templates/status/view.html:195
#: blueprints/status/templates/status/view.html:203
#: blueprints/status/templates/status/view.html:230
#: blueprints/status/templates/status/view.html:248
msgid "File:"
msgstr ""
#: blueprints/status/templates/status/view.html:128
#: blueprints/status/templates/status/view.html:138
#: blueprints/status/templates/status/view.html:130
#: blueprints/status/templates/status/view.html:153
#: blueprints/status/templates/status/view.html:173
#: blueprints/status/templates/status/view.html:182
#: blueprints/status/templates/status/view.html:208
#: blueprints/status/templates/status/view.html:226
#: blueprints/status/templates/status/view.html:196
#: blueprints/status/templates/status/view.html:205
#: blueprints/status/templates/status/view.html:231
#: blueprints/status/templates/status/view.html:249
msgid "Size:"
msgstr ""
#: blueprints/status/templates/status/view.html:129
#: blueprints/status/templates/status/view.html:139
#: blueprints/status/templates/status/view.html:131
#: blueprints/status/templates/status/view.html:154
#: blueprints/status/templates/status/view.html:174
#: blueprints/status/templates/status/view.html:183
#: blueprints/status/templates/status/view.html:209
#: blueprints/status/templates/status/view.html:227
#: blueprints/status/templates/status/view.html:197
#: blueprints/status/templates/status/view.html:206
#: blueprints/status/templates/status/view.html:232
#: blueprints/status/templates/status/view.html:250
msgid "Last modification at:"
msgstr ""
#: blueprints/status/templates/status/view.html:134
#: blueprints/status/templates/status/view.html:149
msgid "Module PID files:"
msgstr ""
#: blueprints/status/templates/status/view.html:136
#: blueprints/status/templates/status/view.html:148
#: blueprints/status/templates/status/view.html:190
#: blueprints/status/templates/status/view.html:224
#: blueprints/status/templates/status/view.html:243
msgid "PID:"
msgstr ""
#: blueprints/status/templates/status/view.html:146
#: blueprints/status/templates/status/view.html:188
#: blueprints/status/templates/status/view.html:161
#: blueprints/status/templates/status/view.html:211
msgid "Module processes:"
msgstr ""
#: blueprints/status/templates/status/view.html:149
#: blueprints/status/templates/status/view.html:191
#: blueprints/status/templates/status/view.html:244
#: blueprints/status/templates/status/view.html:164
#: blueprints/status/templates/status/view.html:214
#: blueprints/status/templates/status/view.html:267
msgid "Process:"
msgstr ""
#: blueprints/status/templates/status/view.html:179
#: blueprints/status/templates/status/view.html:171
#: blueprints/status/templates/status/view.html:194
msgid "Module log file:"
msgstr ""
#: blueprints/status/templates/status/view.html:202
msgid "Module cron file:"
msgstr ""
#: blueprints/status/templates/status/view.html:181
#: blueprints/status/templates/status/view.html:204
msgid "Link:"
msgstr ""
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2018-09-03 19:41+0200\n"
"POT-Creation-Date: 2018-09-04 17:57+0200\n"
"PO-Revision-Date: 2017-09-22 15:33+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: cs\n"
......@@ -424,12 +424,13 @@ msgstr "Registrován v:"
#: blueprints/reports/templates/reports/show.html:204
#: blueprints/settings_reporting/templates/settings_reporting/show.html:17
#: blueprints/settings_reporting/templates/settings_reporting/show.html:262
#: blueprints/status/templates/status/view.html:129
#: blueprints/status/templates/status/view.html:139
#: blueprints/status/templates/status/view.html:131
#: blueprints/status/templates/status/view.html:154
#: blueprints/status/templates/status/view.html:174
#: blueprints/status/templates/status/view.html:183
#: blueprints/status/templates/status/view.html:209
#: blueprints/status/templates/status/view.html:227
#: blueprints/status/templates/status/view.html:197
#: blueprints/status/templates/status/view.html:206
#: blueprints/status/templates/status/view.html:232
#: blueprints/status/templates/status/view.html:250
#: blueprints/users/templates/users/show.html:16
#: blueprints/users/templates/users/show.html:18
#: blueprints/users/templates/users/show.html:199
......@@ -2722,7 +2723,7 @@ msgstr "Databáze provozních statistik systému"
msgid "System performance pluggable module"
msgstr "Provoz systému (zásuvný modul)"
#: blueprints/performance/__init__.py:200 blueprints/status/__init__.py:147
#: blueprints/performance/__init__.py:200 blueprints/status/__init__.py:152
msgid "Status overview"
msgstr "Stavové přehledy"
......@@ -3330,7 +3331,7 @@ msgstr "Skeleton module"
msgid "System status"
msgstr "Stav systému"
#: blueprints/status/__init__.py:131
#: blueprints/status/__init__.py:136
msgid "System status pluggable module"
msgstr "Stav systému (zásuvný modul)"
......@@ -3374,7 +3375,7 @@ msgid "Real-time message processing modules"
msgstr "Moduly pracující v realném čase"
#: blueprints/status/templates/status/view.html:82
#: blueprints/status/templates/status/view.html:160
#: blueprints/status/templates/status/view.html:183
msgid "Cronjob message post-processing modules"
msgstr "Moduly na bázi cronjobů"
......@@ -3383,70 +3384,78 @@ msgid "Messages:"
msgstr "Zprávy:"
#: blueprints/status/templates/status/view.html:119
#: blueprints/status/templates/status/view.html:164
#: blueprints/status/templates/status/view.html:187
msgid "Module status:"
msgstr "Stav modulu:"
#: blueprints/status/templates/status/view.html:126
#: blueprints/status/templates/status/view.html:171
msgid "Module log file:"
msgstr "Log soubor modulu:"
#: blueprints/status/templates/status/view.html:127
#: blueprints/status/templates/status/view.html:137
msgid "Module runlog file:"
msgstr "Runlog soubor modulu:"
#: blueprints/status/templates/status/view.html:128
#: blueprints/status/templates/status/view.html:151
#: blueprints/status/templates/status/view.html:163
#: blueprints/status/templates/status/view.html:213
#: blueprints/status/templates/status/view.html:247
#: blueprints/status/templates/status/view.html:266
msgid "PID:"
msgstr "PID:"
#: blueprints/status/templates/status/view.html:129
#: blueprints/status/templates/status/view.html:152
#: blueprints/status/templates/status/view.html:172
#: blueprints/status/templates/status/view.html:180
#: blueprints/status/templates/status/view.html:207
#: blueprints/status/templates/status/view.html:225
#: blueprints/status/templates/status/view.html:195
#: blueprints/status/templates/status/view.html:203
#: blueprints/status/templates/status/view.html:230
#: blueprints/status/templates/status/view.html:248
msgid "File:"
msgstr "Soubor:"
#: blueprints/status/templates/status/view.html:128
#: blueprints/status/templates/status/view.html:138
#: blueprints/status/templates/status/view.html:130
#: blueprints/status/templates/status/view.html:153
#: blueprints/status/templates/status/view.html:173
#: blueprints/status/templates/status/view.html:182
#: blueprints/status/templates/status/view.html:208
#: blueprints/status/templates/status/view.html:226
#: blueprints/status/templates/status/view.html:196
#: blueprints/status/templates/status/view.html:205
#: blueprints/status/templates/status/view.html:231
#: blueprints/status/templates/status/view.html:249
msgid "Size:"
msgstr "Velikost:"
#: blueprints/status/templates/status/view.html:129
#: blueprints/status/templates/status/view.html:139
#: blueprints/status/templates/status/view.html:131
#: blueprints/status/templates/status/view.html:154
#: blueprints/status/templates/status/view.html:174
#: blueprints/status/templates/status/view.html:183
#: blueprints/status/templates/status/view.html:209
#: blueprints/status/templates/status/view.html:227
#: blueprints/status/templates/status/view.html:197
#: blueprints/status/templates/status/view.html:206
#: blueprints/status/templates/status/view.html:232
#: blueprints/status/templates/status/view.html:250
msgid "Last modification at:"
msgstr "Poslední modifikace ve:"
#: blueprints/status/templates/status/view.html:134
#: blueprints/status/templates/status/view.html:149
msgid "Module PID files:"
msgstr "PID soubor modulu:"
#: blueprints/status/templates/status/view.html:136
#: blueprints/status/templates/status/view.html:148
#: blueprints/status/templates/status/view.html:190
#: blueprints/status/templates/status/view.html:224
#: blueprints/status/templates/status/view.html:243
msgid "PID:"
msgstr "PID:"
#: blueprints/status/templates/status/view.html:146
#: blueprints/status/templates/status/view.html:188
#: blueprints/status/templates/status/view.html:161
#: blueprints/status/templates/status/view.html:211
msgid "Module processes:"
msgstr "Procesy modulu:"
#: blueprints/status/templates/status/view.html:149
#: blueprints/status/templates/status/view.html:191
#: blueprints/status/templates/status/view.html:244
#: blueprints/status/templates/status/view.html:164
#: blueprints/status/templates/status/view.html:214
#: blueprints/status/templates/status/view.html:267
msgid "Process:"
msgstr "Proces:"
#: blueprints/status/templates/status/view.html:179
#: blueprints/status/templates/status/view.html:171
#: blueprints/status/templates/status/view.html:194
msgid "Module log file:"
msgstr "Log soubor modulu:"
#: blueprints/status/templates/status/view.html:202
msgid "Module cron file:"
msgstr "Cron soubor modulu:"
#: blueprints/status/templates/status/view.html:181
#: blueprints/status/templates/status/view.html:204
msgid "Link:"
msgstr "Link:"
......@@ -3762,7 +3771,3 @@ msgid ""
"You have to be authenticated to use most features provided by this "
"application."
msgstr "Pro používání této aplikace je nutné přihlášení."
#~ msgid "Raw filter tree"
#~ msgstr "Surový strom filtru"
......@@ -394,7 +394,7 @@ def analyze_cron_file(cron_file, cron_file_path, cron_links):
fsstat = os.stat(cron_file_path)
return {
'name': match.group(1),
'name': match.group(1).replace('-py', '.py').replace('-sh', '.sh'),
'file': cron_file,
'path': cron_file_path,
'size': fsstat.st_size,
......@@ -578,7 +578,7 @@ def analyze_runlog_file(runlog_file, runlog_file_path):
except:
return None
def analyze_runlog_files(run_dir_path):
def analyze_runlog_files(run_dir_path, limit = None):
"""
Analyze all runlog files in run directory.
......@@ -594,7 +594,8 @@ def analyze_runlog_files(run_dir_path):
if not os.path.isdir(runlog_dir_path):
continue
all_rl_files = os.listdir(runlog_dir_path)
all_rl_files = sorted(os.listdir(runlog_dir_path), reverse = True)
file_counter = 0
for runlog_file in all_rl_files:
runlog_file_path = os.path.join(runlog_dir_path, runlog_file)
if not os.path.isfile(runlog_file_path):
......@@ -604,6 +605,10 @@ def analyze_runlog_files(run_dir_path):
if not record:
continue
file_counter += 1
if limit and file_counter > limit:
break
runlog_files[runlog_dir][record['name']] = record
return dict(runlog_files)
......@@ -802,6 +807,7 @@ def system_status(modules, cronjobs, cfg_dir_path, cron_dir_path, log_dir_path,
status['processes'] = analyze_process_list_ps()
status['pid_files'] = analyze_pid_files(run_dir_path)
status['log_files'] = analyze_log_files(log_dir_path)
status['runlog_files'] = analyze_runlog_files(run_dir_path, limit = 1)
status['cron_files'] = analyze_cron_files(os.path.join(cfg_dir_path, 'cron'), cron_dir_path)
status['resultm'] = None
status['resultc'] = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment