Display machine state using Python3 with Flask.

Overview

Project Logo

Contributor Badge Gitter Badge NPM Badge License Badge Python Badge

Flask-State

English | 简体中文

Flask-State is a lightweight chart plugin for displaying machine state data in your web application.

  • Monitored Metric: CPU, memory, disk usage, LoadAVG and boot time.
  • Extensible: Offers rich customization options, including redis monitoring, user authentication, custom logging, i18n and etc.
  • Stable: Solves multiprocessing concurrency problems (if you use gunicorn) built on top of lightweight dependencies.

This project is in active development and thoroughly tested to ensure that Flask-State stays up-to-date with its project roadmap.

Screenshot

Documentation

Check out the live demo, or head over to the tutorial for more instructions.

Installation

Get this plugin from PyPI:

pip install Flask-State

Alternatively, install Flask-State via NPM or include this script tag to the head section of your HTML document:

<script src="https://cdn.jsdelivr.net/gh/yoobool/[email protected]/packages/umd/flask-state.min.js"></script>
<link href="https://cdn.jsdelivr.net/gh/yoobool/[email protected]/packages/flask-state.min.css" rel="stylesheet">
npm install flask-state --save

Usage

1. Bind Database Address

from flask_state import DEFAULT_BIND_SQLITE
app.config['SQLALCHEMY_BINDS'] = {DEFAULT_BIND_SQLITE: 'sqlite:///path'}

2. Configure Flask-State

import flask_state
flask_state.init_app(app)

3. Include Imports to Views

// requires echarts module
import 'echarts';
import 'flask-state/flask-state.min.css';
import {init} from 'flask-state';
// Create a DOM node with ID 'test'. After init() binds the node,
// click to open the listening window
init({dom:document.getElementById('test')});

Learn more about advanced configurations in the documentation.

Contributing

See the planning document for a roadmap and existing feature requests.

Flask-State follows the Contributor Covenant Code of Conduct.

Alternatives

Looking for something else? Try another monitor project:

Community Channel

We're on Gitter! Join the conversation for more questions and inquiries about this project.

License

Flask-State is available under the BSD-3-Clause License.

