mirror of
https://github.com/FAUSheppy/icinga-webhook-gateway
synced 2025-12-06 07:21:38 +01:00
184 lines
8.3 KiB
HTML
184 lines
8.3 KiB
HTML
{% include "head.html" %}
|
|
<html>
|
|
<body>
|
|
{% include "navbar.html" %}
|
|
<div class="container">
|
|
|
|
<script>
|
|
function sleep(ms) {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
function submit_manual(){
|
|
fetch("/report", {
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify({
|
|
"service" : "{{ service.service }}",
|
|
"token" : "{{ service.token }}",
|
|
"status" : "OK",
|
|
"info" : "Submitted from Web-Interface" })
|
|
}).then( () => {
|
|
sleep(1000).then( () => {
|
|
window.location.reload()
|
|
})
|
|
}).catch( () => {
|
|
alert("Submission failed, see console for details.")
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<h2 class="service-name">Service: {{ service.service }}</h2>
|
|
{% if service.staticly_configured %}
|
|
{% endif %}
|
|
|
|
{% if not service.staticly_configured %}
|
|
<a class="service-info-button mt-3" style="background-color: orange;"
|
|
href="/entry-form?service={{ service.service }}">Modify</a>
|
|
<a class="service-info-button mt-3" style="background-color: red;"
|
|
href="/entry-form?service={{ service.service }}&operation=delete">Delete</a>
|
|
{% else %}
|
|
<div class="static-configured-info">
|
|
This service is staticly configured, to edit or delete it, you have to modify the
|
|
configuration file on the server.
|
|
</div>
|
|
{% endif %}
|
|
|
|
<a href="{{ icinga_link }}" style="clear: both;" class="last-status hover mr-3">
|
|
<p style="color: darkred;">Show in Icinga</p>
|
|
</a>
|
|
|
|
<button style="clear: both;" class="last-status hover mr-3" onclick="submit_manual()">
|
|
<p style="color: darkred;">Submit manual OK</p>
|
|
</button>
|
|
|
|
<div class="last-status">
|
|
{% if status_list | length > 0 %}
|
|
<p class="{{ status_list[0].status }}">
|
|
{{ status_list[0].status }} submitted on {{ status_list[0].human_date() }}
|
|
</p>
|
|
{% else %}
|
|
<p style="color: darkred;">No status for this service submitted</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="clear p-4 box mt-4 mb-3" style="display: none;">
|
|
<div class="service-timeout">Timeout: {{ service.timeout }} days</div>
|
|
<div class="service-timeout">Owner: {{ service.owner }}</div>
|
|
<div style="display: none;"
|
|
class="service-token">Secret Token: {{ service.token }}</div>
|
|
</div>
|
|
|
|
{% if service.special_type == "SMART" %}
|
|
<div class="clear smart-info mt-3" style="background-color: orange;">
|
|
Smart Monitor {% if smart %} for: {{ smart.model_number }} {% endif %}
|
|
</div>
|
|
<div class="clear smart-info mt-3" style="background-color: orange;">
|
|
Example below requires smartmontools ("smartctl") in PATH.
|
|
On Linux this is usually available via the package manager,
|
|
on Windows install it from the
|
|
<a style="text-decoration: underline; color: #5000e1; font-weight: bold;" href="https://www.smartmontools.org/wiki/Download#InstalltheWindowspackage">offical page</a>.
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if service.special_type == "SMART" %}
|
|
<h5 class="clear my-4">Linux</h5>
|
|
{% else %}
|
|
<h5 class="clear my-4">Curl</h5>
|
|
{% endif %}
|
|
<div class="ml-3 example">
|
|
{% if service.special_type == "SMART" %}
|
|
SMART='{ <br>
|
|
<div class="example-indent">
|
|
"service" : "{{ service.service }}", <br>
|
|
"token" : "{{ service.token }}", <br>
|
|
"status" : "N/A", <br>
|
|
"smart" : '$(/sbin/smartctl -a /dev/nvme0n1 --json)' <br>
|
|
</div>
|
|
}' <br><br>
|
|
curl -X POST -H "Content-Type: application/json" \ <br>
|
|
<div class="example-indent">
|
|
--data "${SMART}" \ <br>
|
|
{{ flask.request.url_root.replace("http://", "https://" )}}report
|
|
</div>
|
|
{% else %}
|
|
curl -X POST \ <br>
|
|
<div class="example-indent">
|
|
-H "Content-Type: application/json" \ <br>
|
|
-d '{ "service" : "{{ service.service }}",
|
|
"token" : "{{ service.token }}", <br>
|
|
"status" : "OK", "info" : "Free Text Information here" }' \<br>
|
|
{{ flask.request.url_root.replace("http://", "https://" )}}report
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if service.special_type == "SMART" %}
|
|
<h5 class="my-4">Windows</h5>
|
|
<div class="ml-3 example">
|
|
$SMART = @{ <br>
|
|
<div class="example-indent">
|
|
service = "{{ service.service }}"<br>
|
|
token = "{{ service.token }}"<br>
|
|
status = "N/A"<br>
|
|
smart = "$(smartctl -a C: --json | Out-String)"<br>
|
|
</div>
|
|
} | ConvertTo-Json<br><br>
|
|
Invoke-RestMethod -TimeoutSec 2 -Uri "{{ flask.request.url_root.replace("http://", "https://" )}}report" -Method Post -Headers @{"Content-Type"="application/json"} -Body $SMART
|
|
</div>
|
|
<!-- register task example -->
|
|
<h5 class="my-4">Windows Task (requires Admin-Powershell)</h5>
|
|
<div class="ml-3 example">
|
|
$ScriptPath = Join-Path $HOME -ChildPath "smart_monitor.ps1" <br>
|
|
echo '$SMART = @{ <br>
|
|
<div class="example-indent">
|
|
service = "{{ service.service }}"<br>
|
|
token = "{{ service.token }}"<br>
|
|
status = "N/A"<br>
|
|
smart = "$(smartctl -a C: --json | Out-String)"<br>
|
|
</div>
|
|
} | ConvertTo-Json<br><br>
|
|
Invoke-RestMethod -TimeoutSec 2 -Uri "{{ flask.request.url_root.replace("http://", "https://" )}}report" -Method Post -Headers @{"Content-Type"="application/json"} -Body $SMART' > $ScriptPath <br>
|
|
schtasks /create /tn SMART_Monitor /tr "powershell.exe -executionpolicy bypass -File '$ScriptPath'" /sc hourly /mo 1 /ru "Administratoren"<br>
|
|
echo "Done" <br>
|
|
</div>
|
|
{% else %}
|
|
<h5 class="my-4">Python</h5>
|
|
<div class="ml-3 example">
|
|
import requests<br>
|
|
requests.post("{{ flask.request.url_root.replace("http://", "https://")}}report",
|
|
<br>
|
|
<div class="example-indent-double">
|
|
json= { "service" : "{{ service.service }}", <br>
|
|
<div class="example-indent-double">
|
|
"token" : "{{ service.token }}", <br>
|
|
"status" : "OK", </br>
|
|
"info" : "additional information" })
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<table class="mb-4 mt-5 status-table">
|
|
<thead>
|
|
<th>Date</th>
|
|
<th>Status</th>
|
|
<th>Info</th>
|
|
</thead>
|
|
|
|
<tbody class="mt-2">
|
|
{% for status in status_list %}
|
|
<tr>
|
|
<td>{{ status.human_date() }}</td>
|
|
<td class="{{ status.status }}">{{ status.status }}</td>
|
|
<td>{{ status.info_text }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</body>
|
|
</html>
|