fix(nix-monitor): add system check duration threshold
This commit is contained in:
@@ -34,9 +34,10 @@ end
|
||||
|
||||
-- Vars
|
||||
local branch = cfg("branch")
|
||||
local updateCheckInterval = cfg("check_interval")
|
||||
local checkDurationThreshold = cfg("check_duration_threshold")
|
||||
local updateCheckInterval = cfg("update_check_interval")
|
||||
local updateCheckDurationThreshold = cfg("update_check_duration_threshold")
|
||||
local systemStatsCheckInterval = cfg("system_stats_check_interval")
|
||||
local systemStatsCheckDurationThreshold = cfg("system_stats_check_duration_threshold")
|
||||
local stateDir = "/tmp/nix-monitor"
|
||||
local remoteHashFile = stateDir .. "/remoteHash"
|
||||
local storeSizeFile = stateDir .. "/storeSize"
|
||||
@@ -66,7 +67,8 @@ setState("isRemoteCheckRunning", false)
|
||||
setState("isUpdateAvailable", false)
|
||||
setState("lastGenerationsCheckTime", 0)
|
||||
setState("isSystemStatsCheckRunning", false)
|
||||
setState("lastSystemStatsCheckTime", 0)
|
||||
setState("lastSystemStatsCheckTime", os.time())
|
||||
setState("lastSystemStatsCheckRunTime", os.time())
|
||||
setState("hasHomeManager", noctalia.commandExists("home-manager"))
|
||||
setState("nixosGenerations", "•••")
|
||||
setState("nixosCurrentGen", "•••")
|
||||
@@ -169,7 +171,7 @@ function checkSystemStats()
|
||||
end
|
||||
|
||||
setState("isSystemStatsCheckRunning", true)
|
||||
setState("lastSystemStatsCheckTime", os.time())
|
||||
setState("lastSystemStatsCheckRunTime", os.time())
|
||||
|
||||
-- Sleep 0 to trigger noctalia calling /bin/sh
|
||||
noctalia.runAsync(`sleep 0 && {storeSizeCmd} > {storeSizeFile} & echo $! > {storePidFile}`)
|
||||
@@ -193,6 +195,7 @@ function checkSystemStatsFile()
|
||||
|
||||
if success then
|
||||
setState("isSystemStatsCheckRunning", false)
|
||||
setState("lastSystemStatsCheckTime", os.time())
|
||||
noctalia.removeFile(storePidFile)
|
||||
noctalia.removeFile(closurePidFile)
|
||||
end
|
||||
@@ -207,6 +210,7 @@ end
|
||||
-- Init
|
||||
checkLocalHash()
|
||||
checkRemoteHash(10)
|
||||
checkSystemStats()
|
||||
|
||||
-- Command watcher
|
||||
watchState("command", function(command)
|
||||
@@ -243,7 +247,7 @@ function update()
|
||||
checkRemoteStatus()
|
||||
|
||||
-- Remote check timeout
|
||||
if (os.time() - getState("lastRemoteCheckRunTime")) >= 60 * checkDurationThreshold then
|
||||
if (os.time() - getState("lastRemoteCheckRunTime")) >= 60 * updateCheckDurationThreshold then
|
||||
cancelRemoteCheck()
|
||||
end
|
||||
end
|
||||
@@ -274,6 +278,11 @@ function update()
|
||||
|
||||
if getState("isSystemStatsCheckRunning") then
|
||||
checkSystemStatsFile()
|
||||
|
||||
-- System stats check timeout
|
||||
if (os.time() - getState("lastSystemStatsCheckRunTime")) >= 60 * systemStatsCheckDurationThreshold then
|
||||
cancelSystemCheck()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+15
-6
@@ -86,18 +86,18 @@ label_key = "setting.widget.unknown_color.label"
|
||||
default = "on_surface"
|
||||
|
||||
[[setting]]
|
||||
key = "check_interval"
|
||||
key = "update_check_interval"
|
||||
type = "int"
|
||||
label_key = "setting.check_interval.label"
|
||||
description_key = "setting.check_interval.description"
|
||||
label_key = "setting.update_check_interval.label"
|
||||
description_key = "setting.update_check_interval.description"
|
||||
default = 60
|
||||
min = 10
|
||||
|
||||
[[setting]]
|
||||
key = "check_duration_threshold"
|
||||
key = "update_check_duration_threshold"
|
||||
type = "int"
|
||||
label_key = "setting.check_duration_threshold.label"
|
||||
description_key = "setting.check_duration_threshold.description"
|
||||
label_key = "setting.update_check_duration_threshold.label"
|
||||
description_key = "setting.update_check_duration_threshold.description"
|
||||
default = 5
|
||||
min = 1
|
||||
max = 30
|
||||
@@ -110,6 +110,15 @@ description_key = "setting.system_stats_check_interval.description"
|
||||
default = 10
|
||||
min = 5
|
||||
|
||||
[[setting]]
|
||||
key = "system_stats_check_duration_threshold"
|
||||
type = "int"
|
||||
label_key = "setting.system_stats_check_duration_threshold.label"
|
||||
description_key = "setting.system_stats_check_duration_threshold.description"
|
||||
default = 5
|
||||
min = 1
|
||||
max = 30
|
||||
|
||||
[[setting]]
|
||||
key = "show_update_check_notification"
|
||||
type = "bool"
|
||||
|
||||
@@ -32,12 +32,14 @@
|
||||
"setting.widget.update_available_color.label": "Update available color",
|
||||
"setting.widget.unknown_glyph.label": "Unknown status glyph",
|
||||
"setting.widget.unknown_color.label": "Unknown status color",
|
||||
"setting.check_interval.label": "Update check interval",
|
||||
"setting.check_interval.description": "How often to check for updates (in minutes)",
|
||||
"setting.check_duration_threshold.label": "Update check duration threshold",
|
||||
"setting.check_duration_threshold.description": "Cancel check if it took too long (in minutes)",
|
||||
"setting.update_check_interval.label": "Update check interval",
|
||||
"setting.update_check_interval.description": "How often to check for updates (in minutes)",
|
||||
"setting.update_check_duration_threshold.label": "Update check duration threshold",
|
||||
"setting.update_check_duration_threshold.description": "Cancel update check if it took too long (in minutes)",
|
||||
"setting.system_stats_check_interval.label": "System stats check interval",
|
||||
"setting.system_stats_check_interval.description": "How often to check for system stats (in minutes)",
|
||||
"setting.system_stats_check_duration_threshold.label": "System stats check duration threshold",
|
||||
"setting.system_stats_check_duration_threshold.description": "Cancel system stats check if it took too long (in minutes)",
|
||||
"setting.show_update_check_notification.label": "Show update check notification",
|
||||
"setting.show_update_check_notification.description": "Whether to show a notification whenever update check is in progress and completed",
|
||||
"setting.show_update_available_notification.label": "Show update available notification",
|
||||
|
||||
Reference in New Issue
Block a user