Hack Forums
[Python] Server statistics viewer - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Server statistics viewer (/showthread.php?tid=5697630)



Server statistics viewer - heretobrowse - Aug 18, 2017

Hi,

What would be the best route to go about this. I need to create a lightweight tool that can be deployed on to a bunch of VM's and update a webpage on stats like ram, CPU usage etc?

Thanks guys


* - Goodies - Aug 18, 2017

This wouldn't be too hard to write up. Would you want a single interface to get information on ALL vms? i.e. each VM is a client and there is a central server to which all the data is sent? Or would you want each VM to run its own service?

This is the library I'd use to get the information itself:
https://pypi.python.org/pypi/psutil

You could use Flask to serve the info as a RESTful API. Something like:
Code
curl http:/VM-HOST01:1234/ram
{"success": true, "info": {"name": "VM-HOST01", "memory": "500MB", "max_memory": "1000GB"}}



* - datguy.dev - Aug 18, 2017

I'd do the API as well. Perhaps make a docker container or virtualenv to ease the install and replicate. I guess you could also do an SMB share on the host server, then simply copy/paste /proc system resource files.


* - heretobrowse - Aug 18, 2017

There will be a 'main VM' where all the information will be sent and displayed either on a webpage or some sort of TKinter GUI


* - datguy.dev - Aug 18, 2017

(Aug 18, 2017 09:48 AM)heretobrowse Wrote:  There will be a 'main VM' where all the information will be sent and displayed either on a webpage or some sort of TKinter GUI

Your approach may alleviate the need for some of major aspects of development. Take Windows Hyper-V, you can use Powershell to get the VM resource information so you don't need a data collection agent on each VM. You are aware there exists platforms that do this? Simply google "free vmm."

Unless you're doing this just for learning or something.... But for like the webpage, your going to have to learn languages like HTML, CSS, PHP, JS, JQuery and advanced methods used for graphing and webpage design. Server-side scripting or CGI.

I only use PyQt.


* - Goodies - Aug 18, 2017

That is definitely doable, but it's not something that I'd do for free considering the work required. If you just want VERY basic statistics with little or no aesthetic display, Like a JSON api, that would be fairly easy and I wouldn't mind doing that. You could use Redis or a database or something for storage (volatile or persistent respectively) if you had a lot of machines, but honestly, if it's just for some simple output for basic usage statistics on a small number of machines, it might not even be worth it. A dict in memory would honestly be enough.