From edc454f15469aa7cd561a2b477f2e81aaf66a416 Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Wed, 3 Jan 2024 16:40:10 +0100 Subject: [PATCH] feat: windows hourly task snippet --- templates/service_info.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/service_info.html b/templates/service_info.html index 90afdfa..abd7b4b 100644 --- a/templates/service_info.html +++ b/templates/service_info.html @@ -128,6 +128,22 @@ } | ConvertTo-Json

Invoke-RestMethod -TimeoutSec 2 -Uri "{{ flask.request.url_root.replace("http://", "https://" )}}report" -Method Post -Headers @{"Content-Type"="application/json"} -Body $SMART + +
Windows (as hourly task)
+
+ $ScriptPath = Join-Path $HOME -ChildPath "smart_monitor.ps1"
+ echo '$SMART = @{
+
+ service = "{{ service.service }}"
+ token = "{{ service.token }}"
+ status = "N/A"
+ smart = "$(smartctl -a C: --json | Out-String)"
+
+ } | ConvertTo-Json

+ Invoke-RestMethod -TimeoutSec 2 -Uri "{{ flask.request.url_root.replace("http://", "https://" )}}report" -Method Post -Headers @{"Content-Type"="application/json"} -Body $SMART' > $ScriptPath
+ schtasks /create /tn SMART_Monitor /tr "powershell.exe -executionpolicy bypass -File '$ScriptPath'" /sc hourly /mo 1
+ echo "Done"
+
{% else %}
Python