diff --git a/MMM-SystemStats.js b/MMM-SystemStats.js index 1c5d029..06f73f1 100644 --- a/MMM-SystemStats.js +++ b/MMM-SystemStats.js @@ -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() { @@ -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); }, @@ -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); } }, @@ -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'); @@ -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; }, }); diff --git a/README.md b/README.md index d2dbaff..dcea047 100644 --- a/README.md +++ b/README.md @@ -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 @@ -52,6 +58,7 @@ modules: [ //header: 'System Stats', // This is optional units: 'metric', // default, metric, imperial view: 'textAndIcon', + singleRow: false, }, }, ] @@ -128,6 +135,12 @@ The following properties can be configured:
Default value: http://127.0.0.1:8080/syslog + + singleRow + list all values in one single row +
Default value: false + + diff --git a/img/MMM-SystemStats-line.jpg b/img/MMM-SystemStats-line.jpg new file mode 100644 index 0000000..156d1cc Binary files /dev/null and b/img/MMM-SystemStats-line.jpg differ diff --git a/node_helper.js b/node_helper.js index 943db08..cf285ce 100644 --- a/node_helper.js +++ b/node_helper.js @@ -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 = {}; @@ -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); }); diff --git a/translations/de.json b/translations/de.json index f38fae7..df1d659 100644 --- a/translations/de.json +++ b/translations/de.json @@ -4,5 +4,6 @@ "RAM_FREE": "Freier RAM", "UPTIME": "Laufzeit", "DISK_FREE": "Freier Speicherplatz", + "IP_ADDRESS": "IP-Adresse", "TEMP_THRESHOLD_WARNING": "CPU zu heiß!" } diff --git a/translations/en.json b/translations/en.json index 956c323..ffcdd22 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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" } diff --git a/translations/fr.json b/translations/fr.json index 8d5cef9..c9daf79 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -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" } diff --git a/translations/id.json b/translations/id.json index f045eb3..9099693 100644 --- a/translations/id.json +++ b/translations/id.json @@ -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" } diff --git a/translations/sv.json b/translations/sv.json index c6c01b0..02aee89 100644 --- a/translations/sv.json +++ b/translations/sv.json @@ -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" }