A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems.

Overview

x-server-stats

A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems. x-server(in x-server-stats) is not to be confused with X Window System.

Getting started

Installing the crate
$ cargo install x-server-stats
Installing via npm

You can also install x-server-stats via npm, the npm install command will install rust and the x-server-stats binary in your path. This is useful if you want to get started quickly via npm. But we recommend to go with the cargo install command. The npm package is called rust-x-server-stats

$ npm install -g rust-x-server-stats
Installing Rust

You can install Rust by following the instructions from the rust lang website. The command to install rust using bash looks like below on the website, it's always advisable to follow the instructions on the official website. We don't recommend using the command below as it may not be the latest version and other repos can have malicious bash script as well.

# Just for reference, please always head over to the official website for the instructions.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Install PostgreSQL 14

You can install PostgreSQL 14 by following the instructions from the PostgreSQL website. We use PostgreSQL 14 for the database, you can use any other databases as well, but we don't provide any support for other databases as of now(please raise an issue if you have a usecase for some other database).

# Just for reference, please always head over to the official homebrew/postgres website for the instructions for your OS.
$ brew install postgresql@14
Setting up environment variables

You need to export below environment variables to run the server. The environment variables prefixed with PG are for PotsgreSQL database. Currently, only PostgreSQL is supported for storing stats.

export SERVER_ADDR=localhost:8082
export PG__USER=PG_USERNAME
export PG__PASSWORD=PG_PASSWORD
export PG__HOST=PG_HOST_URL
export PG__PORT=5432
export PG__DBNAME=PG_DB_NAME
export PG__POOL__MAX_SIZE=20
export BASE_ADDR=http://localhost:8082
Building(and running) the application

Before running the application, you need to build it. You can do this by running the following command:

$ cargo build --release 

Run the binary with the following command:

$ ./target/release/x-server-stats
Running the application directly

You can run the application directly by running the following command:

$ cargo run --release
Running the application with Docker

First copy the Dockerfile.example file to Dockerfile and fill in the environment variables. Then run the below commands to build and run the Docker image.

$ docker build -t x-server-stats .
$ docker run -p 8082:8082 x-server-stats

Features

Web page for server stats

TODO - Need to work on this. The web page will be built using just HTML, CSS, JS with the whole page under 14KB gzipped and minified(due to initcwnd of TCP on linux servers).

Request throttling

x-server-stats uses actix-governor to throttle incoming requests based on IP address. The config is present at src/main.rs and can be changed accordingly. Throttling is important if you don't want to overwhelm the server with too many requests by internal systems. We plan to make this configurable in the future, so you don't have to build from source to change the config.

You might also like...
Stream API for tokio-udp.

