Skip to content

Commit 1bf430d

Browse files
Refactor issue templates and README.md, and update prometheus.sh script
1 parent 0adbfc6 commit 1bf430d

5 files changed

Lines changed: 50 additions & 15 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,27 @@ assignees: ''
88
---
99

1010
**Describe the bug**
11+
1112
A clear and concise description of what the bug is.
1213

1314
**To Reproduce**
15+
1416
Steps to reproduce the behavior:
15-
1. Go to '...'
16-
2. Click on '....'
17-
3. Scroll down to '....'
18-
4. See error
1917

2018
**Expected behavior**
19+
2120
A clear and concise description of what you expected to happen.
2221

2322
**Screenshots**
23+
2424
If applicable, add screenshots to help explain your problem.
2525

26-
**Desktop (please complete the following information):**
26+
**(please complete the following information):**
27+
2728
- OS: [e.g. iOS]
2829
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
30-
31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
30+
- Systemguard version [e.g. 22]
3631

3732
**Additional context**
33+
3834
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ assignees: ''
88
---
99

1010
**Is your feature request related to a problem? Please describe.**
11+
1112
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1213

1314
**Describe the solution you'd like**
15+
1416
A clear and concise description of what you want to happen.
1517

1618
**Describe alternatives you've considered**
19+
1720
A clear and concise description of any alternative solutions or features you've considered.
1821

1922
**Additional context**
23+
2024
Add any other context or screenshots about the feature request here.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
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.
44

5+
56
## Features 🚀
67

78
- Lightweight, open-source, and free to use with a straightforward installation process, out-of-the-box monitoring solution.
@@ -18,6 +19,16 @@ System Guard is a Flask app designed to monitor server stats such as CPU, Memory
1819
- Role-based dashboards tailored for Developer, Admin, IT Manager, and Manager roles (upcoming feature).
1920
- Update security updates with a single click or automatically update to the latest version to simplify maintenance.
2021

22+
## Architecture 🏗️
23+
24+
![SystemGuard-Architecture](/src/docs/images/SystemGuard-Architecture.jpg)
25+
26+
## Tech Stack 🛠️
27+
28+
- **Frontend**: JavaScript, Bootstrap, Chart.js, Grafana
29+
- **Backend**: Python, Flask, SQLAlchemy, SQLite, Prometheus, InfluxDB
30+
- **Monitoring**: psutil, speedtest-cli, nmap, netstat
31+
2132
## Get started 🛠️
2233

2334
- Check the [Installation.md](/src/docs/installation.md) file for installation instructions.
78.7 KB
Loading

src/scripts/prometheus.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
#!/bin/bash
22

3+
# function to get the user name
4+
get_user_name() {
5+
if [ "$(whoami)" = "root" ]; then
6+
LOGNAME_USER=$(logname 2>/dev/null) # Redirect any error output to /dev/null
7+
if [ $? -ne 0 ]; then # Check if the exit status of the last command is not 0
8+
USER_NAME=$(cat /etc/passwd | grep '/home' | cut -d: -f1 | tail -n 1)
9+
else
10+
USER_NAME=$LOGNAME_USER
11+
fi
12+
else
13+
USER_NAME=$(whoami)
14+
fi
15+
echo "$USER_NAME"
16+
}
17+
18+
USER_NAME=$(get_user_name)
319
# Configuration
420
NETWORK_NAME="flask-prometheus-net"
521
CONTAINER_NAME="prometheus"
622
PROMETHEUS_IMAGE="prom/prometheus"
723
PROMETHEUS_PORT="9090"
824
PROMETHEUS_CONFIG_DIR="$(pwd)/prometheus_config"
925
PROMETHEUS_CONFIG_FILE="$PROMETHEUS_CONFIG_DIR/prometheus.yml"
26+
PROMETHEUS_DATA_DIR="/home/$USER_NAME/.database/prometheus"
1027
FLASK_APP_IP=$(hostname -I | cut -d' ' -f1)
1128
FLASK_APP_PORT="5050"
29+
SCRAPING_INTERVAL="10s"
30+
JOB_NAME='systemguard-metrics'
1231

1332
# Logging function for better readability
1433
log() {
@@ -18,18 +37,22 @@ log() {
1837
# Ensure the config directory exists
1938
log "Creating Prometheus config directory if it doesn't exist."
2039
mkdir -p "$PROMETHEUS_CONFIG_DIR"
40+
mkdir -p "$PROMETHEUS_DATA_DIR"
2141

2242
# Create the prometheus.yml configuration file
2343
log "Generating prometheus.yml configuration file."
2444
cat > "$PROMETHEUS_CONFIG_FILE" <<EOL
2545
global:
26-
scrape_interval: 10s # How often Prometheus scrapes the target
46+
scrape_interval: $SCRAPING_INTERVAL
47+
# how frequently to scrape targets from the target list
2748
2849
scrape_configs:
29-
- job_name: 'flask_app_metrics' # Scraping metrics from Flask app
30-
static_configs: # first ip address in the local machine ip address list
50+
- job_name: $JOB_NAME
51+
static_configs:
3152
- targets: ['$FLASK_APP_IP:$FLASK_APP_PORT']
53+
3254
# apeend more targets list to scrape metrics from multiple services, on central prometheus server
55+
# first ip address in the local machine ip address list
3356
EOL
3457

3558
# Check if Docker network exists
@@ -57,6 +80,7 @@ run_output=$(docker run -d \
5780
-p "$PROMETHEUS_PORT:$PROMETHEUS_PORT" \
5881
--restart always \
5982
-v "$PROMETHEUS_CONFIG_FILE:/etc/prometheus/prometheus.yml" \
83+
-v "PROMETHEUS_DATA_DIR:/prometheus" \
6084
"$PROMETHEUS_IMAGE" 2>&1) # Capture both stdout and stderr
6185

6286
# Check if Prometheus started successfully

0 commit comments

Comments
 (0)