Skip to content

Instantly share code, notes, and snippets.

@iTeeLion
Last active September 8, 2023 21:07
Show Gist options
  • Save iTeeLion/1e1152067e837325c98bb9703f7baa6c to your computer and use it in GitHub Desktop.
Save iTeeLion/1e1152067e837325c98bb9703f7baa6c to your computer and use it in GitHub Desktop.
Add thermals information to your proxmox node summary panel
#!/bin/bash
PVE_NODES_FILE="/usr/share/perl5/PVE/API2/Nodes.pm"
PVE_TPL_FILE="/usr/share/pve-manager/index.html.tpl"
function installPackages() {
apt-get install -y wget lm-sensors
}
function injectNodes() {
if grep -q "res->{thermalstate}" $PVE_NODES_FILE; then
echo "sensors already injected to nodes file!!!"
else
echo "sensors injection to nodes file not found, injecting..."
cp $PVE_NODES_FILE $PVE_NODES_FILE"_orig"
sed -i 's/my $dinfo = df('\''\/'\''\, 1);/$res->{thermalstate} = `sensors -jA`;\n&/' $PVE_NODES_FILE
fi
}
function injectTemplate() {
if grep -q "pve_node_summary.js" $PVE_TPL_FILE; then
echo "sensors already injected to nodes js file!!!"
else
echo "sensors injection to nodes js file not found, injecting..."
cp $PVE_TPL_FILE $PVE_TPL_FILE"_orig"
wget -O /usr/share/pve-manager/js/pve_node_summary.js https://gist.githubusercontent.com/iTeeLion/efd6c128f6cfa702cc112adeaa8d2177/raw/f76a6e8662b8945c517018a5fc417fb8b44b304b/pve_node_summary.js
sed -i '/<\/head>/i \ <script type="text\/javascript" src="\/pve2\/js\/pve_node_summary.js?ver=\[% version %\]"><\/script>' $PVE_TPL_FILE
fi
}
function init() {
installPackages
injectNodes
injectTemplate
systemctl restart pveproxy
}
init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment