Skip to content

Pushing code into production branch after testing on dev server #5

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 20 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
55bc050
chore: ascii art added
codeperfectplus Sep 5, 2024
de3c5b5
feat: systemguard fix added
codeperfectplus Sep 5, 2024
d9a6d30
feat: auto update feature added
codeperfectplus Sep 5, 2024
280567c
feat: auto update feature release
codeperfectplus Sep 5, 2024
081951d
chore: flow chart added
codeperfectplus Sep 5, 2024
107e46c
chore: Add introductory ASCII art to setup script
codeperfectplus Sep 5, 2024
c9e5dd4
git pull for already running server removed
codeperfectplus Sep 5, 2024
1c80d00
chore: Update CPU graph template to display recent CPU usage data
codeperfectplus Sep 5, 2024
3efb70a
chore: cpu, memory, network, battery graph added
codeperfectplus Sep 5, 2024
cf00b00
chore: Add website monitoring page, ping route, and ping model
codeperfectplus Sep 6, 2024
02f8edd
chore: logger added and naming variable improved
codeperfectplus Sep 6, 2024
1706f38
chore: multithreading implemented for background task
codeperfectplus Sep 6, 2024
f50e413
feat: logic improve to track website up or not
codeperfectplus Sep 6, 2024
ef7fa9f
feat: email alert added for website status
codeperfectplus Sep 6, 2024
97bd199
chore: graphs axis fixed
codeperfectplus Sep 6, 2024
47af8f3
feat: refactoed the code base
codeperfectplus Sep 6, 2024
6b00851
feat: logs directory creation bug fixed
codeperfectplus Sep 6, 2024
d8c4ea9
Merge pull request #4 from codeperfectplus/features/graphs
codeperfectplus Sep 6, 2024
865926c
chore: Update default branch name to "production" in setup.sh
codeperfectplus Sep 6, 2024
6f963d9
chore: Update default branch name to "production" in setup.sh
codeperfectplus Sep 6, 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
66 changes: 47 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ System Guard is a Flask app designed to monitor server stats such as CPU, Memory
## Installation 🛠️

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

Expand All @@ -27,6 +27,13 @@ sudo systemguard-installer --uninstall
sudo systemguard-installer --restore
```

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

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


### Help

```bash
Expand All @@ -48,17 +55,25 @@ chmod +x install_miniconda.sh && sudo ./install_miniconda.sh

## Features 🚀

- Monitor server stats like CPU, Memory, Disk, and Network.
- Check the network speed of the server using a speed test.
- Rate limit the speed test to prevent abuse.
- Kill the process that is consuming the most CPU.
- Real-time monitoring of server stats.
- Responsive design that works on mobile, tablet, and desktop.
- Update itself to the latest version.
- Easy download and installation using a bash script.
- Logged user and admin user will get the notification if the user kill some process manully on dashbaord.
- Different email alerts for different actions.
- Different Dashboards for different users.(Deveoper, Admin, IT Manager, Manager)
- Lightweight, open-source, and free to use with a straightforward installation process.
- Capable of monitoring core server metrics like CPU, memory, disk usage, and network traffic.
- Includes built-in security features such as authentication for login, logout, and signup.
- Administrators can manage user accounts by creating, updating, or deleting users.
- Admin-level access is required for configuring settings, managing users, and adjusting security and notification - preferences.
- Historical performance data can be viewed as charts, aiding in trend analysis.
- Supports network speed testing directly from the server.
- Provides the ability to terminate resource-heavy processes with a single command.
- Real-time server metric monitoring keeps data consistently updated.
- The interface is responsive and optimized for various devices including mobile, tablets, and desktops.
- The system can automatically update to the latest version to simplify maintenance.
- Installation can be done quickly via a bash script for easy setup.
- Notifications are sent to users and admins when a process is manually terminated.
- Offers website monitoring tasks that trigger email alerts when a website becomes unavailable.
- Configurable email alerts for various actions across the server.
- Role-based dashboards tailored for Developer, Admin, IT Manager, and Manager roles (upcoming feature).
- Option to download historical data in CSV format for detailed analysis (upcoming feature).
- Server status monitoring with alerts for server downtime or recovery (upcoming feature).


