Add thermal protection options: temp_limit and temp_sleep
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-win (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled

Introduce two new configuration directives to protect disks from overheating:

- temp_limit <TEMPERATURE_CELSIUS>
  Sets the maximum allowed disk temperature. When any disk exceeds this limit,
  SnapRAID stops all operations and spins down the disks.

- temp_sleep <TIME_IN_MINUTES>
  Specifies how long disks remain in standby after a temperature event.
  Defaults to 15 minutes.

These options allow SnapRAID to automatically pause activity and cool down
disks when a temperature threshold is reached, improving data safety and
hardware longevity.
This commit is contained in:
Andrea Mazzoleni 2025-09-21 19:54:10 +02:00
parent b5bbece95e
commit 906d215bf5
23 changed files with 1144 additions and 81 deletions

View file

@ -631,6 +631,57 @@ unsigned strsplit(char** split_map, unsigned split_max, char* str, const char* d
return mac;
}
void strtrim(char* str)
{
char* begin;
char* end;
begin = str;
while (begin[0] && isspace((unsigned char)begin[0]))
++begin;
end = begin + strlen(begin);
while (end > begin && isspace((unsigned char)end[-1]))
--end;
end[0] = 0;
if (begin != end)
memmove(str, begin, end - begin + 1);
}
#ifndef __MINGW32__
void strlwr(char* s)
{
while (*s) {
*s = tolower((unsigned char)*s);
++s;
}
}
#endif
char* worddigitstr(const char* haystack, const char* needle)
{
size_t len = strlen(needle);
const char* s;
if (len == 0)
return NULL;
for (s = haystack; (s = strstr(s, needle)) != NULL; ++s) {
/* left boundary */
if (s == haystack || isspace((unsigned char)s[-1]) || isdigit((unsigned char)s[-1])) {
/* right boundary */
if (s[len] == '\0' || isspace((unsigned char)s[len]) || isdigit((unsigned char)s[len])) {
return (char *)s;
}
}
}
return NULL;
}
/****************************************************************************/
/* path */