<h1>Node <b><%= node.name %></b></h1>

<div class="section">
<h2>Overview</h2>
<div class="hider updatable">
<% if (!node.running) { %>
<p class="warning">Node not running</p>
<% } else if (node.os_pid == undefined) { %>
<p class="warning">Node statistics not available</p>
<% } else { %>
  <table class="facts">
    <tr>
      <th>
        File descriptors <span class="help" id="file-descriptors"></span>
      </th>
      <td>
<%= fmt_resource_bar_count(fmt_fd_used(node.fd_used, node.fd_total), node.fd_total, FD_THRESHOLDS) %>
      </td>
    </tr>
    <tr>
      <th>
        Socket descriptors <span class="help" id="socket-descriptors"></span>
      </th>
      <td>
<%= fmt_resource_bar_count(node.sockets_used, node.sockets_total, FD_THRESHOLDS) %>
      </td>
    </tr>
    <tr>
      <th>
        Erlang processes
      </th>
     <td>
<%= fmt_resource_bar_count(node.proc_used, node.proc_total, PROCESS_THRESHOLDS) %>
     </td>
    </tr>
  </table>
  <table class="facts">
    <tr>
      <th>
        Memory
      </th>
      <td>
<% if (node.mem_limit != 'memory_monitoring_disabled') { %>
   <%= fmt_resource_bar(fmt_bytes(node.mem_used),
                        fmt_bytes(node.mem_limit) + ' high watermark',
                        node.mem_used / node.mem_limit,
                        node.mem_alarm ? 'red' : 'green',
                        node.mem_alarm ? 'memory-alarm' : null) %>
<% } else { %>
   <%= fmt_bytes(node.mem_used) %>
<% } %>
      </td>
    </tr>
    <tr>
      <th>
        Disk space
      </th>
      <td>
<% if (node.disk_free_limit != 'disk_free_monitoring_disabled') { %>
   <%= fmt_resource_bar(fmt_bytes(node.disk_free),
                        fmt_bytes(node.disk_free_limit) + ' low watermark',
                        node.disk_free_limit / node.disk_free,
                        node.disk_free_alarm ? 'red' : 'green',
                        node.disk_free_alarm ? 'disk_free-alarm' : null) %>
<% } else { %>
         (not available)
<% } %>
      </td>
    </tr>
  </table>

  <table class="facts">
    <tr>
      <th>Uptime</th>
      <td><%= fmt_uptime(node.uptime) %></td>
    </tr>
<% if (rabbit_versions_interesting) { %>
    <tr>
      <th>RabbitMQ Version</th>
      <td><%= fmt_rabbit_version(node.applications) %></td>
    </tr>
<% } %>
    <tr>
      <th>Type</th>
      <td>
       <% if (node.type == 'disc') { %>
         <acronym title="Broker definitions are held on disc.">Disc</acronym>
       <% } else { %>
         <acronym title="Broker definitions are held in RAM. Messages will still be written to disc if necessary.">RAM</acronym>
       <% } %>
      </td>
    </tr>
  </table>
<% } %>
</div>
</div>

<div class="section">
<h2>Memory details</h2>
<div class="hider">
  <div id="memory-details"></div>
  <button class="update-manual memory-button" for="memory-details" query="memory">Update</button>
</div>
</div>

<div class="section-hidden">
<h2>Applications</h2>
<div class="hider updatable">
<% if (!node.running) { %>
<p class="warning">Node not running</p>
<% } else if (node.os_pid == undefined) { %>
<p class="warning">Node statistics not available</p>
<% } else { %>
<table class="list">
    <tr>
      <th>Name</th>
      <th>Version</th>
    </tr>
    <%
      for (var j = 0; j < node.applications.length; j++) {
        var application = node.applications[j];
    %>
       <tr<%= alt_rows(j)%>>
         <td>
           <%= application.name %>
           <sub><%= application.description %></sub>
         </td>
         <td><%= application.version %></td>
       </tr>
    <% } %>
</table>
<% } %>
</div>
</div>

<div class="section-hidden">
<h2>Registry</h2>
<div class="hider updatable">
<% if (!node.running) { %>
<p class="warning">Node not running</p>
<% } else if (node.os_pid == undefined) { %>
<p class="warning">Node statistics not available</p>
<% } else { %>
<h3>Exchange types</h3>
<%= format('registry', {'list': node.exchange_types, 'node': node, 'show_enabled': false} ) %>
<h3>Authentication mechanisms</h3>
<%= format('registry', {'list': node.auth_mechanisms, 'node': node, 'show_enabled': true} ) %>
<% } %>
</div>
</div>

<div class="section-hidden">
<h2>Advanced</h2>
<div class="hider updatable">
<% if (!node.running) { %>
<p class="warning">Node not running</p>
<% } else if (node.os_pid == undefined) { %>
<p class="warning">Node statistics not available</p>
<% } else { %>
  <div class="box">
  <h3>VM</h3>
  <table class="facts">
    <tr>
      <th>OS pid</th>
      <td><%= node.os_pid %></td>
    </tr>
    <tr>
      <th>Statistics</th>
      <td><%= node.statistics_level %></td>
    </tr>
  </table>

  <table class="facts">
    <tr>
      <th>Run queue</th>
      <td><%= node.run_queue %></td>
    </tr>
    <tr>
      <th>Processors</th>
      <td><%= node.processors %></td>
    </tr>
  </table>
<% } %>
</div>
</div>
