An Express.js app for tracking and exposing your host computers usage statistics!
Report Bug
·
Request Feature
Table of Contents
There are times when you want to remotely track how well your machine is doing when handling servers, and I didn't really find a pre-existing solution that suited my needs, so I created Statsy. I wanted to create an easy-to-use and straightforward app that returns your statistics and logs them without any fuss, and I feel that Statsy is a nice solution for this use case.
Of course, Statsy is a new app and thus won't fit all use cases, so please feel free to suggest changes by forking this repo and creating a pull request or opening an issue. Thank you in advance, all contributions are appreciated!
To get a local copy up and running follow these simple example steps:
- npm
npm install npm@latest -g
- Clone the repo
git clone [email protected]:erayalkis/statsy.git
- Build Docker Image
./setup_docker.sh
- Run Docker Container
docker run -p 3000:3000 --name=statsy erayalkis/statsy
- Done!
- Install npm packages
npm install
- Run server
npm run dev
- Done!
To start up your server, simply run the npm run dev
command, and you're all set!
You can visit these routes to get a JSON response:
- /stats: Returns all of the statistics for the host computer.
- /memory: Returns the total and the available memory.
- /memfree: Returns the available memory.
- /memtotal: Returns the total memory.
- /cpus: Returns an array of CPU objects.
- /loadavg: Returns an array of load averages.
- /uptime: Returns the uptime of the host computer.
Statsy's logging features are all toggleable through command line arguments:
- LOG_USAGE_TO_FILE: Enables logging host machine stats to logs/usage.txt.
- LOG_USAGE_TO_CONSOLE: Enables logging host machine stats to the console. (This will clutter up your console a lot, use with caution)
- LOG_REQUESTS_TO_FILE: Enables logging server requests to logs/requests.txt.
- LOG_REQUESTS_TO_CONSOLE: Enables logging server requests to the console.
To enable logging requests to the console, and logging usage stats to a file, you can run:
LOG_REQUESTS_TO_CONSOLE=true LOG_USAGE_TO_FILE=tru npm run dev
And with Docker, you can run:
docker run -p 3000:3000 --name=statsy -e LOG_REQUEST_TO_CONSOLE=true -e LOG_USAGE_TO_FILE=true erayalkis/statsy
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Your Name - @erayaIlkis - [email protected]
Project Link: https://github.com/erayalkis/statsy