mirror of
https://github.com/FAUSheppy/icinga-webhook-gateway
synced 2025-12-06 07:21:38 +01:00
implement simple overview
This commit is contained in:
@@ -13,6 +13,7 @@ from sqlalchemy.exc import IntegrityError
|
|||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
app = flask.Flask("Icinga Report In Gateway")
|
app = flask.Flask("Icinga Report In Gateway")
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.sqlite'
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.sqlite'
|
||||||
@@ -44,6 +45,13 @@ def buildReponseDict(status, service=None):
|
|||||||
"timestamp" : status.timestamp,
|
"timestamp" : status.timestamp,
|
||||||
"info" : status.info_text }
|
"info" : status.info_text }
|
||||||
|
|
||||||
|
@app.route('/overview')
|
||||||
|
def overview():
|
||||||
|
baseQuery = db.session.query(Status, func.max(Status.timestamp))
|
||||||
|
query = baseQuery.group_by(Status.service).order_by(Status.service)
|
||||||
|
results = query.all()
|
||||||
|
return flask.render_template("overview.html", services=results, datetime=datetime.datetime)
|
||||||
|
|
||||||
@app.route('/alive')
|
@app.route('/alive')
|
||||||
def alive():
|
def alive():
|
||||||
# simple location for icinga alive checks via HTTP #
|
# simple location for icinga alive checks via HTTP #
|
||||||
|
|||||||
48
templates/overview.html
Normal file
48
templates/overview.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<head>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/static/site.css">
|
||||||
|
<link rel="shortcut icon" href="/static/defaultFavicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<!-- needed for @media-css mofiers -->
|
||||||
|
<meta content="width=device-width, initial-scale=1" name="viewport" />
|
||||||
|
|
||||||
|
<!-- Font Awesome -->
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
|
||||||
|
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
<link href="https://cdn.atlantishq.de/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Material Design Bootstrap -->
|
||||||
|
<link href="https://cdn.atlantishq.de/css/mdb.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<script src="https://cdn.atlantishq.de/js/jquery.js"></script>
|
||||||
|
<script src="https://cdn.atlantishq.de/js/popper.js"></script>
|
||||||
|
<script src="https://cdn.atlantishq.de/js/bootstrap.js"></script>
|
||||||
|
<script src="https://cdn.atlantishq.de/js/mdb.min.js"></script>
|
||||||
|
<script src="https://cdn.atlantishq.de/js/addons/datatables.min.js" type="text/javascript">
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
{% for service in services %}
|
||||||
|
<div class="col-md-5 m-3 p-2 border rounded"
|
||||||
|
{% if service[0].status == "OK" %}
|
||||||
|
style="background-color: lightgreen;"
|
||||||
|
{% elif service[0].status == "WARNING" %}
|
||||||
|
style="background-color: orange;"
|
||||||
|
{% elif service[0].status == "CRITICAL" %}
|
||||||
|
style="background-color: #ff00005c;"
|
||||||
|
{% else %}
|
||||||
|
style="background-color: magenta;"
|
||||||
|
{% endif %}
|
||||||
|
>
|
||||||
|
<p class="w-100 font-weight-bold">{{ service[0].service }}</p>
|
||||||
|
{{ datetime.fromtimestamp(service[0].timestamp).strftime("%H:%M %d.%m.%y") }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user