Compare commits

..

13 Commits

5 changed files with 31 additions and 6 deletions

View File

@@ -4,6 +4,8 @@ on:
push: push:
branches: branches:
- "master" - "master"
schedule:
- cron: "0 2 * * 0"
jobs: jobs:
docker: docker:

View File

@@ -396,7 +396,7 @@ def record_and_check_smart(service, timestamp, smart):
return ("SMART report prefail disk (wear_level < 20%)", "CRITICAL") return ("SMART report prefail disk (wear_level < 20%)", "CRITICAL")
# temp max > X # # temp max > X #
if smart_last.temperature > 50: if smart_last.temperature > 60:
return ("Disk Temperatur {}".format(smart_last.temperature), "CRITICAL") return ("Disk Temperatur {}".format(smart_last.temperature), "CRITICAL")
# available_SSD spare # # available_SSD spare #
@@ -412,11 +412,12 @@ def record_and_check_smart(service, timestamp, smart):
spare_change), "WARNING") spare_change), "WARNING")
# unsafe_shutdowns +1 # # unsafe_shutdowns +1 #
if smart_second_last.unsafe_shutdowns - smart_last.unsafe_shutdowns >= 1: if(smart_second_last and
smart_second_last.unsafe_shutdowns - smart_last.unsafe_shutdowns >= 1):
return ("Disk had {} unsafe shutdowns".format(smart_last.unsafe_shutdowns), return ("Disk had {} unsafe shutdowns".format(smart_last.unsafe_shutdowns),
"WARNING") "WARNING")
return ("", "OK") return ("{} - no problems detected".format(smart_last.model_number), "OK")
def create_app(): def create_app():

View File

@@ -34,6 +34,8 @@ def normalize(smart):
elif name == "power_on_hours": elif name == "power_on_hours":
target_name = "power_on_hours" target_name = "power_on_hours"
use_raw = True use_raw = True
elif name == "perc_avail_resrvd_space":
target_name = "available_spare"
# check if metric should be recorded # # check if metric should be recorded #
if target_name in ret: if target_name in ret:
@@ -46,4 +48,7 @@ def normalize(smart):
ret[target_name] = value ret[target_name] = value
if ret["critical_warning"] == 0 and "smart_status" in smart:
ret["critical_warning"] = int(not smart["smart_status"]["passed"])
return ret return ret

View File

@@ -1,5 +1,6 @@
body{ body{
background: radial-gradient(ellipse at center, #47918a 0%, #0b3161 100%); background: radial-gradient(ellipse at center, #47918a 0%, #0b3161 100%);
background-attachment: fixed;
color: aliceblue !important; color: aliceblue !important;
} }

View File

@@ -83,13 +83,13 @@
</div> </div>
{% endif %} {% endif %}
{% if smart %} {% if service.special_type == "SMART" %}
<h5 class="clear my-4">Linux</h5> <h5 class="clear my-4">Linux</h5>
{% else %} {% else %}
<h5 class="clear my-4">Curl</h5> <h5 class="clear my-4">Curl</h5>
{% endif %} {% endif %}
<div class="ml-3 example"> <div class="ml-3 example">
{% if smart %} {% if service.special_type == "SMART" %}
SMART='{ <br> SMART='{ <br>
<div class="example-indent"> <div class="example-indent">
"service" : "{{ service.service }}", <br> "service" : "{{ service.service }}", <br>
@@ -115,7 +115,7 @@
{% endif %} {% endif %}
</div> </div>
{% if smart %} {% if service.special_type == "SMART" %}
<h5 class="my-4">Windows</h5> <h5 class="my-4">Windows</h5>
<div class="ml-3 example"> <div class="ml-3 example">
$SMART = @{ <br> $SMART = @{ <br>
@@ -128,6 +128,22 @@
} | ConvertTo-Json<br><br> } | 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 Invoke-RestMethod -TimeoutSec 2 -Uri "{{ flask.request.url_root.replace("http://", "https://" )}}report" -Method Post -Headers @{"Content-Type"="application/json"} -Body $SMART
</div> </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' &gt; $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 %} {% else %}
<h5 class="my-4">Python</h5> <h5 class="my-4">Python</h5>
<div class="ml-3 example"> <div class="ml-3 example">