Comments
  • Consider using dataclasses

    Consider using dataclasses

    I see that you're using sqlalchemy and db.Model to describe your data and queries.

    I've been trying to use dataclasses + fquery to do something similar.

    dataclasses-sql on sqlalchemy: most recent commits in the repo below have examples.

    https://github.com/adsharma/dataclasses-sql/tree/decorator

    More on fquery:

    https://adsharma.github.io/fquery/ https://github.com/adsharma/fquery

    Looking for django/flask projects to test these ideas out.

    opened by adsharma 4
  • i18n: improves Japanese translation.

    i18n: improves Japanese translation.

    I noticed that there were some errors in the Japanese localization. This PR aims to improve the Japanese translation by using established terminology.

    opened by hentai-chan 3
  • GitHub Action to lint Python code

    GitHub Action to lint Python code

    Output: https://github.com/cclauss/flask-state/actions

    Run pytest .
    ImportError while loading conftest '/home/runner/work/flask-state/flask-state/tests/conftest.py'.
    tests/conftest.py:4: in <module>
        from src.flask_state import DEFAULT_BIND_SQLITE
    E   ModuleNotFoundError: No module named 'src'
    Error: Process completed with exit code 4.
    
    opened by cclauss 3
  • Docs: Improved style, grammar and formatting.

    Docs: Improved style, grammar and formatting.

    I tried to improve the English translation while staying true to the original document. I also changed the formatting a little so that this README file conforms to markdown rules and recommendations.

    docs 
    opened by hentai-chan 2
  • Example needs a separate README

    Example needs a separate README

    Currently, it is unclear how to use example/, because there's no information available.

    Looks like it needs its own guide:

    • How to install all the required dependencies?
    • How to run the project?
    • What should you expect?
    • How to simulate the high-load so I can test that the metrics work?
    docs 
    opened by sobolevn 2
  • `name` field is duplicated in both setup.py and setup.cfg

    `name` field is duplicated in both setup.py and setup.cfg

    1. https://github.com/yoobool/flask-state/blob/master/setup.cfg#L2
    2. https://github.com/yoobool/flask-state/blob/master/setup.py#L8

    In my opinion, there should be only a single place to define this data.

    opened by sobolevn 2
  • Change disk usage plot to a pie chart or a disk chart.

    Change disk usage plot to a pie chart or a disk chart.

    Is your feature request related to a problem? Please describe. Change disk usage plot to a pie chart or a disk chart.

    Describe the solution you'd like The disk usage plot can be changed to a pie chart which will have a better representation.

    enhancement good first issue 
    opened by ajinsunny 2
  • log.exception does not show the full stack trace of the problem

    log.exception does not show the full stack trace of the problem

    Describe the bug When I use log.exception, the Flask-State does not log trace as expected.
    It just show the error msg like use log.error

    To Reproduce Steps to reproduce the behavior:

    1. Run the examples/app.py without change the example Redis config
    2. Change the services/host_status in line 94 from log.warning(t) to log.exception(t)
    3. When trigger the record events, timeout error will be raised

    Expected behavior log.exception will print full stack trace of the error

    Actual behavior Simply log imeout connecting to server and with confuse code line like the following output:

    FLASK_APP = examples/app.py
    FLASK_ENV = development
    FLASK_DEBUG = 1
    
    flask-state/env/bin/python -m flask run
     * Serving Flask app "examples/app.py" (lazy loading)
     * Environment: development
     * Debug mode: on
     * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
     * Restarting with stat
    2020-11-22 23:11:20,821 | INFO | manager:record_timer:83 - Acquired file lock successfully. process ID: 29123
     * Debugger is active!
     * Debugger PIN: 161-836-542
    127.0.0.1 - - [22/Nov/2020 23:11:41] "GET / HTTP/1.1" 200 -
    2020-11-22 23:12:01,012 | ERROR | __init__:exception:1413 - Timeout connecting to server
    2020-11-22 23:12:01,025 | INFO | host_status:create_host_status:52 - Insert status
    

    Additional context Commit ID is 11c2ea4b29c40b3fa10cb85b38986eeca0b93ce3

    bug 
    opened by FesonX 2
  • Activation of DeepSource

    Activation of DeepSource

    Hi 👋

    One of my Pull Requests around fixing Code Quality Issues with DeepSource was merged here: https://github.com/yoobool/flask-state/pull/33

    I'd just like to inform you that the issues fixed here were detected by running DeepSource analysis on the repo. If you like, you can activate analysis for your repository to detect such code quality issues/bug risks on the fly for every change made. You can also use the Autofix feature to fix them with one click.

    The .deepsource.toml file you merged will only take effect if you activate analysis for this repo.

    Here's what you can do if you wish to activate DeepSource to continuously analyze your repository:

    • Sign up on DeepSource and activate analysis for this repository.
    • Create .deepsource.toml configuration which you can use to configure your analysis settings (My PR already added that, but feel free to edit it anytime).
    • Track/Check analysis here.

    If you have any doubts or questions, you can check out the docs, or feel free to reach out :)

    opened by HarshCasper 1
  • Memory usage of the application or the code

    Memory usage of the application or the code

    Real time use of the memory in the code e.g. if you import NumPy then what's the state of the memory. If you create a variable then how much did the memory increase. Increase or change in memory usage as per every line that's present in the code would be really helpful for the programmers.

    opened by Prashantmdgl9 1
  • Network monitor on web dashboard

    Network monitor on web dashboard

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Would be nice to have a network monitor in the dashboard. Something that depicted network information such as packets in/out, data received/sent, etc.

    Describe alternatives you've considered No alternative, but I think it would make a good addition to the dashboard.

    Additional context Might I recommend looking into the Scapy python library. It is a packet manipulation library that allows you to implement packet sniffers and network monitors.

    enhancement 
    opened by skekre98 1
  • Using custom exception with app error handler

    Using custom exception with app error handler

    Flask mentions Implementing API Exceptions in docs, which MAY be better than what we used in current project.

    from flask import jsonify
    
    class InvalidUsage(Exception):
        status_code = 400
    
        def __init__(self, message, status_code=None, payload=None):
            Exception.__init__(self)
            self.message = message
            if status_code is not None:
                self.status_code = status_code
            self.payload = payload
    
        def to_dict(self):
            rv = dict(self.payload or ())
            rv['message'] = self.message
            return rv
    
    @app.errorhandler(InvalidUsage)
    def handle_invalid_usage(error):
        response = jsonify(error.to_dict())
        response.status_code = error.status_code
        return response
    
    @app.route('/foo')
    def get_foo():
        """**Just raise and don't need more try-catch code!**"""
        raise InvalidUsage('This view is gone', status_code=410)
    
    enhancement 
    opened by FesonX 0
  • Temperature, number of users etc as the features

    Temperature, number of users etc as the features

    I believe the temperature of the machine will be an interesting feature as the machines overheat when running deep learning models locally. Boot time, number of threads can be an interesting addition as well.

    opened by Prashantmdgl9 1
  • Consider GPU and maybe some analytics

    Consider GPU and maybe some analytics

    GPU stats can be included too

    Also temperature of CPU and other internal components and the relation between usage and temperature can be interesting stats to look at...

    Besides, if you give interesting stats and analytics to your users and work on this area, it can be amazing and it brings a great advantage to your program. It may worth to inspect machine state monitor desktop programs to discover features that would match your project.

    enhancement 
    opened by FarshadAmiri 1
  • Prometheus metrics compatibility

    Prometheus metrics compatibility

    This is more like a question, not actually a feature request.

    For me right now it is unclear if I can use this project together with Prometheus stack. It is the default solution right now for monitoring things.

    Looks like it should be possible to use it instead of your own frontend to see the metrics. Or are there any problems / unknowns?

    opened by sobolevn 1
