Compare commits
1 Commits
main
...
072536a04c
| Author | SHA1 | Date | |
|---|---|---|---|
| 072536a04c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
config.cfg
|
|
||||||
__pycache__
|
|
||||||
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2021 clerie
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
Simple status page for server uptime.
|
Simple status page for server uptime.
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Displays the up indicator of node-exporter from your prometheus for the last 14 days in 6h steps.
|
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
Init codebase
|
Init codebase
|
||||||
```
|
```
|
||||||
@@ -19,7 +15,6 @@ Create `config.cfg` with the following contents and edit values for your needs:
|
|||||||
|
|
||||||
```
|
```
|
||||||
PROMETHEUS_API_BASE="http://[::1]:9090"
|
PROMETHEUS_API_BASE="http://[::1]:9090"
|
||||||
PROMETHEUS_QUERY='(sum_over_time(up{job="node-exporter"}[6h]) / count_over_time(up{job="node-exporter"}[6h]))[14d:6h]'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Starten und updaten lässt sich die Flask-App folgendermaßen:
|
Starten und updaten lässt sich die Flask-App folgendermaßen:
|
||||||
|
|||||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.7 KiB |
@@ -5,8 +5,7 @@ import os
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
app.config["PROMETHEUS_API_BASE"] = "http://[::1]:9090"
|
app.config["PROMETHEUS_API_BASE"] = "https://[::1]:9090"
|
||||||
app.config["PROMETHEUS_QUERY"] = '(sum_over_time(up{job="node-exporter"}[6h]) / count_over_time(up{job="node-exporter"}[6h]))[14d:6h]'
|
|
||||||
|
|
||||||
if "UPTIMESTATUS_SETTINGS" in os.environ:
|
if "UPTIMESTATUS_SETTINGS" in os.environ:
|
||||||
app.config.from_envvar('UPTIMESTATUS_SETTINGS')
|
app.config.from_envvar('UPTIMESTATUS_SETTINGS')
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
<footer class="container">
|
<footer class="container">
|
||||||
<center><a href="https://git.clerie.de/clerie/uptime-status">Uptime Status</a> by <a href="https://clerie.de">clerie</a></center>
|
<center>Uptime Status</center>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ from .utils import process_instance
|
|||||||
from flask import render_template
|
from flask import render_template
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import urllib.parse
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def status():
|
def status():
|
||||||
r = requests.get(app.config["PROMETHEUS_API_BASE"] + "/api/v1/query?" + urllib.parse.urlencode({'query': app.config["PROMETHEUS_QUERY"]}))
|
r = requests.get(app.config["PROMETHEUS_API_BASE"] + "/api/v1/query?query=%28sum_over_time%28up%7Bjob%3D%22node-exporter%22%7D%5B6h%5D%29+%2F+count_over_time%28up%7Bjob%3D%22node-exporter%22%7D%5B6h%5D%29%29%5B14d%3A6h%5D")
|
||||||
j = json.loads(r.text)
|
j = json.loads(r.text)
|
||||||
metrics = sorted(map(process_instance, j["data"]["result"]), key=lambda m: m["name"])
|
metrics = sorted(map(process_instance, j["data"]["result"]), key=lambda m: m["name"])
|
||||||
return render_template("status.html", metrics=metrics)
|
return render_template("status.html", metrics=metrics)
|
||||||
|
|||||||
Reference in New Issue
Block a user