## Email Feature 📧

Expand All @@ -74,7 +89,9 @@ chmod +x install_miniconda.sh && sudo ./install_miniconda.sh
| Server Up | Yes | Admin User |
| Notification Settings Change | Yes | Admin User |
| Signup | Yes(few changes required) | Admin User & Logged User |

| Website Monitoring | Yes | Input Email |
| Server Down | No | Admin User |
| Server Up | No | Admin User |


## Product Screenshots 📸
Expand Down Expand Up @@ -105,12 +122,23 @@ A Docker image has not been created for this project because it requires access

## Upcoming Features 📅

- Threshold notifications
- Customizable dashboards
- Plugin support to make SystemGuard even more powerful.
- make server logs
- Check Disk read/write speed
- Check Firewall status
- Receive notifications when system metrics cross predefined thresholds.
- Customizable dashboards for personalized server monitoring.
- Plugin support to enhance and extend SystemGuard's functionality.
- Generate and manage server logs for better tracking and troubleshooting.
- Monitor disk read/write speeds for performance insights.
- 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.

## Learnings 📖

- How to use the `psutil` library to retrieve system stats.
- How to use multiple Flask routes to display different pages.
- How to use multi-threading to run a function in the background.
- How to use the `chart.js` library to display charts on a webpage.
- How to use the `flask-login` library to manage user sessions.
- How to use the `flask-mail` library to send emails in Flask.

## Acknowledgments

Expand Down
24 changes: 15 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import time
import datetime
from src.config import app
import threading
from src.config import app, db
from src import routes
from src.utils import render_template_from_file, get_flask_memory_usage, cpu_usage_percent, get_memory_percent, ROOT_DIR
from src.models import UserProfile
from src.scripts.email_me import send_smpt_email
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)
Expand All @@ -17,14 +21,16 @@ def register_routes():
app.register_blueprint(routes.speedtest_bp)
app.register_blueprint(routes.process_bp)

app.config['is_server_up_email_sent'] = False




if __name__ == "__main__":
register_routes()
# # Start the memory-consuming program in a separate thread
# memory_thread = threading.Thread(target=memory_consuming_program, daemon=True)
# memory_thread.start()


# 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)
57 changes: 57 additions & 0 deletions installation_flow_chart.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
+-----------------------------------+
| Start |
+-----------------------------------+
|
v
+-----------------------------------+
| Display Menu: |
| (Install, Uninstall, Status) |
+-----------------------------------+
|
v
+---------------------------------------------+
| User selects an option |
+---------------------------------------------+
| | |
v v v
+-------------------+ +-------------------+ +-------------------+
| Option: Install | | Option: Uninstall | | Option: Status |
+-------------------+ +-------------------+ +-------------------+
| | |
v v v
+-------------------+ +-------------------+ +-------------------+
| Ask for Install | | Remove Files | | Check Installation |
| Type (Git/Release)| | and Clean Cron | | and Cron Job |
+-------------------+ +-------------------+ +-------------------+
| | |
v v v
+-------------------+ +-------------------+ +-------------------+
| Download Files | | Uninstallation | | Status: |
| or Clone Git | | Success/Failure | | - Installed? |
+-------------------+ +-------------------+ +-------------------+
| |
v v
+-----------------------+ +-----------------------+
| Extract or Install | | Display status and |
| and Verify | | Health Check Results |
+-----------------------+ +-----------------------+
|
v
+-------------------------------+
| Install Executable & Set Cron |
+-------------------------------+
|
v
+-------------------------------+
| Health Check or Start System |
+-------------------------------+
|
v
+-------------------------------+
| Installation Success or Error |
+-------------------------------+
|
v
+-------------------+
| Exit |
+-------------------+
Loading