UDPflow Stream API for tokio-udp. TCP-like UDP stream use tokio::net::UdpSocket; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use udpflow::{UdpListen

Crate extending futures stream combinators, that is adding precise rate limiter
Crate extending futures stream combinators, that is adding precise rate limiter

stream-rate-limiter Stream combinator .rate_limiter(opt: RateLimitOptions) Provides way to limit stream element rate with constant intervals. It adds

Stream & Download Cartoons & Animes

eren Stream & Download Cartoons & Animes Install Linux/Mac First of all install rust then git clone 'https://github.com/Based-Programmer/eren' && \ cd

Send files over TCP. Quick and simple. Made in Rust.

SFT Multithreaded utility to send files over TCP. The sender writes a header containing the filename, and then the contents of the file, buffered, to

Conway Game of Life plus WebAssembly and basic HTTP Server
Conway Game of Life plus WebAssembly and basic HTTP Server

Conway Game of Life plus WebAssembly and basic HTTP Server How to run First, you have to choose what server do you want to use for hosting the wasm ga

An HTTP server wrapper for omnisette. Supports both V1 (Provision) and V3 of anisette servers.

omnisette-server An HTTP server wrapper for omnisette. Supports both V1 (Provision) and V3 of anisette servers. Setup First, download the Apple Music

Basic chat example to demonstrate I/O and other rust features.

Basic chat Provides basic chat functions: create room send messages to room fetch room's messages Components STP - custom string transfer protocol lib

A high performance http proxy server & extensions platform & net packet capture tool
A high performance http proxy server & extensions platform & net packet capture tool

CthulhuRs A high performance http proxy server A browser extensions platform A net packet capture tool Demonstration Main features of CthulhuRs Inject

β™» A simple and efficient Gemini-to-HTTP proxy written in Rust.

September A simple and efficient Gemini-to-HTTP proxy written in Rust. Usage Docker $ docker run -d [ -e ROOT="gemini://fuwn.me" ] [ -e PORT="8080"] [

Comments
  • GET Stats API: Add memory usage and loadavg data

    GET Stats API: Add memory usage and loadavg data

    Currently only cpu stats are coming in the API response, the loadavg and memory usage values are hard coded. We need to fix this and look for more data that we can add in the API response. The same change will have to be done for index_stats page that returns the data in HTML form over HTTP.

    We can research more about the sysinfo package as well.

    We can prepare a list of stats that are interesting and pick and choose from that list.

    good first issue hacktoberfest hacktoberfest-accepted 
    opened by xamfy 11
  • Fix docker builds

    Fix docker builds

    TODO

    • [x] Try to find the issue in the Dockerfile, and fix the docker image builds.
    • [x] Add steps in docs/readme to build and run the project via docker.
    documentation research-task 
    opened by xamfy 0
  • Separate module for raspberry pi or any debian based distro running SBCs

    Separate module for raspberry pi or any debian based distro running SBCs

    • Build and run the binary on a spare raspberry pi(not used anywhere).
    • Check for the feasibility of publishing data to a MQTT broker or any cloud IoT broker.
    • A separate rust package for IoT devices that publishes data to a MQTT broker(whether on a LAN or a cloud based IoT broker).

    Prerequisites:

    • Understanding of how a SBC like raspberry pi works
    • You have a spare raspberry pi or any other linux based distro running SBCs.

    PS: SBCs - small single-board computers

    good first issue hacktoberfest IoT 
    opened by xamfy 0
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)
    • Dockerfile.example (dockerfile)
    • .github/workflows/devskim.yml (github-actions)
    • .github/workflows/hugo.yml (github-actions)
    • .github/workflows/rust-clippy.yml (github-actions)
    • .github/workflows/rust.yml (github-actions)
    • npm-package/package.json (npm)

    Configuration

    πŸ”‘ Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 15 Pull Requests:

    fix(deps): update rust crate actix-web-lab to 0.18.5
    • Schedule: ["at any time"]
    • Branch name: renovate/actix-web-lab-0.x
    • Merge into: main
    • Upgrade actix-web-lab to 0.18.5
    fix(deps): update rust crate chrono to 0.4.23
    • Schedule: ["at any time"]
    • Branch name: renovate/chrono-0.x
    • Merge into: main
    • Upgrade chrono to 0.4.23
    fix(deps): update rust crate deadpool-postgres to 0.10.3
    • Schedule: ["at any time"]
    • Branch name: renovate/deadpool-postgres-0.x
    • Merge into: main
    • Upgrade deadpool-postgres to 0.10.3
    fix(deps): update rust crate env_logger to 0.9.3
    • Schedule: ["at any time"]
    • Branch name: renovate/env_logger-0.x
    • Merge into: main
    • Upgrade env_logger to 0.9.3
    fix(deps): update rust crate nats to 0.23.1
    • Schedule: ["at any time"]
    • Branch name: renovate/nats-0.x
    • Merge into: main
    • Upgrade nats to 0.23.1
    fix(deps): update rust crate serde to 1.0.147
    • Schedule: ["at any time"]
    • Branch name: renovate/serde-1.x
    • Merge into: main
    • Upgrade serde to 1.0.147
    fix(deps): update rust crate strum_macros to 0.24.3
    • Schedule: ["at any time"]
    • Branch name: renovate/strum_macros-0.x
    • Merge into: main
    • Upgrade strum_macros to 0.24.3
    fix(deps): update rust crate systemstat to 0.2.2
    • Schedule: ["at any time"]
    • Branch name: renovate/systemstat-0.x
    • Merge into: main
    • Upgrade systemstat to 0.2.2
    fix(deps): update rust crate tokio-postgres to 0.7.7
    • Schedule: ["at any time"]
    • Branch name: renovate/tokio-postgres-0.x
    • Merge into: main
    • Upgrade tokio-postgres to 0.7.7
    chore(deps): update rust docker tag to v1.65.0
    • Schedule: ["at any time"]
    • Branch name: renovate/rust-1.x
    • Merge into: main
    • Upgrade rust to 1.65.0
    fix(deps): update rust crate config to 0.13
    • Schedule: ["at any time"]
    • Branch name: renovate/config-0.x
    • Merge into: main
    • Upgrade config to 0.13
    fix(deps): update rust crate minify to 1.3
    • Schedule: ["at any time"]
    • Branch name: renovate/minify-1.x
    • Merge into: main
    • Upgrade minify to 1.3
    fix(deps): update rust crate rdkafka to 0.29
    • Schedule: ["at any time"]
    • Branch name: renovate/rdkafka-0.x
    • Merge into: main
    • Upgrade rdkafka to 0.29
    chore(deps): update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: main
    • Upgrade actions/checkout to v3
    chore(deps): update github/codeql-action action to v2
    • Schedule: ["at any time"]
    • Branch name: renovate/github-codeql-action-2.x
    • Merge into: main
    • Upgrade github/codeql-action to v2

    🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or spam the project. See docs for prhourlylimit for details.


    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
Releases(release-v0.1.2)
Owner
Pratyaksh
Full stack developer with experience in AWS, flutter, Django, and google actions. EraftYps@SO
Pratyaksh
A Matrix Server Stats bot

A bot running trough the matrix network to find all rooms.

Marcel 14 Dec 8, 2021
It's like "docker stats" but with beautiful, real-time charts into your terminal. πŸ“Š

?? ds - Real-time Stats with Terminal Charts Visualize container stats with beautiful, real-time charts directly in your terminal. Why ds? Missing Cha

Rafael R. Camargo 5 Oct 3, 2023
GeoIP lookup server over HTTP.

geoip-http | geoip-http is a fast GeoIP lookup service in Rust, using the Axum web framework. It provides one possible server for tzupdate. Features F

Chris Down 4 Jun 3, 2023
A simple cross-platform remote file management tool to upload and download files over HTTP/S

A simple cross-platform remote file management tool to upload and download files over HTTP/S

sexnine 13 Dec 30, 2022
Implementation of the Docker Registry HTTP API V2 in Rust, that can act as a proxy to other registries

Docker registry server and proxy (I'm bad at creating catchy names, but this one is good enough.) This project aims to implement a Docker Registry HTT

l4p1n (Mathias B.) 2 Dec 30, 2022
Bevy asset loader that transparently supports loading over http(s)

Bevy Web Asset This is a tiny crate that that wraps the standard bevy asset loader, and adds the ability to load assets from http and https urls. Supp

Johan Klokkhammer Helsing 28 Jan 2, 2023
πŸ“‘Proxy HTTP/1.1 requests over a sensitive point-to-point link

ptproxy Motivation What's this? Why do I need this? What's a sensitive network link? What's wrong with a VPN? What's wrong with HTTP[S]? What's wrong

Alba Mendez 5 Jul 26, 2023
SpringQL: Open-source stream processor for IoT devices and in-vehicle computers

What is SpringQL? SpringQL is an open-source stream processor specialized in memory efficiency. It is supposed to run on embedded systems like IoT dev

SpringQL 25 Dec 26, 2022
Transforms UDP stream into (fake) TCP streams that can go through Layer 3 & Layer 4 (NAPT) firewalls/NATs.

Phantun A lightweight and fast UDP to TCP obfuscator. Table of Contents Phantun Latest release Overview Usage 1. Enable Kernel IP forwarding 2. Add re

Datong Sun 782 Dec 30, 2022
General-purpose asynchronous socket stream.

async-socket This crate implements a general-purpose asynchronous socket. The Socket implements AsyncRead, AsyncWrite, Stream and Clone traits and thu

Kristijan Sedlak 3 Oct 20, 2021