Add a basic service status page
This commit is contained in:
@@ -1 +1,30 @@
|
||||
{% extends "working.html" %}
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
Services status
|
||||
{% endblock %}
|
||||
|
||||
{% block box %}
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Service</th>
|
||||
<th>Status</th>
|
||||
<th>PID</th>
|
||||
<th>Image</th>
|
||||
<th>Started</th>
|
||||
<th>Last update</th>
|
||||
</tr>
|
||||
{% for name, container in containers.items() %}
|
||||
<tr>
|
||||
<td>{{ name }}</td>
|
||||
<td><span class="label label-{{ "success" if container['State']['Running'] else "danger" }}">{{ container['State']['Status'] }}</span></td>
|
||||
<td>{{ container['State']['Pid'] }}</td>
|
||||
<td>{{ container['Config']['Image'] }}</td>
|
||||
<td>{{ container['State']['StartedAt'] }}</td>
|
||||
<td>{{ container['Image']['Created'] }}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,15 +1,26 @@
|
||||
from freeposte import dockercli
|
||||
from freeposte.admin import app, db, models, forms, utils
|
||||
from flask.ext import login as flask_login
|
||||
|
||||
import os
|
||||
import pprint
|
||||
import flask
|
||||
import json
|
||||
|
||||
|
||||
@app.route('/status', methods=['GET'])
|
||||
@flask_login.login_required
|
||||
def status():
|
||||
utils.require_global_admin()
|
||||
return flask.render_template('admin/status.html')
|
||||
containers = {}
|
||||
for brief in dockercli.containers(all=True):
|
||||
if brief['Image'].startswith('freeposte/'):
|
||||
container = dockercli.inspect_container(brief['Id'])
|
||||
container['Image'] = dockercli.inspect_image(container['Image'])
|
||||
name = container['Config']['Labels']['com.docker.compose.service']
|
||||
containers[name] = container
|
||||
pprint.pprint(container)
|
||||
return flask.render_template('admin/status.html', containers=containers)
|
||||
|
||||
|
||||
@app.route('/admins', methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user