Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Introduction of a new option singleRow #33

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions MMM-SystemStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Module.register('MMM-SystemStats', {
useSyslog: false,
thresholdCPUTemp: 75, // in configured units
baseURLSyslog: 'http://127.0.0.1:8080/syslog',
label: 'textAndIcon'
label: 'textAndIcon',
singleRow: false,
},
// Define required styles.
getStyles: function() {
Expand Down Expand Up @@ -52,6 +53,7 @@ Module.register('MMM-SystemStats', {
this.stats.freeMem = this.translate('LOADING').toLowerCase();
this.stats.upTime = this.translate('LOADING').toLowerCase();
this.stats.freeSpace = this.translate('LOADING').toLowerCase();
this.stats.ipaddr = this.translate('LOADING').toLowerCase();
this.sendSocketNotification('CONFIG', this.config);
},

Expand All @@ -74,6 +76,7 @@ Module.register('MMM-SystemStats', {
upTime = parseInt(payload.upTime[0]);
this.stats.upTime = moment.duration(upTime, "seconds").humanize();
this.stats.freeSpace = payload.freeSpace;
this.stats.ipaddr = payload.ipaddr;
this.updateDom(this.config.animationSpeed);
}
},
Expand Down Expand Up @@ -104,10 +107,23 @@ Module.register('MMM-SystemStats', {
text: 'DISK_FREE',
icon: 'fa-hdd-o',
},
ipaddr: {
text: 'IP_ADDRESS',
icon: 'fa-info-circle',
},

};

var row;

if (self.config.singleRow) {
row = document.createElement('tr');
}

Object.keys(sysData).forEach(function (item){
var row = document.createElement('tr');
if (!self.config.singleRow) {
row = document.createElement('tr');
}

if (self.config.label.match(/^(text|textAndIcon)$/)) {
var c1 = document.createElement('td');
Expand All @@ -129,9 +145,15 @@ Module.register('MMM-SystemStats', {
c3.innerText = self.stats[item];
row.appendChild(c3);

wrapper.appendChild(row);
if (!self.config.singleRow) {
wrapper.appendChild(row);
}
});

if (self.config.singleRow) {
wrapper.appendChild(row);
}

return wrapper;
},
});
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Module: MMM-SystemStats
This [MagicMirror](https://github.com/MichMich/MagicMirror) modules, shows the processor temperature, system load, available RAM, uptime and free disk space.

display as block

![Magic-Mirror Module MMM-SystemStats screenshot](https://raw.githubusercontent.com/BenRoe/MMM-SystemStats/master/screenshot.png)

display a single line

![Magic-Mirror Module MMM-SystemStats screenshot](https://raw.githubusercontent.com/spitzlbergerj/MMM-SystemStats/master/img/MMM-SystemStats-line.jpg)

Tested with:
- Raspberry Pi

Expand Down Expand Up @@ -52,6 +58,7 @@ modules: [
//header: 'System Stats', // This is optional
units: 'metric', // default, metric, imperial
view: 'textAndIcon',
singleRow: false,
},
},
]
Expand Down Expand Up @@ -128,6 +135,12 @@ The following properties can be configured:
<br><b>Default value:</b> <code>http://127.0.0.1:8080/syslog</code>
</td>
</tr>
<tr>
<td><code>singleRow</code></td>
<td>list all values in one single row
<br><b>Default value:</b> <code>false</code>
</td>
</tr>
</tbody>
</table>

Expand Down
Binary file added img/MMM-SystemStats-line.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module.exports = NodeHelper.create({
async.apply(exec, 'cat /proc/uptime'),
// get root free-space
async.apply(exec, "df -h|grep /dev/root|awk '{print $4}'"),

// get ip address
async.apply(exec, "ifconfig | grep inet | grep '255.255.255.0' | tail -1 | awk '{print $2}'"),
],
function (err, res) {
var stats = {};
Expand All @@ -78,6 +79,7 @@ module.exports = NodeHelper.create({
stats.freeMem = res[2][0];
stats.upTime = res[3][0].split(' ');
stats.freeSpace = res[4][0];
stats.ipaddr = res[5][0];
// console.log(stats);
self.sendSocketNotification('STATS', stats);
});
Expand Down
1 change: 1 addition & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"RAM_FREE": "Freier RAM",
"UPTIME": "Laufzeit",
"DISK_FREE": "Freier Speicherplatz",
"IP_ADDRESS": "IP-Adresse",
"TEMP_THRESHOLD_WARNING": "CPU zu heiß!"
}
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"RAM_FREE": "Free RAM",
"UPTIME": "Uptime",
"DISK_FREE": "Avail Space",
"IP_ADDRESS": "IP-Address",
"TEMP_THRESHOLD_WARNING": "CPU Temp is exceeded threshold"
}
1 change: 1 addition & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"RAM_FREE": "RAM Libre",
"UPTIME": "En fonctionnement depuis",
"DISK_FREE": "Espace disponible",
"IP_ADDRESS": "IP-Address",
"TEMP_THRESHOLD_WARNING": "Temp. CPU a dépassé le seuil"
}
1 change: 1 addition & 0 deletions translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"RAM_FREE": "RAM Sisa",
"UPTIME": "Nyala",
"DISK_FREE": "Ruang Sisa",
"IP_ADDRESS": "IP-Address",
"TEMP_THRESHOLD_WARNING": "Suhu CPU melebihi batas normal"
}
1 change: 1 addition & 0 deletions translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"RAM_FREE": "Fri RAM",
"UPTIME": "tid sedan start",
"DISK_FREE": "lagrings plats",
"IP_ADDRESS": "IP-Address",
"TEMP_THRESHOLD_WARNING": "CPU Temperaturen går ovanför gränsen"
}