Skip to content

An Express.js app for tracking your machines usage stats!

License

Notifications You must be signed in to change notification settings

erayalkis/statsy

Repository files navigation

Contributors Forks Stargazers Issues MIT License


Logo

Statsy

An Express.js app for tracking and exposing your host computers usage statistics!
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

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!

(back to top)

Built With

  • HTML
  • CSS3
  • JavaScript
  • TypeScript
  • Express

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps:

Prerequisites

  • npm
    npm install npm@latest -g

Installation

  1. Clone the repo
    git clone git@github.com:erayalkis/statsy.git

With Docker:

  1. Build Docker Image
    ./setup_docker.sh
    
  2. Run Docker Container
    docker run -p 3000:3000 --name=statsy erayalkis/statsy
    
  3. Done!

Without Docker:

  1. Install npm packages
    npm install
    
  2. Run server
    npm run dev
    
  3. Done!

(back to top)

Usage

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.

Command line arg examples:

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

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Your Name - @erayaIlkis - erayalkis@hotmail.com

Project Link: https://github.com/erayalkis/statsy

(back to top)