Git Product home page Git Product logo

python-system-monitoring's Introduction

Python Flask - Demo Web Application

This is a simple Python Flask web application. The app provides system information and a realtime monitoring screen with dials showing CPU, memory, IO and process information.

The app has been designed with cloud native demos & containers in mind, in order to provide a real working application for deployment, something more than "hello-world" but with the minimum of pre-reqs. It is not intended as a complete example of a fully functioning architecture or complex software design.

Typical uses would be deployment to Kubernetes, demos of Docker, CI/CD (build pipelines are provided), deployment to cloud (Azure) monitoring, auto-scaling

Screenshot

screen

Status

Live instances:


Building & Running Locally

Pre-reqs

  • Be using Linux, WSL or MacOS, with bash, make etc
  • Python 3.8+ - for running locally, linting, running tests etc
  • Docker - for running as a container, or image build and push
  • Azure CLI - for deployment to Azure

Clone the project to any directory where you do development work

git clone https://github.com/benc-uk/python-demoapp.git

Makefile

A standard GNU Make file is provided to help with running and building locally.

help                 ๐Ÿ’ฌ This help message
lint                 ๐Ÿ”Ž Lint & format, will not fix but sets exit code on error
lint-fix             ๐Ÿ“œ Lint & format, will try to fix errors and modify code
image                ๐Ÿ”จ Build container image from Dockerfile
push                 ๐Ÿ“ค Push container image to registry
run                  ๐Ÿƒ Run the server locally using Python & Flask
deploy               ๐Ÿš€ Deploy to Azure Web App
undeploy             ๐Ÿ’€ Remove from Azure
test                 ๐ŸŽฏ Unit tests for Flask app
test-report          ๐ŸŽฏ Unit tests for Flask app (with report output)
test-api             ๐Ÿšฆ Run integration API tests, server must be running
clean                ๐Ÿงน Clean up project

Make file variables and default values, pass these in when calling make, e.g. make image IMAGE_REPO=blah/foo

Makefile Variable Default
IMAGE_REG ghcr.io
IMAGE_REPO benc-uk/python-demoapp
IMAGE_TAG latest
AZURE_RES_GROUP temp-demoapps
AZURE_REGION uksouth
AZURE_SITE_NAME pythonapp-{git-sha}

The app runs under Flask and listens on port 5000 by default, this can be changed with the PORT environmental variable.

Containers

Public container image is available on GitHub Container Registry

Run in a container with:

docker run --rm -it -p 5000:5000 ghcr.io/benc-uk/python-demoapp:latest

Should you want to build your own container, use make image and the above variables to customise the name & tag.

Kubernetes

The app can easily be deployed to Kubernetes using Helm, see deploy/kubernetes/readme.md for details

GitHub Actions CI/CD

A working set of CI and CD release GitHub Actions workflows are provided .github/workflows/, automated builds are run in GitHub hosted runners

Running in Azure App Service (Linux)

If you want to deploy to an Azure Web App as a container (aka Linux Web App), a Bicep template is provided in the deploy directory

For a super quick deployment, use make deploy which will deploy to a resource group, temp-demoapps and use the git ref to create a unique site name

make deploy

Running in Azure App Service (Windows)

Just don't, it's awful

python-system-monitoring's People

Contributors

aj7ay avatar vedthavkar avatar

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.