Coder Social home page Coder Social logo

system-stats-dashboard's Introduction

system-stats-dashboard

Provides a simple dashboard for viewing system stats, and an API for retrieving said stats programmatically.

There are 3 levels of stats: "current", "recent", and "persisted". Current and recent stats are all kept in memory, and persisted stats are saved to disk. The recent stats are a subset of the persisted stats.

By default:

  • Current stats are updated every 3 seconds.
  • Every minute, the last minute of current stats are consolidated and added as a single entry to the list of recent and persisted stats.
  • 180 entries (3 hours) are kept in the recent list, and 2 megabytes (~2000 entries, ~33 hours) are kept in the persisted list.
  • Persisted stats are stored in ./stats_history.

Running

  • Download the release for your platform from the releases page and unzip it to a directory you like.
  • Run the system-stats-dashboard executable.
  • Go to localhost:8001/dashboard and take a gander at some stats.

Configuration

Configuration options are located in Rocket.toml.

Name Default value Description
address "0.0.0.0" The address to run the server on
port 8001 The port to run the server on
recent_history_size 180 The number of entries to keep in recent history
consolidation_limit 20 The number of entries to collect before consolidating them and writing an entry to recent and persisted stats
update_frequency_seconds 3 The number of seconds to wait between each stats collection
persist_history true Whether to persist stats to disk or not. If set to false, all the config options below are ignored.
history_files_directory "./stats_history" The directory to persist stats to
history_files_max_size_bytes 2_000_000 The maximum size, in bytes, to allow history_files_directory to grow to

Endpoints

Dashboard

/dashboard

Displays current stats, as well as graphs of some recent stats. Defaults to dark mode; add ?dark=false for light mode.

dark_dashboard

/dashboard/history

Same as /dashboard, except for persisted stats.

API

GET /stats

Returns all the most recently collected stats.

Example response:

{
  "general": {
    "uptimeSeconds": 5239,
    "bootTimestamp": 1615846969,
    "loadAverages": {
      "oneMinute": 0.0,
      "fiveMinutes": 0.01,
      "fifteenMinutes": 0.0
    }
  },
  "cpu": {
    "perLogicalCpuLoadPercent": [
      0.0,
      0.0,
      0.0,
      0.0
    ],
    "aggregateLoadPercent": 0.2450943,
    "tempCelsius": 50.464
  },
  "memory": {
    "usedMb": 52,
    "totalMb": 969
  },
  "filesystems": [
    {
      "fsType": "ext4",
      "mountedFrom": "/dev/root",
      "mountedOn": "/",
      "usedMb": 8208,
      "totalMb": 62699
    }
  ],
  "network": {
    "interfaces": [
      {
        "name": "wlan0",
        "addresses": [
          "192.168.1.100"
        ],
        "sentMb": 1,
        "receivedMb": 1,
        "sentPackets": 4391,
        "receivedPackets": 7024,
        "sendErrors": 0,
        "receiveErrors": 0
      }
    ],
    "sockets": {
      "tcpInUse": 5,
      "tcpOrphaned": 0,
      "udpInUse": 4,
      "tcp6InUse": 4,
      "udp6InUse": 3
    }
  },
  "collectionTime": "2021-03-15T18:50:07.721739139-05:00"
}

GET /stats/general

Returns the most recently collected general stats.

Example response:

{
  "uptimeSeconds": 5239,
  "bootTimestamp": 1615846969,
  "loadAverages": {
    "oneMinute": 0.0,
    "fiveMinutes": 0.01,
    "fifteenMinutes": 0.0
  }
}

GET /stats/cpu

Returns the most recently collected stats related to the CPU.

Example response:

{
  "perLogicalCpuLoadPercent": [
    0.0,
    0.0,
    0.0,
    0.0
  ],
  "aggregateLoadPercent": 0.2450943,
  "tempCelsius": 50.464
}

GET /stats/memory

Returns the most recently collected stats related to memory.

Example response:

{
  "usedMb": 52,
  "totalMb": 969
}

GET /stats/filesystems

Returns the most recently collected stats related to filesystems.

Example response:

[
  {
    "fsType": "ext4",
    "mountedFrom": "/dev/root",
    "mountedOn": "/",
    "usedMb": 8208,
    "totalMb": 62699
  }
]

GET /stats/network

Returns the most recently collected stats related to the network.

Example response:

{
  "interfaces": [
    {
      "name": "wlan0",
      "addresses": [
        "192.168.1.100"
      ],
      "sentMb": 1,
      "receivedMb": 1,
      "sentPackets": 4391,
      "receivedPackets": 7024,
      "sendErrors": 0,
      "receiveErrors": 0
    }
  ],
  "sockets": {
    "tcpInUse": 5,
    "tcpOrphaned": 0,
    "udpInUse": 4,
    "tcp6InUse": 4,
    "udp6InUse": 3
  }
}

Possible features to add

  • Load saved history from disk on startup
  • Send emails if certain stats are above/below certain values for a certain amount of time

Building for Raspberry Pi from Windows

  1. Get linker from https://gnutoolchains.com/raspberry/
  2. Add target: rustup target add armv7-unknown-linux-gnueabihf
  3. Build: cargo build --release --target=armv7-unknown-linux-gnueabihf

system-stats-dashboard's People

Contributors

rotoclone avatar

Stargazers

 avatar 沐佑 avatar Pengju He avatar Peter W avatar hibi221b avatar Matthias avatar Francesco avatar yhnu avatar Bin Huang avatar 张伯雨 avatar  avatar Jiping Liu avatar Ben Powley avatar  avatar

Watchers

 avatar  avatar

Forkers

muyz-sudo

system-stats-dashboard's Issues

RUSTSEC-2020-0151: Generators can cause data races if non-Send types are used in their generator functions

Generators can cause data races if non-Send types are used in their generator functions

Details
Package generator
Version 0.6.25
URL Xudong-Huang/generator-rs#27
Date 2020-11-16
Patched versions >=0.7.0

The Generator type is an iterable which uses a generator function that yields
values. In affected versions of the crate, the provided function yielding values
had no Send bounds despite the Generator itself implementing Send.

The generator function lacking a Send bound means that types that are
dangerous to send across threads such as Rc could be sent as part of a
generator, potentially leading to data races.

This flaw was fixed in commit f7d120a3b
by enforcing that the generator function be bound by Send.

See advisory page for additional details.

RUSTSEC-2017-0005: Large cookie Max-Age values can cause a denial of service

Large cookie Max-Age values can cause a denial of service

Details
Package cookie
Version 0.15.0-dev
URL rwf2/cookie-rs#86
Date 2017-05-06
Patched versions <0.6.0,>=0.6.2, <0.7.0,>=0.7.6

Affected versions of this crate use the time crate and the method
Duration::seconds to parse the Max-Age duration cookie setting. This method
will panic if the value is greater than 2^64/1000 and less than or equal to
2^64, which can result in denial of service for a client or server.

This flaw was corrected by explicitly checking for the Max-Age being in this
integer range and clamping the value to the maximum duration value.

See advisory page for additional details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.