├── .gitignore ├── LICENSE ├── README.md ├── config.js ├── index.html ├── package-lock.json ├── package.json ├── server.js └── utils.js /.gitignore: -------------------------------------------------------------------------------- 1 | ###Node### 2 | 3 | lib-cov 4 | *.seed 5 | *.log 6 | *.csv 7 | *.dat 8 | *.out 9 | *.pid 10 | *.gz 11 | 12 | pids 13 | logs 14 | results 15 | 16 | npm-debug.log 17 | ###Node### 18 | 19 | lib-cov 20 | *.seed 21 | *.log 22 | *.csv 23 | *.dat 24 | *.out 25 | *.pid 26 | *.gz 27 | 28 | pids 29 | logs 30 | results 31 | 32 | npm-debug.log 33 | node_modules 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 Mario Pérez Esteso 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Raspberry Pi Monitoring Panel 2 | =================== 3 | 4 | This project consist on a Node.js-based Raspberry Pi monitoring panel that allows to check the temperature, memory status (free, cached, buffered, total...), the CPU load and the top tasks with their PID. 5 | 6 | This is a very useful web app for checking the status not only of a Raspberry Pi but also of a Linux computer. 7 | 8 | # Author 9 | 10 | This project has been developed by [Mario Pérez Esteso](http://github.com/marioperezesteso "Mario Pérez Esteso"). 11 | 12 | #### Contributors 13 | 14 | * [Bernat Borrás Paronella](http://github.com/alorma "Bernat Borrás Paronella") 15 | 16 | # Screenshot 17 | ![Raspberry Pi Monitoring Panel](http://i1.wp.com/geekytheory.com/wp-content/uploads/2013/12/panel-monitorizacion-raspberry-pi-node-js.png "Raspberry Pi Monitoring Panel") 18 | 19 | # How to install 20 | 21 | **STEP 1:** 22 | ~~~ 23 | $ sudo apt-get update && sudo apt-get upgrade 24 | ~~~ 25 | **STEP 2:** 26 | ~~~ 27 | $ sudo apt-get install nodejs npm git 28 | ~~~ 29 | **STEP 3:** 30 | ~~~ 31 | $ git clone https://github.com/GeekyTheory/Raspberry-Pi-Status.git 32 | ~~~ 33 | **STEP 4:** 34 | ~~~ 35 | $ cd Raspberry-Pi-Status 36 | ~~~ 37 | **STEP 5:** 38 | ~~~ 39 | $ npm install 40 | ~~~ 41 | If everything is OK, go to step 6. If it throws an error: 42 | ~~~ 43 | npm config set registry http://registry.npmjs.org/ 44 | ~~~ 45 | ~~~ 46 | npm install 47 | ~~~ 48 | **STEP 6:** 49 | ~~~ 50 | $ nodejs server.js 51 | ~~~ 52 | **STEP 7:** 53 | 54 | Open a browser with your Raspberry Pi's IP and start to listen the port 8000. For example: [http://192.168.1.100:8000](http://192.168.1.100:8000) 55 | 56 | 57 | # License 58 | ~~~~~~ 59 | Copyright 2014 GeekyTheory (Mario Pérez Esteso) 60 | 61 | Licensed under the Apache License, Version 2.0 (the "License"); 62 | you may not use this file except in compliance with the License. 63 | You may obtain a copy of the License at 64 | 65 | http://www.apache.org/licenses/LICENSE-2.0 66 | 67 | Unless required by applicable law or agreed to in writing, software 68 | distributed under the License is distributed on an "AS IS" BASIS, 69 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 70 | See the License for the specific language governing permissions and 71 | limitations under the License. 72 | ~~~~~~~ 73 | 74 | # More info 75 | 76 | For more details, please visit: [Geeky Theory](http://geekytheory.com/panel-de-monitorizacion-para-raspberry-pi-con-node-js/ "Geeky Theory") 77 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | port: process.env.PORT || 3000, 3 | ip: process.env.IP || "0.0.0.0", 4 | intervals: { 5 | short: 5000, 6 | medium: 10000, 7 | long: 60000 8 | } 9 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | Raspberry Pi Status 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 |
32 |
General info
33 |
34 |

