Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions API-documentation-tools-functions/monitor-mind-API-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Monitormind provides the following functionalities

- **CPU Monitoring**: Real-time monitoring of CPU usage.
- **Memory Monitoring**: Track RAM and swap usage.
- **Process Tracking**: Monitor and display active system processes.
- **Real-Time Updates**: Frontend updates using polling to display the latest data.

It does this by using the flask Advance Scheduler to schedule code to be executed whenever the client wants to monitor something.
Monitor mind also uses python system and process utilities (psutils) to retrieve information on running processes and system utilisation.


Monitormind also makes use of RESTAPI services which lets it interact the client's software using HTTP request such as GET, POST, PATCH AND HEAD.


# The api code or controller

# starts by importing all necessary packages
from flask import Flask, render_template, jsonify
from flask_apscheduler import APScheduler

# Import service modules
import services.cpu_service as cpu_service
import services.memory_service as memory_service



# set configuration values. The APScheduler is used here to schedule job which will be executed whenever a get request is recived.
class Config:
SCHEDULER_API_ENABLED = True


# create app
app = Flask(__name__)
app.config.from_object(Config())

# initialize scheduler
scheduler = APScheduler()
# if you don't wanna use a config, you can set options here:
# scheduler.api_enabled = True
scheduler.init_app(app)
scheduler.start()

# code bloc to display the home page.
@app.route('/')
def home():
"""Serve the homepage with system metrics."""
return render_template('index.html')


# Code bloc to monitor cpu usage. It uses a get request and then displays data in Java Script Object Notation(JSON)
@app.route('/api/cpu')
def get_cpu():
"""API endpoint to get CPU usage."""
timestamps, cpu_usage = cpu_service.get_cpu_usage_array()
return jsonify(timestamps=timestamps, cpu_usage=cpu_usage)

# RAM and swap tracking code
@app.route('/api/memory')
def get_memory():
"""API endpoint to get memory (RAM and Swap) usage."""
ram_usage, swap_usage = memory_service.get_memory_usage()
return jsonify(ram_usage_history=ram_usage, swap_usage_history=swap_usage)


# code bloc to monitor and display system process
@app.route('/api/process')
def get_processes():
"""API endpoint to get active processes."""
active_processes = process_service.get_active_processes
return jsonify(active_processes=active_processes)

# Update data and display latest data
@app.route('/api/update')
def updates():
"""API endpoint to geet latest updates"
latest_updates =update_service.get_latest_update
return jsonify(latest_update=latest_updates)


@scheduler.task('interval', id='cpu_get_data', seconds=15, misfire_grace_time=1000)
def actualise_cpu_data():
cpu_service.calculate_cpu_usage()


if __name__ == '__main__':
app.run(debug=True, port=2376)



# How it works
# Example

When a client wants types the url of monitormind on his machine,a
conection is first established between the client'computer and the
monitormind server then a http GET request is sent and the api executes
the bloc of code to display the home page by rendering the home page
html_template. The GEt request is responded and the api enables the monitormind home page is
then displayed on the clients srceen.
To check the cpu usage, the client clicks on cpu usage on the home screen, then a http GET reqest is sent which is taken care of by the api and cpu_usage is displayed on the client's screen.

# Support

If you have any questions or run into problems while using monitormind,you can contact monitormind developees at (https://github.com/ADORSYS-GIS/monitor-mind)

12 changes: 12 additions & 0 deletions API-documentation-tools-functions/monitor-mind-brief.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MonitorMind is an automated system monitoring tool designed to provide real-time insights into various system metrics such as CPU usage, RAM, Swap usage, and system processes. Developed as a Flask web application, MonitorMind utilizes Python's `psutil` library to gather system data, presenting it in a user-friendly web interface.

Monitormind can be used to do the following;

# 1.cpu monitoring:
Monitor mind can monitor the how the cpu of a computer is being used and return the info in a sinple form that is easy for users to read and understand.

# 2. Memory and swap usage
Monitormind can actually be used to monitor memory usage by tracking how the memory is managed and how processes are broght into memory and temporarily copied to a disk after they have been ran for a while.

# 3. system processes
Monitormind can also monitor and display all running processes in an that is user friendly.
8 changes: 8 additions & 0 deletions API-documentation-tools-functions/monitor-mind-users-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Getting Started with Monitormind

You just have to log into the dashboard using **URL**
Then choose what you want to monitormid to monitor for you by clicking on it.
Click on **CPU Monitoring** to get real-time monitoring of your CPU usage
Select **Memory Monitoring** To track and view infomatioin about your RAM and swap usage.
Select **Process Tracking** To monitor and display active system processes.
And to get latedt updates simply select **Real-Time Updates** on your monitormind home page
22 changes: 0 additions & 22 deletions services/cpu_service.py

This file was deleted.

4 changes: 0 additions & 4 deletions services/memory_service.py

This file was deleted.

7 changes: 0 additions & 7 deletions services/time_service.py

This file was deleted.