From 3bd8e10943dc6c5d322fc9cbc6dfe2b60b249985 Mon Sep 17 00:00:00 2001 From: Nancy Muyeh Date: Fri, 10 Nov 2023 06:05:00 +0100 Subject: [PATCH 1/6] Creation of documentation files --- API-documentation-tools-functions/monitor-mind-brief.md | 1 + API-documentation-tools-functions/monitor-mind-tutorial.md | 1 + 2 files changed, 2 insertions(+) create mode 100644 API-documentation-tools-functions/monitor-mind-brief.md create mode 100644 API-documentation-tools-functions/monitor-mind-tutorial.md diff --git a/API-documentation-tools-functions/monitor-mind-brief.md b/API-documentation-tools-functions/monitor-mind-brief.md new file mode 100644 index 00000000..552cdf5a --- /dev/null +++ b/API-documentation-tools-functions/monitor-mind-brief.md @@ -0,0 +1 @@ +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. diff --git a/API-documentation-tools-functions/monitor-mind-tutorial.md b/API-documentation-tools-functions/monitor-mind-tutorial.md new file mode 100644 index 00000000..68a83ffe --- /dev/null +++ b/API-documentation-tools-functions/monitor-mind-tutorial.md @@ -0,0 +1 @@ +This is how to utilise monitor mind From c712da58ffb933a69aaa25732ca0444b6548cd2f Mon Sep 17 00:00:00 2001 From: Nancy Muyeh Date: Fri, 10 Nov 2023 08:41:29 +0100 Subject: [PATCH 2/6] Changed the tutorial file name to user guide --- ...-mind-tutorial.md => monitor-mind-users-guide} | 0 services/__pycache__/cpu_service.cpython-310.pyc | Bin 0 -> 978 bytes .../__pycache__/memory_service.cpython-310.pyc | Bin 0 -> 328 bytes services/__pycache__/time_service.cpython-310.pyc | Bin 0 -> 357 bytes 4 files changed, 0 insertions(+), 0 deletions(-) rename API-documentation-tools-functions/{monitor-mind-tutorial.md => monitor-mind-users-guide} (100%) create mode 100644 services/__pycache__/cpu_service.cpython-310.pyc create mode 100644 services/__pycache__/memory_service.cpython-310.pyc create mode 100644 services/__pycache__/time_service.cpython-310.pyc diff --git a/API-documentation-tools-functions/monitor-mind-tutorial.md b/API-documentation-tools-functions/monitor-mind-users-guide similarity index 100% rename from API-documentation-tools-functions/monitor-mind-tutorial.md rename to API-documentation-tools-functions/monitor-mind-users-guide diff --git a/services/__pycache__/cpu_service.cpython-310.pyc b/services/__pycache__/cpu_service.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..aa38c5104b13ecb0b4542c44ba4f0a1e8ffd71a4 GIT binary patch literal 978 zcmZuvv2GJV5S`t-IA_NJivShH6_L;t*!cisA(;|cND++%I-PDe_K`cE+1*2OWLHT` z!5<_A1s&hBEmbOdDrVNc*p^spXJ_`jZ)V=S^7yy~xPJV4C;u>j-xTaFj=>w;x{pSH zU^$G}CmS;t^THeZ3^EuW2rj%E7&nA34)8n_4RMHPAlNxX!960tC?#7jLicbFaqAao z418vS3I2_(!0=n|4pwZ*mTN>Sx0&;$@*a-RoY I&}jSr0PU~fp8x;= literal 0 HcmV?d00001 diff --git a/services/__pycache__/memory_service.cpython-310.pyc b/services/__pycache__/memory_service.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0c874821fea01f0972962d2efc522b630d385cde GIT binary patch literal 328 zcmY*TyKVw85cD0*34z2XY?&*<{Q!zU6loHQ(4|3^y*W<8_G#?{9W}o~kuKjuo4=r9 z4T#5BJL_4^dhGiBu3+r{K9IQoNAZZ1#hARPyPExde9K0#Uy^Np-?XuK>Dqz4H#l42w4;jf^CpS#m>Tr8cz z!b+>!!Z=$6N3W)``dN6Sb*0c3m$b!I59{_YC^0Oq<8x|E@bUXuN*!*qJURD!>g5(K Phiqh=ZdUkq+v!qIYulwN)vg8->Tu^}k literal 0 HcmV?d00001 From 3c3e2a49e4f82ca3320d5f92e4bc9250a47fd2d6 Mon Sep 17 00:00:00 2001 From: Nancy Muyeh Date: Fri, 10 Nov 2023 17:07:39 +0100 Subject: [PATCH 3/6] Creation and partial editing of monitor-mind-API-reference.md --- .../monitor-mind-API-reference.md | 77 +++++++++++++++++++ .../monitor-mind-brief.md | 4 + .../monitor-mind-users-guide | 1 - .../monitor-mind-users-guide.md | 4 + 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 API-documentation-tools-functions/monitor-mind-API-reference.md delete mode 100644 API-documentation-tools-functions/monitor-mind-users-guide create mode 100644 API-documentation-tools-functions/monitor-mind-users-guide.md diff --git a/API-documentation-tools-functions/monitor-mind-API-reference.md b/API-documentation-tools-functions/monitor-mind-API-reference.md new file mode 100644 index 00000000..3474f794 --- /dev/null +++ b/API-documentation-tools-functions/monitor-mind-API-reference.md @@ -0,0 +1,77 @@ +# 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 + +@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) diff --git a/API-documentation-tools-functions/monitor-mind-brief.md b/API-documentation-tools-functions/monitor-mind-brief.md index 552cdf5a..f69eca12 100644 --- a/API-documentation-tools-functions/monitor-mind-brief.md +++ b/API-documentation-tools-functions/monitor-mind-brief.md @@ -1 +1,5 @@ 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: diff --git a/API-documentation-tools-functions/monitor-mind-users-guide b/API-documentation-tools-functions/monitor-mind-users-guide deleted file mode 100644 index 68a83ffe..00000000 --- a/API-documentation-tools-functions/monitor-mind-users-guide +++ /dev/null @@ -1 +0,0 @@ -This is how to utilise monitor mind diff --git a/API-documentation-tools-functions/monitor-mind-users-guide.md b/API-documentation-tools-functions/monitor-mind-users-guide.md new file mode 100644 index 00000000..82ec76df --- /dev/null +++ b/API-documentation-tools-functions/monitor-mind-users-guide.md @@ -0,0 +1,4 @@ +# Getting Started with Monitormind + +You just have to log into the dashboard using #put the URL here +Then chose what you want to monitor from the project by clicking on it. \ No newline at end of file From 0c6af8f963cef65238a37dee4b5b7e83d0a25fce Mon Sep 17 00:00:00 2001 From: Nancy Muyeh Date: Sat, 11 Nov 2023 02:23:03 +0100 Subject: [PATCH 4/6] The monitormind reference for developers --- .../monitor-mind-API-reference.md | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/API-documentation-tools-functions/monitor-mind-API-reference.md b/API-documentation-tools-functions/monitor-mind-API-reference.md index 3474f794..44a73388 100644 --- a/API-documentation-tools-functions/monitor-mind-API-reference.md +++ b/API-documentation-tools-functions/monitor-mind-API-reference.md @@ -66,7 +66,16 @@ def get_memory(): @app.route('/api/process') def get_processes(): """API endpoint to get active processes.""" - 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(): @@ -75,3 +84,21 @@ def actualise_cpu_data(): 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) + From ed466e8a80f348ec065f888b1faac1ced048061e Mon Sep 17 00:00:00 2001 From: Nancy Muyeh Date: Sat, 11 Nov 2023 08:45:13 +0100 Subject: [PATCH 5/6] A brief of monitor mind --- API-documentation-tools-functions/monitor-mind-brief.md | 7 +++++++ .../monitor-mind-users-guide.md | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/API-documentation-tools-functions/monitor-mind-brief.md b/API-documentation-tools-functions/monitor-mind-brief.md index f69eca12..fd5a3d7b 100644 --- a/API-documentation-tools-functions/monitor-mind-brief.md +++ b/API-documentation-tools-functions/monitor-mind-brief.md @@ -3,3 +3,10 @@ MonitorMind is an automated system monitoring tool designed to provide real-time 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. \ No newline at end of file diff --git a/API-documentation-tools-functions/monitor-mind-users-guide.md b/API-documentation-tools-functions/monitor-mind-users-guide.md index 82ec76df..255aa756 100644 --- a/API-documentation-tools-functions/monitor-mind-users-guide.md +++ b/API-documentation-tools-functions/monitor-mind-users-guide.md @@ -1,4 +1,8 @@ # Getting Started with Monitormind -You just have to log into the dashboard using #put the URL here -Then chose what you want to monitor from the project by clicking on it. \ No newline at end of file +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 \ No newline at end of file From f8146694fc8de24a9c7915785243c2191a2fca75 Mon Sep 17 00:00:00 2001 From: Nancy Muyeh Date: Sat, 11 Nov 2023 14:20:34 +0100 Subject: [PATCH 6/6] Deleted unnecessary files --- .../__pycache__/cpu_service.cpython-310.pyc | Bin 978 -> 0 bytes .../memory_service.cpython-310.pyc | Bin 328 -> 0 bytes .../__pycache__/time_service.cpython-310.pyc | Bin 357 -> 0 bytes services/cpu_service.py | 22 ------------------ services/memory_service.py | 4 ---- services/time_service.py | 7 ------ 6 files changed, 33 deletions(-) delete mode 100644 services/__pycache__/cpu_service.cpython-310.pyc delete mode 100644 services/__pycache__/memory_service.cpython-310.pyc delete mode 100644 services/__pycache__/time_service.cpython-310.pyc delete mode 100644 services/cpu_service.py delete mode 100644 services/memory_service.py delete mode 100644 services/time_service.py diff --git a/services/__pycache__/cpu_service.cpython-310.pyc b/services/__pycache__/cpu_service.cpython-310.pyc deleted file mode 100644 index aa38c5104b13ecb0b4542c44ba4f0a1e8ffd71a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 978 zcmZuvv2GJV5S`t-IA_NJivShH6_L;t*!cisA(;|cND++%I-PDe_K`cE+1*2OWLHT` z!5<_A1s&hBEmbOdDrVNc*p^spXJ_`jZ)V=S^7yy~xPJV4C;u>j-xTaFj=>w;x{pSH zU^$G}CmS;t^THeZ3^EuW2rj%E7&nA34)8n_4RMHPAlNxX!960tC?#7jLicbFaqAao z418vS3I2_(!0=n|4pwZ*mTN>Sx0&;$@*a-RoY I&}jSr0PU~fp8x;= diff --git a/services/__pycache__/memory_service.cpython-310.pyc b/services/__pycache__/memory_service.cpython-310.pyc deleted file mode 100644 index 0c874821fea01f0972962d2efc522b630d385cde..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 328 zcmY*TyKVw85cD0*34z2XY?&*<{Q!zU6loHQ(4|3^y*W<8_G#?{9W}o~kuKjuo4=r9 z4T#5BJL_4^dhGiBu3+r{K9IQoNAZZ1#hARPyPExde9K0#Uy^Np-?XuK>Dqz4H#l42w4;jf^CpS#m>Tr8cz z!b+>!!Z=$6N3W)``dN6Sb*0c3m$b!I59{_YC^0Oq<8x|E@bUXuN*!*qJURD!>g5(K Phiqh=ZdUkq+v!qIYulwN)vg8->Tu^}k diff --git a/services/cpu_service.py b/services/cpu_service.py deleted file mode 100644 index aad8f812..00000000 --- a/services/cpu_service.py +++ /dev/null @@ -1,22 +0,0 @@ -import time - -import psutil -import services.time_service as ts - -fake_mem = {} - - -def _collect_cpu_usage(): - cpu_usage = psutil.cpu_percent(interval=1) - timestamp = ts.get_history_time() - return timestamp, cpu_usage - - -def get_cpu_usage_array(): - return [i for i in fake_mem.keys()], [i for i in fake_mem.values()] - - -def calculate_cpu_usage(): - """Calculate the current CPU usage as a percentage.""" - timestamp, cpu_usage = _collect_cpu_usage() - fake_mem[timestamp] = cpu_usage diff --git a/services/memory_service.py b/services/memory_service.py deleted file mode 100644 index 182c487d..00000000 --- a/services/memory_service.py +++ /dev/null @@ -1,4 +0,0 @@ -def get_memory_usage(): - """Get the current memory (RAM and Swap) usage as a percentage.""" - return [], [] - diff --git a/services/time_service.py b/services/time_service.py deleted file mode 100644 index c21150eb..00000000 --- a/services/time_service.py +++ /dev/null @@ -1,7 +0,0 @@ -from time import time - - -def get_history_time(): - """Return the history of time.""" - timestamp = time() - return int(timestamp * 1000)