Releases(v1.1.4)
  • v1.1.4(Jun 18, 2021)

  • v1.1.3(May 11, 2021)

    Improvements

    • [Refactor] [back-end] Extract file lock decorator

    Bug Fixes

    • [Fix] [back-end] Fix the alembic_version table update version failed

    • [Fix] [back-end] Block other databases from creating alembic_version table

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Apr 22, 2021)

    Features

    • [Feature] [back-end] Add user login information collection

    • [Feature] [back-end] Add Network IO packet sending and receiving data collection

    • [Feature] [back-end] Add disk IO read and write count collection

    Bug Fixes

    • [Fix] [back-end] Fix the error of querying the latest database version
    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Mar 31, 2021)

    Features

    • [Feature] [front-end] Add Disk IO line chart

    Improvements

    • [Refactor] [back-end] IO data returns the latest 480

    • [Style] [front-end] Modify CPUs legend width

    Bug Fixes

    • [Fix] [back-end] Fix database migration exception when a single process starts
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Mar 24, 2021)

    Features

    • [Feature] [back-end] Add cpu multi-core data collection

    Improvements

    • [Refactor] [back-end] Refactor the returned data structure to speed up the front-end rendering speed

    Bug Fixes

    • [Fix] [back-end] Fix network IO data will increase abnormally
    Source code(tar.gz)
    Source code(zip)
  • v1.0.8(Mar 3, 2021)

    Improvements

    • [Refactor] [back-end] Refactor code

    • [Refactor] [back-end] Explicit conversion log print error content as str

    • [Refactor] [back-end] Prohibit multiple threads writing to the database at the same time

    • [Refactor] [back-end] Compatible to obtain some computers lacking io information

    Bug Fixes

    • [Fix] [back-end] Fix SQL delete operation failed and did not release resources in time
    Source code(tar.gz)
    Source code(zip)
  • v1.0.7(Feb 17, 2021)

    Features

    • [Feature] [back-end] Add disk IO and network IO data collection

    • [Feature] [front-end] Network IO line chart instead of disk usage line chart

    Improvements

    • [Refactor] [back-end] Split part of the bloated code

    • [Styles] [back-end] The latest status data acquisition is changed from reading from the database to real-time reading

    • [Styles] [back-end] Add redis missing tips

    Source code(tar.gz)
    Source code(zip)
  • v1.0.6(Jan 11, 2021)

    Improvements

    • [Styles] Improve README #31

    • [Refactor] [back-end] Code-Refactor #33

    • [Styles] [back-end] Added docker-compose and HOWTO #30

    • [Refactor] [back-end] Improve example application #24

    • [Styles] [front-end] Added I18N #20, #34

    Bug Fixes

    • [Fix] [back-end] Fix abnormal collection task behavior during host sleep

    • [Fix] [back-end] Fix the problem that redis is blocked

    • [Fix] [back-end] Fix the exception log path is incorrect

    • [Fix] [front-end] Fix some text display exception #38

    Source code(tar.gz)
    Source code(zip)
  • v1.0.5(Nov 20, 2020)

    Improvements

    • [Refactor] [back-end] Refactor the code according to the PE8 specification #16

    • [Styles] [front-end] Added Spanish and Indonesian #15

    • [Actions] [back-end] Actions test each operating system and Python version 3.5-3.9

    Bug Fixes

    • [Fix] [front-end] Fix an exception thrown in the console when the return code is not 200

    • [Fix] [back-end] Fix logger TypeError for Python 3.8 API change #14

    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Nov 11, 2020)

    1.0.4

    Improvements

    • [Refactor] [front-end] Modify font specifications and terminology

    • [Test] [back-end] GitHub Action to lint Python code #9

    Bug Fixes

    • [Fix] [back-end] Fix redis ImportError

    • [Fix] [back-end] Fix the problem that the Test module cannot run normally

    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Nov 6, 2020)

  • v1.0.2(Nov 6, 2020)

    Improvements

    • [Refactor] [front-end] Modify display styles.

    Bug Fixes

    • [Fix] [front-end] fix display problem in low resolution.

    • [Fix] [back-end] fix Windows system db_path no access.

    • [Fix] [back-end] fix the problem that the thread cannot end normally when receiving the exit signal.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Oct 21, 2020)

    Features

    • [Feature] [front-end] add custom Dom node binding trigger event.

    • [Feature] [front-end] add i18n-zh display language.

    • [Feature] [back-end] add logger print instructions, and users can customize the logger object.

    • [Feature] [back-end] when the user loads the flask-login module, the flask-state can be verified at the same time.

    Improvements

    • [Refactor] normalization code.

    • [Refactor] [front-end] compressed view files ( JavaScript, CSS ).

    Bug Fixes

    • [Fix] [front-end] fix duplicate addition of flask-state elements.

    • [Fix] [front-end] fix duplicate binding of mobile phone user switching label event.

    • [Fix] [back-end] fix the problem that non application/json header can request data.

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Aug 29, 2020)

