attempt_logs.mako 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. ## Licensed to Cloudera, Inc. under one
  2. ## or more contributor license agreements. See the NOTICE file
  3. ## distributed with this work for additional information
  4. ## regarding copyright ownership. Cloudera, Inc. licenses this file
  5. ## to you under the Apache License, Version 2.0 (the
  6. ## "License"); you may not use this file except in compliance
  7. ## with the License. You may obtain a copy of the License at
  8. ##
  9. ## http://www.apache.org/licenses/LICENSE-2.0
  10. ##
  11. ## Unless required by applicable law or agreed to in writing, software
  12. ## distributed under the License is distributed on an "AS IS" BASIS,
  13. ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. ## See the License for the specific language governing permissions and
  15. ## limitations under the License.
  16. <%!
  17. from desktop.views import commonheader, commonfooter
  18. from django.utils.translation import ugettext as _
  19. %>
  20. <%namespace name="comps" file="jobbrowser_components.mako" />
  21. ${ commonheader(_('Task Attempt: %(attemptId)s') % dict(attemptId=attempt.attemptId_short), "jobbrowser", user, request) | n,unicode }
  22. ${ comps.menubar() }
  23. <div class="container-fluid">
  24. <div class="row-fluid">
  25. <div class="span2">
  26. <div class="sidebar-nav" style="padding-top: 0">
  27. <ul class="nav nav-list">
  28. <li class="nav-header">${_('Attempt ID')}</li>
  29. <li class="white truncate" title="${attempt.attemptId_short}">${attempt.attemptId_short}</li>
  30. <li class="nav-header">${_('Task')}</li>
  31. <li><a href="${url('jobbrowser.views.single_task', job=joblnk.jobId, taskid=taskid)}" class="truncate" title="${task.taskId_short}">${task.taskId_short}</a>
  32. </li>
  33. <li class="nav-header">${_('Job')}</li>
  34. <li><a href="${url('jobbrowser.views.single_job', job=joblnk.jobId)}" class="truncate" title="${joblnk.jobId_short}">${joblnk.jobId_short}</a></li>
  35. <li class="nav-header">${_('Status')}</li>
  36. <li class="white">
  37. <%
  38. status = attempt.state.lower()
  39. %>
  40. % if status == 'running' or status == 'pending':
  41. <span class="label label-warning">${status}</span>
  42. % elif status == 'succeeded':
  43. <span class="label label-success">${status}</span>
  44. % else:
  45. <span class="label">${status}</span>
  46. % endif
  47. </li>
  48. </ul>
  49. </div>
  50. </div>
  51. <div class="span10">
  52. <div class="card card-small">
  53. <h1 class="card-heading simple">${_('Task Attempt: %(attemptId)s') % dict(attemptId=attempt.attemptId_short)}</h1>
  54. <div class="card-body">
  55. <p>
  56. <ul class="nav nav-tabs">
  57. <li><a href="${ url('jobbrowser.views.single_task_attempt', job=joblnk.jobId, taskid=task.taskId, attemptid=attempt.attemptId) }#tmetadata">${_('Metadata')}</a></li>
  58. <li><a href="${ url('jobbrowser.views.single_task_attempt', job=joblnk.jobId, taskid=task.taskId, attemptid=attempt.attemptId) }#tcounters">${_('Counters')}</a></li>
  59. <li class="active"><a href="#logs" data-toggle="tab">${_('Logs')}</a></li>
  60. </ul>
  61. <div class="tab-content">
  62. <div class="tab-pane active" id="logs">
  63. <%def name="format_log(raw)">
  64. ## have to remove any indentation here or it breaks inside the pre tags
  65. % for line in raw.split('\n'):
  66. ${ line | unicode,trim }
  67. % endfor
  68. </%def>
  69. <%
  70. log_diagnostic = logs[0]
  71. log_stdout = logs[1]
  72. log_stderr = logs[2]
  73. log_syslog = logs[3]
  74. %>
  75. <div class="tabbable">
  76. <ul class="nav nav-pills">
  77. <li class="${ first_log_tab == 0 and 'active' or '' }"><a href="#logsDiagnostic" data-toggle="tab">${_('task diagnostic log')}</a></li>
  78. <li class="${ first_log_tab == 1 and 'active' or '' }"><a href="#logsStdOut" data-toggle="tab">${_('stdout')}</a></li>
  79. <li class="${ first_log_tab == 2 and 'active' or '' }"><a href="#logsStdErr" data-toggle="tab">${_('stderr')}</a></li>
  80. <li class="${ first_log_tab == 3 and 'active' or '' }"><a href="#logsSysLog" data-toggle="tab">${_('syslog')}</a></li>
  81. </ul>
  82. <div class="tab-content">
  83. <div class="tab-pane ${ first_log_tab == 0 and 'active' or '' }" id="logsDiagnostic">
  84. % if not log_diagnostic:
  85. <pre>-- empty --</pre>
  86. % else:
  87. <pre></pre>
  88. % endif
  89. </div>
  90. <div class="tab-pane ${ first_log_tab == 1 and 'active' or '' }" id="logsStdOut">
  91. % if not log_stdout:
  92. <pre>-- empty --</pre>
  93. % else:
  94. <pre></pre>
  95. % endif
  96. </div>
  97. <div class="tab-pane ${ first_log_tab == 2 and 'active' or '' }" id="logsStdErr">
  98. % if not log_stderr:
  99. <pre>-- empty --</pre>
  100. % else:
  101. <pre></pre>
  102. % endif
  103. </div>
  104. <div class="tab-pane ${ first_log_tab == 3 and 'active' or '' }" id="logsSysLog">
  105. % if not log_syslog:
  106. <pre>-- empty --</pre>
  107. % else:
  108. <pre></pre>
  109. % endif
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </p>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <script src="${ static('jobbrowser/js/utils.js') }" type="text/javascript" charset="utf-8"></script>
  122. <script type="text/javascript">
  123. $(document).ready(function () {
  124. enableResizeLogs();
  125. $("#metadataTable").dataTable({
  126. "bPaginate": false,
  127. "bLengthChange": false,
  128. "bInfo": false,
  129. "bAutoWidth": false,
  130. "bFilter": false,
  131. "aoColumns": [
  132. { "sWidth": "30%" },
  133. { "sWidth": "70%" }
  134. ],
  135. "oLanguage": {
  136. "sEmptyTable": "${_('No data available')}",
  137. "sZeroRecords": "${_('No matching records')}",
  138. }
  139. });
  140. $(".taskCountersTable").dataTable({
  141. "bPaginate": false,
  142. "bLengthChange": false,
  143. "bInfo": false,
  144. "bFilter": false,
  145. "bAutoWidth": false,
  146. "aoColumns": [
  147. { "sWidth": "30%" },
  148. { "sWidth": "70%" }
  149. ],
  150. "oLanguage": {
  151. "sEmptyTable": "${_('No data available')}",
  152. "sZeroRecords": "${_('No matching records')}",
  153. }
  154. });
  155. refreshLogs();
  156. initLogsElement($("#logsDiagnostic pre"));
  157. initLogsElement($("#logsStdOut pre"));
  158. initLogsElement($("#logsStdErr pre"));
  159. initLogsElement($("#logsSysLog pre"));
  160. function refreshLogs() {
  161. $.getJSON("?format=json", function (data) {
  162. if (data && data.logs && data.logs.length > 3) {
  163. var log_diagnostic = data.logs[0];
  164. var log_stdout = data.logs[1];
  165. var log_stderr = data.logs[2];
  166. var log_syslog = data.logs[3];
  167. appendAndScroll($("#logsDiagnostic pre"), log_diagnostic);
  168. appendAndScroll($("#logsStdOut pre"), log_stdout);
  169. appendAndScroll($("#logsStdErr pre"), log_stderr);
  170. appendAndScroll($("#logsSysLog pre"), log_syslog);
  171. if (data.isRunning) {
  172. window.setTimeout(refreshLogs, 1000);
  173. }
  174. }
  175. });
  176. }
  177. $(document).on("resized", function () {
  178. resizeLogs($("#logsDiagnostic pre"));
  179. resizeLogs($("#logsStdOut pre"));
  180. resizeLogs($("#logsStdErr pre"));
  181. resizeLogs($("#logsSysLog pre"));
  182. });
  183. $("a[data-toggle='tab']").on("shown", function (e) {
  184. resizeLogs($($(e.target).attr("href")).find("pre"));
  185. });
  186. $.jHueScrollUp();
  187. });
  188. </script>
  189. ${ commonfooter(request, messages) | n,unicode }