From 515d77f00adfa38c78f97a0fb098fa3107f8b7d0 Mon Sep 17 00:00:00 2001 From: JHale716 Date: Tue, 4 Jun 2019 22:38:38 +1200 Subject: [PATCH] Update node_helper.js Additional system calls to enable pi/intel use. Config variable in main MMM-SystemStats.js file also needs consideration and addition. Have not proposed there as it is dependant on this suggestion being adopted. --- node_helper.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/node_helper.js b/node_helper.js index 943db08..7ea4986 100644 --- a/node_helper.js +++ b/node_helper.js @@ -59,17 +59,32 @@ module.exports = NodeHelper.create({ } async.parallel([ - // get cpu temp - async.apply(exec, temp_conv + ' /sys/class/thermal/thermal_zone0/temp'), + // propose config setting pi/intel (config chanegs for pi/intel in main js needs adding + if ( cpu === 'pi') { + // get pi cpu temp + async.apply(exec, temp_conv + ' /sys/class/thermal/thermal_zone0/temp'), + } else if ( cpu === 'intel') { + // get intel cpu temp + async.apply(exec, "sensors|grep 1:|awk '{print $3}'"), + } else { + async.apply(exec, "CPU not defined correctly and/or not supported"), + } // get system load async.apply(exec, 'cat /proc/loadavg'), // get free ram in % async.apply(exec, "free | awk '/^Mem:/ {print $4*100/$2}'"), // get uptime async.apply(exec, 'cat /proc/uptime'), - // get root free-space - async.apply(exec, "df -h|grep /dev/root|awk '{print $4}'"), - + // Similar for detecting space + if ( cpu === 'pi') { + // get root free-space on pi + async.apply(exec, "df -h|grep /dev/root|awk '{print $4}'"), + } else if ( cpu === 'intel') { + // get root free-space on intel + async.apply(exec, "df -h|grep /dev/sda2|awk '{print $4}'"), // for Intel Linux + } else { + async.apply(exec, "CPU not defined correctly and/or not supported"), + } ], function (err, res) { var stats = {};