Prometheus exporter for Flask applications

Prometheus Flask exporter This library provides HTTP request metrics to export into Prometheus. It can also track method invocations using convenient

Viktor Adam 535 Dec 23, 2022
Fully Automated YouTube Channel ▶️with Added Extra Features.

Fully Automated Youtube Channel ▒█▀▀█ █▀▀█ ▀▀█▀▀ ▀▀█▀▀ █░░█ █▀▀▄ █▀▀ █▀▀█ ▒█▀▀▄ █░░█ ░░█░░ ░▒█░░ █░░█ █▀▀▄ █▀▀ █▄▄▀ ▒█▄▄█ ▀▀▀▀ ░░▀░░ ░▒█░░ ░▀▀▀ ▀▀▀░

sam-sepiol 249 Jan 2, 2023
Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display

Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display

Mark McIntyre 64 Oct 11, 2022
An IoT Trivia app that shows you how to take a JSON web API such as the opentdb.com API and stream and display it on a FeatherS2 in an OLED display.

CircuitPython IoT Trivia ESP32-S2 OLED Version An IoT Trivia app that shows you how to take a JSON web API such as the opentdb.com API and stream and

Kevin Thomas 1 Nov 27, 2021
Adjust the white point, gamma or make your XDR display darker without losing HDR peak luminance or the ability to adjust display brightness

