Skip to content

Dev to Production push after testing #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f296b08
chore: installtion instruction file created and server logs command a…
codeperfectplus Sep 6, 2024
54e8b84
chore: installation fix function improved and requirement.txt updated
codeperfectplus Sep 6, 2024
b850c52
chore: Update Flask and other dependencies in requirements.txt
codeperfectplus Sep 6, 2024
95084e7
chore: loggin enabled, email alert set for website, smtp configuratio…
codeperfectplus Sep 7, 2024
a36c2a7
chore: basic firwall added
codeperfectplus Sep 7, 2024
ca7df3f
feat: flash messaged added and logic improved to show webpage
codeperfectplus Sep 7, 2024
825aef4
chore: docstring added in firewall
codeperfectplus Sep 7, 2024
2edab53
chore: added docstring
codeperfectplus Sep 7, 2024
9d70cf6
Merge pull request #6 from codeperfectplus/feature/doc_string
codeperfectplus Sep 7, 2024
1776d50
Merge pull request #7 from codeperfectplus/features/firewall
codeperfectplus Sep 7, 2024
930ca96
feat: lazy loading eanbled for homepage
codeperfectplus Sep 7, 2024
ab3e68c
chore: graph is calling in front end
codeperfectplus Sep 8, 2024
4c162e0
Merge pull request #8 from codeperfectplus/features/lazy_loading
codeperfectplus Sep 8, 2024
9b25f83
fix: graph bug fix
codeperfectplus Sep 8, 2024
046e87f
feat: refactored the javascript
codeperfectplus Sep 8, 2024
c2441e6
chore: dependcy update
codeperfectplus Sep 8, 2024
7c6bf9a
Merge pull request #9 from codeperfectplus/features/dependency_updates
codeperfectplus Sep 8, 2024
3970aa9
chore: installtion instrunction improved
codeperfectplus Sep 9, 2024
5fc217a
feat: improved graphs, refresh inteval
codeperfectplus Sep 9, 2024
8713843
fix: logger direcotry issue fixed
codeperfectplus Sep 9, 2024
4b7d9a2
chore: Refactor logger directory creation code
codeperfectplus Sep 9, 2024
aaf01c1
chore: setup.sh imroved
codeperfectplus Sep 9, 2024
8064470
chore: Refactor the installation script
codeperfectplus Sep 9, 2024
4a557e0
reverted the changes for setup.sh
codeperfectplus Sep 9, 2024
987920d
datetime on graph improved
codeperfectplus Sep 9, 2024
2e554bd
chore: reverted system loggin due to memeory issue
codeperfectplus Sep 9, 2024
f85e7d9
chore: Refactor installation script and improve setup.sh
codeperfectplus Sep 9, 2024
d3c8437
Update setup.sh
codeperfectplus Sep 9, 2024
2c4bc01
Update setup.sh
codeperfectplus Sep 9, 2024
8e7221e
Update installation.md
codeperfectplus Sep 9, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

predefine_user.json
src/assets/predefine_user.json
57 changes: 6 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,6 @@

System Guard is a Flask app designed to monitor server stats such as CPU, Memory, Disk, and Network. It also provides real-time monitoring capabilities which can be useful for system administrators, developers, and DevOps engineers to keep track of their server's performance and troubleshoot issues. The app uses the `psutil` library to retrieve system stats and the `speedtest-cli` library to perform a network speed test.

## Installation 🛠️

```bash
wget https://raw.githubusercontent.com/codeperfectplus/SystemGuard/production/setup.sh
chmod +x setup.sh && sudo mv setup.sh /usr/local/bin/systemguard-installer
```

### To install the SystemGuard app, run the following command:

```bash
sudo systemguard-installer --install
```

### To uninstall the SystemGuard app, run the following command:

```bash
sudo systemguard-installer --uninstall
```

### To Restore the SystemGuard app, run the following command:

```bash
sudo systemguard-installer --restore
```

### Incase of any error, run the following command:

```bash
sudo systemguard-installer --fix
```


### Help

```bash
systemguard-installer --help
```


It will install the SystemGuard app and its dependencies in the crontab and it will be started automatically every time the server is restarted. The app will be available at `http://localhost:5050`.

## Dependencies(must be installed)

- Anaconda3/Miniconda3

```bash
# install miniconda3 if not installed already
wget https://raw.githubusercontent.com/codeperfectplus/HackScripts/main/setup/install_miniconda.sh
chmod +x install_miniconda.sh && sudo ./install_miniconda.sh
```

## Features 🚀

- Lightweight, open-source, and free to use with a straightforward installation process.
Expand All @@ -75,6 +24,11 @@ chmod +x install_miniconda.sh && sudo ./install_miniconda.sh
- Server status monitoring with alerts for server downtime or recovery (upcoming feature).


## Installation 🛠️

check the [Installation.md](/src/docs/installation.md) file for installation instructions.


## Email Feature 📧

| Email Alert | Is implemented | who will get the email |
Expand Down Expand Up @@ -130,6 +84,7 @@ A Docker image has not been created for this project because it requires access
- Check the current firewall status to ensure security.
- A dedicated website monitoring page for tracking uptime and performance.
- Track and save total network data sent/received in the database for data usage monitoring.
- Improve website monitor, save data in database with timestamp to show the history of the website.

## Learnings 📖

Expand Down
32 changes: 4 additions & 28 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
import os
import time
import datetime
import threading
from src.config import app, db
from src.config import app
from src import routes
from src.utils import get_system_info_for_db
from src.models import SystemInformation, ApplicationGeneralSettings
from sqlalchemy.exc import SQLAlchemyError
from src.logger import logger
from src.thread_process import monitor_settings, start_website_monitoring

def register_routes():
app.register_blueprint(routes.dashboard_bp)
app.register_blueprint(routes.settings_bp)
app.register_blueprint(routes.system_health_bp)
app.register_blueprint(routes.cpu_info_bp)
app.register_blueprint(routes.disk_info_bp)
app.register_blueprint(routes.memory_info_bp)
app.register_blueprint(routes.network_info_bp)
app.register_blueprint(routes.speedtest_bp)
app.register_blueprint(routes.process_bp)




# background thread to monitor system settings changes
# monitor_settings() # Starts monitoring for system logging changes
start_website_monitoring() # Starts pinging active websites

if __name__ == "__main__":
register_routes()

# Start monitoring settings and website pinging when the server starts
# monitor_settings() # Starts monitoring for system logging changes
# start_website_monitoring() # Starts pinging active websites

# Run the Flask application
app.run(host="0.0.0.0", port=5000, debug=True)
47 changes: 0 additions & 47 deletions line_counter.py

This file was deleted.

23 changes: 0 additions & 23 deletions load_testing.sh

This file was deleted.

29 changes: 22 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
Flask==2.3.3
psutil==5.9.5
gunicorn
flask-sqlalchemy
flask-login
flask-session
python-dotenv
# Flask web framework
Flask==3.0.3

# Library for retrieving system information
psutil==6.0.0

# For managing environment variables
python-dotenv==1.0.1

# WSGI HTTP server for running the application in production
gunicorn==23.0.0

# Flask extensions for database and user session management
flask-sqlalchemy==3.1.1 # SQLAlchemy integration for Flask
flask-login==0.6.3 # User session management for Flask
flask-session==0.8.0 # Server-side session handling for Flask

# File system monitoring and watching
watchdog==5.0.2

#
requests
Loading