Here you can see the general info of the Raspberry Pi

35 |

36 |

37 |
38 | Top list: 39 |
    40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 59 | 60 | 219 | 220 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Raspberry-Pi-Status", 3 | "version": "0.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "accepts": { 8 | "version": "1.3.7", 9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", 10 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", 11 | "requires": { 12 | "mime-types": "~2.1.24", 13 | "negotiator": "0.6.2" 14 | } 15 | }, 16 | "after": { 17 | "version": "0.8.2", 18 | "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", 19 | "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" 20 | }, 21 | "arraybuffer.slice": { 22 | "version": "0.0.7", 23 | "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", 24 | "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==" 25 | }, 26 | "backo2": { 27 | "version": "1.0.2", 28 | "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", 29 | "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" 30 | }, 31 | "base64-arraybuffer": { 32 | "version": "0.1.4", 33 | "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz", 34 | "integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=" 35 | }, 36 | "base64id": { 37 | "version": "2.0.0", 38 | "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", 39 | "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==" 40 | }, 41 | "blob": { 42 | "version": "0.0.5", 43 | "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", 44 | "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==" 45 | }, 46 | "component-bind": { 47 | "version": "1.0.0", 48 | "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", 49 | "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" 50 | }, 51 | "component-emitter": { 52 | "version": "1.3.0", 53 | "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", 54 | "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" 55 | }, 56 | "component-inherit": { 57 | "version": "0.0.3", 58 | "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", 59 | "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" 60 | }, 61 | "cookie": { 62 | "version": "0.4.1", 63 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", 64 | "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==" 65 | }, 66 | "debug": { 67 | "version": "4.1.1", 68 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", 69 | "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", 70 | "requires": { 71 | "ms": "^2.1.1" 72 | } 73 | }, 74 | "engine.io": { 75 | "version": "3.5.0", 76 | "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.5.0.tgz", 77 | "integrity": "sha512-21HlvPUKaitDGE4GXNtQ7PLP0Sz4aWLddMPw2VTyFz1FVZqu/kZsJUO8WNpKuE/OCL7nkfRaOui2ZCJloGznGA==", 78 | "requires": { 79 | "accepts": "~1.3.4", 80 | "base64id": "2.0.0", 81 | "cookie": "~0.4.1", 82 | "debug": "~4.1.0", 83 | "engine.io-parser": "~2.2.0", 84 | "ws": "~7.4.2" 85 | } 86 | }, 87 | "engine.io-client": { 88 | "version": "3.5.0", 89 | "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.5.0.tgz", 90 | "integrity": "sha512-12wPRfMrugVw/DNyJk34GQ5vIVArEcVMXWugQGGuw2XxUSztFNmJggZmv8IZlLyEdnpO1QB9LkcjeWewO2vxtA==", 91 | "requires": { 92 | "component-emitter": "~1.3.0", 93 | "component-inherit": "0.0.3", 94 | "debug": "~3.1.0", 95 | "engine.io-parser": "~2.2.0", 96 | "has-cors": "1.1.0", 97 | "indexof": "0.0.1", 98 | "parseqs": "0.0.6", 99 | "parseuri": "0.0.6", 100 | "ws": "~7.4.2", 101 | "xmlhttprequest-ssl": "~1.5.4", 102 | "yeast": "0.1.2" 103 | }, 104 | "dependencies": { 105 | "debug": { 106 | "version": "3.1.0", 107 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 108 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 109 | "requires": { 110 | "ms": "2.0.0" 111 | } 112 | }, 113 | "ms": { 114 | "version": "2.0.0", 115 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 116 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 117 | } 118 | } 119 | }, 120 | "engine.io-parser": { 121 | "version": "2.2.1", 122 | "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.1.tgz", 123 | "integrity": "sha512-x+dN/fBH8Ro8TFwJ+rkB2AmuVw9Yu2mockR/p3W8f8YtExwFgDvBDi0GWyb4ZLkpahtDGZgtr3zLovanJghPqg==", 124 | "requires": { 125 | "after": "0.8.2", 126 | "arraybuffer.slice": "~0.0.7", 127 | "base64-arraybuffer": "0.1.4", 128 | "blob": "0.0.5", 129 | "has-binary2": "~1.0.2" 130 | } 131 | }, 132 | "has-binary2": { 133 | "version": "1.0.3", 134 | "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", 135 | "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", 136 | "requires": { 137 | "isarray": "2.0.1" 138 | } 139 | }, 140 | "has-cors": { 141 | "version": "1.1.0", 142 | "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", 143 | "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" 144 | }, 145 | "indexof": { 146 | "version": "0.0.1", 147 | "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", 148 | "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" 149 | }, 150 | "isarray": { 151 | "version": "2.0.1", 152 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", 153 | "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" 154 | }, 155 | "mime-db": { 156 | "version": "1.45.0", 157 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz", 158 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==" 159 | }, 160 | "mime-types": { 161 | "version": "2.1.28", 162 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz", 163 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==", 164 | "requires": { 165 | "mime-db": "1.45.0" 166 | } 167 | }, 168 | "ms": { 169 | "version": "2.1.3", 170 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 171 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 172 | }, 173 | "negotiator": { 174 | "version": "0.6.2", 175 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 176 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 177 | }, 178 | "parseqs": { 179 | "version": "0.0.6", 180 | "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz", 181 | "integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w==" 182 | }, 183 | "parseuri": { 184 | "version": "0.0.6", 185 | "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz", 186 | "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow==" 187 | }, 188 | "socket.io": { 189 | "version": "2.4.0", 190 | "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.4.0.tgz", 191 | "integrity": "sha512-9UPJ1UTvKayuQfVv2IQ3k7tCQC/fboDyIK62i99dAQIyHKaBsNdTpwHLgKJ6guRWxRtC9H+138UwpaGuQO9uWQ==", 192 | "requires": { 193 | "debug": "~4.1.0", 194 | "engine.io": "~3.5.0", 195 | "has-binary2": "~1.0.2", 196 | "socket.io-adapter": "~1.1.0", 197 | "socket.io-client": "2.4.0", 198 | "socket.io-parser": "~3.4.0" 199 | } 200 | }, 201 | "socket.io-adapter": { 202 | "version": "1.1.2", 203 | "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz", 204 | "integrity": "sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g==" 205 | }, 206 | "socket.io-client": { 207 | "version": "2.4.0", 208 | "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.4.0.tgz", 209 | "integrity": "sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ==", 210 | "requires": { 211 | "backo2": "1.0.2", 212 | "component-bind": "1.0.0", 213 | "component-emitter": "~1.3.0", 214 | "debug": "~3.1.0", 215 | "engine.io-client": "~3.5.0", 216 | "has-binary2": "~1.0.2", 217 | "indexof": "0.0.1", 218 | "parseqs": "0.0.6", 219 | "parseuri": "0.0.6", 220 | "socket.io-parser": "~3.3.0", 221 | "to-array": "0.1.4" 222 | }, 223 | "dependencies": { 224 | "debug": { 225 | "version": "3.1.0", 226 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 227 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 228 | "requires": { 229 | "ms": "2.0.0" 230 | } 231 | }, 232 | "ms": { 233 | "version": "2.0.0", 234 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 235 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 236 | }, 237 | "socket.io-parser": { 238 | "version": "3.3.2", 239 | "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.2.tgz", 240 | "integrity": "sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg==", 241 | "requires": { 242 | "component-emitter": "~1.3.0", 243 | "debug": "~3.1.0", 244 | "isarray": "2.0.1" 245 | } 246 | } 247 | } 248 | }, 249 | "socket.io-parser": { 250 | "version": "3.4.1", 251 | "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.4.1.tgz", 252 | "integrity": "sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A==", 253 | "requires": { 254 | "component-emitter": "1.2.1", 255 | "debug": "~4.1.0", 256 | "isarray": "2.0.1" 257 | }, 258 | "dependencies": { 259 | "component-emitter": { 260 | "version": "1.2.1", 261 | "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", 262 | "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" 263 | } 264 | } 265 | }, 266 | "to-array": { 267 | "version": "0.1.4", 268 | "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", 269 | "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" 270 | }, 271 | "ws": { 272 | "version": "7.4.2", 273 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz", 274 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA==" 275 | }, 276 | "xmlhttprequest-ssl": { 277 | "version": "1.5.5", 278 | "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", 279 | "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=" 280 | }, 281 | "yeast": { 282 | "version": "0.1.2", 283 | "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", 284 | "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" 285 | } 286 | } 287 | } 288 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Raspberry-Pi-Status", 3 | "version": "0.1.0", 4 | "description": "Raspberry Pi monitoring panel", 5 | "main": "server.js", 6 | "repository": "https://github.com/GeekyTheory/Raspberry-Pi-Status", 7 | "author": "Mario Pérez Esteso ", 8 | "dependencies": { 9 | "socket.io": "~2.4.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Autor: Mario Pérez Esteso 3 | * Web: geekytheory.com 4 | */ 5 | 6 | const {port, ip, intervals} = require('./config'), 7 | {serverHandler, execHandler, errorHandler, counterAdd, counterLess} = require('./utils'), 8 | server = require('http').createServer(serverHandler).listen(port, ip), 9 | io = require('socket.io').listen(server); 10 | 11 | 12 | //Cuando abramos el navegador estableceremos una conexión con socket.io. 13 | //Cada X segundos mandaremos a la gráfica un nuevo valor. 14 | io.sockets.on('connection', function(socket) { 15 | const address = socket.handshake.address; 16 | console.log("New connection from " + address.address + ":" + address.port); 17 | console.log("NUMBER OF CONNECTIONS++: " + counterAdd()); 18 | socket.on('disconnect', function() { 19 | console.log("NUMBER OF CONNECTIONS--: " + counterLess()); 20 | }); 21 | 22 | // Function for checking memory 23 | execHandler("egrep --color 'MemTotal' /proc/meminfo | egrep '[0-9.]{4,}' -o") 24 | .then(stdout => { 25 | socket.emit('memoryTotal', stdout); 26 | }) 27 | .catch(errorHandler); 28 | 29 | execHandler("hostname") 30 | .then(stdout => socket.emit('hostname', stdout)) 31 | .catch(errorHandler); 32 | 33 | execHandler("uptime | tail -n 1 | awk '{print $1}'") 34 | .then(stdout => socket.emit('uptime', stdout)) 35 | .catch(errorHandler); 36 | 37 | execHandler("uname -r") 38 | .then(stdout => socket.emit('kernel', stdout)) 39 | .catch(errorHandler); 40 | 41 | execHandler("top -d 0.5 -b -n2 | tail -n 10 | awk '{print $12}'") 42 | .then(stdout => socket.emit('toplist', stdout)) 43 | .catch(errorHandler); 44 | 45 | 46 | setInterval(function() { 47 | 48 | Promise.all([ 49 | execHandler("egrep --color 'MemFree' /proc/meminfo | egrep '[0-9.]{4,}' -o"), 50 | execHandler("egrep --color 'Buffers' /proc/meminfo | egrep '[0-9.]{4,}' -o"), 51 | execHandler("egrep --color 'Cached' /proc/meminfo | egrep '[0-9.]{4,}' -o"), 52 | execHandler("egrep --color 'MemTotal' /proc/meminfo | egrep '[0-9.]{4,}' -o") 53 | ]) 54 | .then(stdouts => { 55 | const memFree = stdouts[0]; 56 | const memBuffered = stdouts[1]; 57 | const memCached = stdouts[2]; 58 | const memTotal = stdouts[3]; 59 | 60 | const memUsed = parseInt(memTotal, 10) - parseInt(memFree, 10); 61 | const percentUsed = Math.round(parseInt(memUsed, 10) * 100 / parseInt(memTotal, 10)); 62 | const percentFree = 100 - percentUsed; 63 | const percentBuffered = Math.round(parseInt(memBuffered, 10) * 100 / parseInt(memTotal, 10)); 64 | const percentCached = Math.round(parseInt(memCached, 10) * 100 / parseInt(memTotal, 10)); 65 | 66 | socket.emit('memoryUpdate', percentFree, percentUsed, percentBuffered, percentCached); 67 | 68 | }).catch(errorHandler); 69 | 70 | 71 | // Function for measuring temperature 72 | execHandler("cat /sys/class/thermal/thermal_zone0/temp") 73 | .then(stdout => { 74 | const date = new Date().getTime(); 75 | const temp = parseFloat(stdout) / 1000; 76 | socket.emit('temperatureUpdate', date, temp); 77 | }) 78 | .catch(errorHandler); 79 | 80 | }, intervals.short); 81 | 82 | // Uptime 83 | setInterval(function() { 84 | execHandler("uptime | tail -n 1 | awk '{print $3 $4 $5}'") 85 | .then(stdout => socket.emit('uptime', stdout)) 86 | .catch(errorHandler); 87 | 88 | }, intervals.medium); 89 | 90 | // TOP list 91 | setInterval(function() { 92 | execHandler("ps aux --width 30 --sort -rss --no-headers | head | awk '{print $11}'") 93 | .then(stdout => socket.emit('toplist', stdout)) 94 | .catch(errorHandler); 95 | 96 | execHandler("top -d 0.5 -b -n2 | grep 'Cpu(s)'|tail -n 1 | awk '{print $2 + $4}'") 97 | .then(stdout => { 98 | const date = new Date().getTime(); 99 | socket.emit('cpuUsageUpdate', date, parseFloat(stdout)); 100 | }) 101 | .catch(errorHandler); 102 | 103 | }, intervals.long); 104 | }); 105 | 106 | 107 | //Escuchamos en el puerto $port 108 | server.listen(port); -------------------------------------------------------------------------------- /utils.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'), 2 | exec = require('child_process').exec; 3 | 4 | 5 | let connectCounter = 0; 6 | 7 | function counterAdd () { 8 | return ++connectCounter; 9 | } 10 | 11 | function counterLess () { 12 | return --connectCounter; 13 | } 14 | 15 | 16 | 17 | //Si todo va bien al abrir el navegador, cargaremos el archivo index.html 18 | function serverHandler(req, res) { 19 | fs.readFile(__dirname + '/index.html', function(err, data) { 20 | if (err) { 21 | //Si hay error, mandaremos un mensaje de error 500 22 | console.log(err); 23 | res.writeHead(500); 24 | res.end('Error loading index.html'); 25 | } else { 26 | res.writeHead(200); 27 | res.end(data); 28 | } 29 | }); 30 | } 31 | 32 | 33 | function errorHandler (err) { 34 | console.error('exec error: ' + err); 35 | } 36 | 37 | function execHandler (cmd) { 38 | return new Promise ((resolve, reject) => { 39 | 40 | exec(cmd, function(error, stdout, stderr) { 41 | if (error) { 42 | reject(error); 43 | } else { 44 | resolve(stdout); 45 | } 46 | }); 47 | 48 | }) 49 | } 50 | 51 | module.exports = {serverHandler, execHandler, errorHandler, counterAdd, counterLess} --------------------------------------------------------------------------------