XDR Tuner Adjust the white point, gamma or make your XDR display darker without losing HDR peak luminance or the ability to adjust display brightness

François Simond 16 Dec 28, 2022
TB Set color display - Add-on for Blender to set multiple objects and material Display Color at once.

TB_Set_color_display Add-on for Blender with operations to transfer name between object, data, materials and action names Set groups of object's or ma

null 1 Jun 1, 2022
Python3🐍 webApp to display your current playing music on OBS Studio.

Spotify Overlay A Overlay to display on Obs Studio or any related video/stream recorder, the current music that is playing on your Spotify. Installati

carlitos 0 Oct 17, 2022
flask-apispec MIT flask-apispec (🥉24 · ⭐ 520) - Build and document REST APIs with Flask and apispec. MIT

flask-apispec flask-apispec is a lightweight tool for building REST APIs in Flask. flask-apispec uses webargs for request parsing, marshmallow for res

Joshua Carp 617 Dec 30, 2022
Periodically check the manuscript state in the scholar one system and send email when finding a new state.

ScholarOne-manuscript-checker Periodically check the manuscript state in the scholar one system and send email when finding a new state. Parameters ne

null 2 Aug 18, 2022
Spotify Top Lists - get the current top lists of a user from the Spotify API and display them in a Flask app

Spotify Top Lists This is a simple script that will get the current top lists of a user from the Spotify API and display them in a Flask app. Requirem

Yasin 0 Oct 16, 2022
python3 flask based python-url-shortener microservice.

python-url-shortener This repository is for managing all public/private entity specific api endpoints for an organisation. In this case we have entity

Asutosh Parida 1 Oct 18, 2021
machine learning model deployment project of Iris classification model in a minimal UI using flask web framework and deployed it in Azure cloud using Azure app service

This is a machine learning model deployment project of Iris classification model in a minimal UI using flask web framework and deployed it in Azure cloud using Azure app service. We initially made this project as a requirement for an internship at Indian Servers. We are now making it open to contribution.

Krishna Priyatham Potluri 73 Dec 1, 2022
URL Shortener in Flask - Web service using Flask framework for Shortener URLs

URL Shortener in Flask Web service using Flask framework for Shortener URLs Install Create Virtual env $ python3 -m venv env Install requirements.txt

Rafnix Guzman 1 Sep 21, 2021
Pyrin is an application framework built on top of Flask micro-framework to make life easier for developers who want to develop an enterprise application using Flask

Pyrin A rich, fast, performant and easy to use application framework to build apps using Flask on top of it. Pyrin is an application framework built o

Mohamad Nobakht 10 Jan 25, 2022
User Authentication in Flask using Flask-Login

User-Authentication-in-Flask Set up & Installation. 1 .Clone/Fork the git repo and create an environment Windows git clone https://github.com/Dev-Elie

ONDIEK ELIJAH OCHIENG 31 Dec 11, 2022
flask-reactize is a boostrap to serve any React JS application via a Python back-end, using Flask as web framework.

flask-reactize Purpose Developing a ReactJS application requires to use nodejs as back end server. What if you want to consume external APIs: how are

Julien Chomarat 4 Jan 11, 2022
A lightweight, object-oriented finite state machine implementation in Python with many extensions

transitions A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+. Installa

null 4.7k Jan 1, 2023
Easy to use, state-of-the-art Neural Machine Translation for 100+ languages

EasyNMT - Easy to use, state-of-the-art Neural Machine Translation This package provides easy to use, state-of-the-art machine translation for more th

Ubiquitous Knowledge Processing Lab 748 Jan 6, 2023
Django friendly finite state machine support

Django friendly finite state machine support django-fsm adds simple declarative state management for django models. If you need parallel task executio

Viewflow 2.1k Dec 31, 2022
A disassembler for the RP2040 Programmable I/O State-machine!

piodisasm A disassembler for the RP2040 Programmable I/O State-machine! Usage Just run piodisasm.py on a file that contains the PIO code as hex! (Such

Ghidra Ninja 29 Dec 6, 2022