Merge pull request #30 from Meliox/integration-eremem
Show in color when temperatures exceed critical values
This commit is contained in:
commit
c2cf636986
@ -8,9 +8,9 @@
|
|||||||
# Display configuration for HDD, NVME, CPU
|
# Display configuration for HDD, NVME, CPU
|
||||||
# Set to 0 to disable line breaks
|
# Set to 0 to disable line breaks
|
||||||
# Note: use these settings only if the displayed layout is broken
|
# Note: use these settings only if the displayed layout is broken
|
||||||
CPU_ITEMS_PER_ROW=0;
|
CPU_ITEMS_PER_ROW=0
|
||||||
NVME_ITEMS_PER_ROW=0;
|
NVME_ITEMS_PER_ROW=0
|
||||||
HDD_ITEMS_PER_ROW=0;
|
HDD_ITEMS_PER_ROW=0
|
||||||
|
|
||||||
# Known CPU sensor names. They can be full or partial but should ensure unambiguous identification.
|
# Known CPU sensor names. They can be full or partial but should ensure unambiguous identification.
|
||||||
# Should new ones be added, also update logic in configure() function.
|
# Should new ones be added, also update logic in configure() function.
|
||||||
@ -233,29 +233,43 @@ function install_mod {
|
|||||||
// ---\n\
|
// ---\n\
|
||||||
const objValue = JSON.parse(value);\n\
|
const objValue = JSON.parse(value);\n\
|
||||||
if (objValue.hasOwnProperty(cpuAddress)) {\n\
|
if (objValue.hasOwnProperty(cpuAddress)) {\n\
|
||||||
const items = objValue[cpuAddress],\n\
|
const items = objValue[cpuAddress];\n\
|
||||||
itemKeys = Object.keys(items).filter(item => { return String(item).startsWith(cpuItemPrefix); });\n\
|
const itemKeys = Object.keys(items).filter(item => { return String(item).startsWith(cpuItemPrefix); });\n\
|
||||||
let temps = [];\n\
|
let temps = [];\n\
|
||||||
itemKeys.forEach((coreKey) => {\n\
|
itemKeys.forEach((coreKey) => {\n\
|
||||||
try {\n\
|
try {\n\
|
||||||
|
let tempVal = NaN, tempMax = NaN, tempCrit = NaN;\n\
|
||||||
Object.keys(items[coreKey]).forEach((secondLevelKey) => {\n\
|
Object.keys(items[coreKey]).forEach((secondLevelKey) => {\n\
|
||||||
if (secondLevelKey.includes('_input')) {\n\
|
if (secondLevelKey.endsWith('_input')) {\n\
|
||||||
let tempStr = '';\n\
|
tempVal = parseFloat(items[coreKey][secondLevelKey]);\n\
|
||||||
let temp = items[coreKey][secondLevelKey];\n\
|
} else if (secondLevelKey.endsWith('_max')) {\n\
|
||||||
let index = coreKey.match(/\\\S+\\\s*(\\\d+)/);\n\
|
tempMax = parseFloat(items[coreKey][secondLevelKey]);\n\
|
||||||
if(index !== null && index.length > 1) {\n\
|
} else if (secondLevelKey.endsWith('_crit')) {\n\
|
||||||
index = index[1];\n\
|
tempCrit = parseFloat(items[coreKey][secondLevelKey]);\n\
|
||||||
tempStr = \`\${cpuTempCaption} \${index}: \${temp}°C\`;\n\
|
|
||||||
}\n\
|
}\n\
|
||||||
else {\n\
|
});\n\
|
||||||
tempStr = \`\${cpuTempCaption}: \${temp}°C\`;\n\
|
if (!isNaN(tempVal)) {\n\
|
||||||
|
let tempStyle = '';\n\
|
||||||
|
if (!isNaN(tempMax) && tempVal > tempMax) {\n\
|
||||||
|
tempStyle = 'color: #FFC300; font-weight: bold;';\n\
|
||||||
|
}\n\
|
||||||
|
if (!isNaN(tempCrit) && tempVal > tempCrit) {\n\
|
||||||
|
tempStyle = 'color: red; font-weight: bold;';\n\
|
||||||
|
}\n\
|
||||||
|
let tempStr = '';\n\
|
||||||
|
let tempIndex = coreKey.match(/\\\S+\\\s*(\\\d+)/);\n\
|
||||||
|
if (tempIndex !== null && tempIndex.length > 1) {\n\
|
||||||
|
tempIndex = tempIndex[1];\n\
|
||||||
|
tempStr = \`\${cpuTempCaption} \${tempIndex}: <span style=\"\${tempStyle}\">\${tempVal}°C</span>\`;\n\
|
||||||
|
} else {\n\
|
||||||
|
tempStr = \`\${cpuTempCaption}: \${tempVal}°C\`;\n\
|
||||||
}\n\
|
}\n\
|
||||||
temps.push(tempStr);\n\
|
temps.push(tempStr);\n\
|
||||||
}\n\
|
}\n\
|
||||||
})\n\
|
} catch (e) { /*_*/\n\
|
||||||
} catch(e) { /*_*/ }\n\
|
}\n\
|
||||||
});\n\
|
});\n\
|
||||||
const result = temps.map((strTemp, index, arr) => { return strTemp + (index + 1 < arr.length ? (itemsPerRow > 0 && (index + 1) % itemsPerRow === 0 ? '<br>' : ' | ') : '')});\n\
|
const result = temps.map((strTemp, index, arr) => { return strTemp + (index + 1 < arr.length ? (itemsPerRow > 0 && (index + 1) % itemsPerRow === 0 ? '<br>' : ' | ') : ''); });\n\
|
||||||
return '<div style=\"text-align: left; margin-left: 28px;\">' + (result.length > 0 ? result.join('') : 'N/A') + '</div>';\n\
|
return '<div style=\"text-align: left; margin-left: 28px;\">' + (result.length > 0 ? result.join('') : 'N/A') + '</div>';\n\
|
||||||
}\n\
|
}\n\
|
||||||
}\n\
|
}\n\
|
||||||
@ -292,12 +306,27 @@ function install_mod {
|
|||||||
let temps = [];\n\
|
let temps = [];\n\
|
||||||
drvKeys.forEach((drvKey, index) => {\n\
|
drvKeys.forEach((drvKey, index) => {\n\
|
||||||
try {\n\
|
try {\n\
|
||||||
|
let tempVal = NaN, tempMax = NaN, tempCrit = NaN;\n\
|
||||||
Object.keys(objValue[drvKey][sensorName]).forEach((secondLevelKey) => {\n\
|
Object.keys(objValue[drvKey][sensorName]).forEach((secondLevelKey) => {\n\
|
||||||
if (secondLevelKey.includes('_input')) {\n\
|
if (secondLevelKey.endsWith('_input')) {\n\
|
||||||
let temp = objValue[drvKey][sensorName][secondLevelKey];\n\
|
tempVal = parseFloat(objValue[drvKey][sensorName][secondLevelKey]);\n\
|
||||||
temps.push(\`Drive \${index + 1}: \${temp}°C\`);\n\
|
} else if (secondLevelKey.endsWith('_max')) {\n\
|
||||||
|
tempMax = parseFloat(objValue[drvKey][sensorName][secondLevelKey]);\n\
|
||||||
|
} else if (secondLevelKey.endsWith('_crit')) {\n\
|
||||||
|
tempCrit = parseFloat(objValue[drvKey][sensorName][secondLevelKey]);\n\
|
||||||
|
}\n\
|
||||||
|
});\n\
|
||||||
|
if (!isNaN(tempVal)) {\n\
|
||||||
|
let tempStyle = '';\n\
|
||||||
|
if (!isNaN(tempMax) && tempVal > tempMax) {\n\
|
||||||
|
tempStyle = 'color: #FFC300; font-weight: bold;';\n\
|
||||||
|
}\n\
|
||||||
|
if (!isNaN(tempCrit) && tempVal > tempCrit) {\n\
|
||||||
|
tempStyle = 'color: red; font-weight: bold;';\n\
|
||||||
|
}\n\
|
||||||
|
const tempStr = \`Drive \${index + 1}: <span style=\"\${tempStyle}\">\${tempVal}°C</span>\`;\n\
|
||||||
|
temps.push(tempStr);\n\
|
||||||
}\n\
|
}\n\
|
||||||
})\n\
|
|
||||||
} catch(e) { /*_*/ }\n\
|
} catch(e) { /*_*/ }\n\
|
||||||
});\n\
|
});\n\
|
||||||
const result = temps.map((strTemp, index, arr) => { return strTemp + (index + 1 < arr.length ? ((index + 1) % itemsPerRow === 0 ? '<br>' : ' | ') : ''); });\n\
|
const result = temps.map((strTemp, index, arr) => { return strTemp + (index + 1 < arr.length ? ((index + 1) % itemsPerRow === 0 ? '<br>' : ' | ') : ''); });\n\
|
||||||
@ -334,12 +363,27 @@ function install_mod {
|
|||||||
let temps = [];\n\
|
let temps = [];\n\
|
||||||
nvmeKeys.forEach((nvmeKey, index) => {\n\
|
nvmeKeys.forEach((nvmeKey, index) => {\n\
|
||||||
try {\n\
|
try {\n\
|
||||||
|
let tempVal = NaN, tempMax = NaN, tempCrit = NaN;\n\
|
||||||
Object.keys(objValue[nvmeKey][sensorName]).forEach((secondLevelKey) => {\n\
|
Object.keys(objValue[nvmeKey][sensorName]).forEach((secondLevelKey) => {\n\
|
||||||
if (secondLevelKey.includes('_input')) {\n\
|
if (secondLevelKey.endsWith('_input')) {\n\
|
||||||
let temp = objValue[nvmeKey][sensorName][secondLevelKey];\n\
|
tempVal = parseFloat(objValue[nvmeKey][sensorName][secondLevelKey]);\n\
|
||||||
temps.push(\`Drive \${index + 1}: \${temp}°C\`);\n\
|
} else if (secondLevelKey.endsWith('_max')) {\n\
|
||||||
|
tempMax = parseFloat(objValue[nvmeKey][sensorName][secondLevelKey]);\n\
|
||||||
|
} else if (secondLevelKey.endsWith('_crit')) {\n\
|
||||||
|
tempCrit = parseFloat(objValue[nvmeKey][sensorName][secondLevelKey]);\n\
|
||||||
|
}\n\
|
||||||
|
});\n\
|
||||||
|
if (!isNaN(tempVal)) {\n\
|
||||||
|
let tempStyle = '';\n\
|
||||||
|
if (!isNaN(tempMax) && tempVal > tempMax) {\n\
|
||||||
|
tempStyle = 'color: #FFC300; font-weight: bold;';\n\
|
||||||
|
}\n\
|
||||||
|
if (!isNaN(tempCrit) && tempVal > tempCrit) {\n\
|
||||||
|
tempStyle = 'color: red; font-weight: bold;';\n\
|
||||||
|
}\n\
|
||||||
|
const tempStr = \`Drive \${index + 1}: <span style=\"\${tempStyle}\">\${tempVal}°C</span>\`;\n\
|
||||||
|
temps.push(tempStr);\n\
|
||||||
}\n\
|
}\n\
|
||||||
})\n\
|
|
||||||
} catch(e) { /*_*/ }\n\
|
} catch(e) { /*_*/ }\n\
|
||||||
});\n\
|
});\n\
|
||||||
const result = temps.map((strTemp, index, arr) => { return strTemp + (index + 1 < arr.length ? ((index + 1) % itemsPerRow === 0 ? '<br>' : ' | ') : ''); });\n\
|
const result = temps.map((strTemp, index, arr) => { return strTemp + (index + 1 < arr.length ? ((index + 1) % itemsPerRow === 0 ? '<br>' : ' | ') : ''); });\n\
|
||||||
|
|||||||
@ -81,7 +81,7 @@ function install_mod {
|
|||||||
|
|
||||||
if [ ! -h "$proxmoxlibminjs" ]; then
|
if [ ! -h "$proxmoxlibminjs" ]; then
|
||||||
msg "Disabling minified front-end library file..."
|
msg "Disabling minified front-end library file..."
|
||||||
(mv "$proxmoxlibminjs" "$BACKUP_DIR/proxmoxlib.min.js.$timestamp" && \
|
(mv "$proxmoxlibminjs" "$BACKUP_DIR/proxmoxlib.min.js.$timestamp" &&
|
||||||
ln -s "$proxmoxlibjs" "$proxmoxlibminjs") || err "Error disabling minified front-end library file."
|
ln -s "$proxmoxlibjs" "$proxmoxlibminjs") || err "Error disabling minified front-end library file."
|
||||||
restart=true
|
restart=true
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user