Skip to content

Commit c8a4666

Browse files
updated the dashboard
1 parent 7f3f152 commit c8a4666

2 files changed

Lines changed: 68 additions & 23 deletions

File tree

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
# SystemDashboard
1+
# SystemDashboard
2+
3+
System Dashboard is flask app to monitor the server stats like CPU, Memory, Disk, Network etc. It also provides the option to monitor the server stats in real time.
4+
5+
## Installation
6+
7+
1. Clone the repository
8+
9+
```bash
10+
git clone https://github.com/codeperfectplus/SystemDashboard.git
11+
```
12+
13+
2. Install the dependencies
14+
15+
```bash
16+
pip install -r requirements.txt
17+
```
18+
19+
3. Run the app
20+
21+
```bash
22+
python app.py
23+
```
24+
25+
4. Open the app in your browser
26+
27+
```bash
28+
http://localhost:5000
29+
```
30+
31+
32+
## Why not the docker image?
33+
34+
I have not created the docker image for this project because it requires the access to the host machine to get the server stats. So, it is not possible to get the server stats from the docker container.

dashboard.sh

100644100755
Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
#!/bin/bash
22

3-
# Change to the directory where your Flask app is located
4-
# cd /home/alphahub/development/SystemDashboard || { echo "Directory not found"; exit 1; }
5-
6-
# Create virtual environment if it doesn't exist; otherwise, activate it
7-
eval "$(conda shell.bash hook)"
8-
9-
# Check if the conda environment exists
10-
if ! conda env list | grep -q "systemdashboard"; then
11-
echo "Creating conda environment 'systemdashboard'"
12-
conda create -n systemdashboard python=3.10 -y
13-
echo "Activating conda environment 'systemdashboard'"
14-
conda activate systemdashboard
15-
echo "Installing required packages"
16-
pip install -r requirements.txt
3+
# Determine the directory where this script is located
4+
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
5+
6+
# Define variables for paths relative to the script's directory
7+
FLASK_APP_PATH="${FLASK_APP_PATH:-$SCRIPT_DIR/app.py}"
8+
REQUIREMENTS_FILE="${REQUIREMENTS_FILE:-$SCRIPT_DIR/requirements.txt}"
9+
FLASK_PORT="${FLASK_PORT:-5050}"
10+
LOG_FILE="${SCRIPT_DIR}/my_script.log"
11+
12+
# Full path to Conda setup script
13+
CONDA_SETUP_SCRIPT="/home/deepak/miniconda3/etc/profile.d/conda.sh"
14+
15+
# Check if Conda setup script exists
16+
if [ ! -f "$CONDA_SETUP_SCRIPT" ]; then
17+
echo "Conda setup script not found at $CONDA_SETUP_SCRIPT" >> "$LOG_FILE"
18+
exit 1
19+
fi
20+
21+
# Initialize Conda
22+
source "$CONDA_SETUP_SCRIPT"
23+
24+
# Activate the Conda environment
25+
CONDA_ENV_NAME="systemdashboard"
26+
if conda env list | grep -q "$CONDA_ENV_NAME"; then
27+
echo "Activating Conda environment '$CONDA_ENV_NAME'" >> "$LOG_FILE"
28+
conda activate "$CONDA_ENV_NAME"
1729
else
18-
echo "Activating existing conda environment 'systemdashboard'"
19-
conda activate systemdashboard
30+
echo "Conda environment '$CONDA_ENV_NAME' not found." >> "$LOG_FILE"
31+
exit 1
2032
fi
2133

2234
# Continue with the rest of your script
23-
echo "Conda environment 'systemdashboard' is active."
35+
echo "Conda environment '$CONDA_ENV_NAME' is active." >> "$LOG_FILE"
2436

2537
# Export Flask environment variables
26-
export FLASK_APP=app.py
38+
export FLASK_APP="$FLASK_APP_PATH"
2739
export FLASK_ENV=development # or production
2840

2941
# Check if Flask app is running
30-
if ! pgrep -f "flask run --host=0.0.0.0 --port=5050" > /dev/null; then
31-
echo "Flask app is not running. Starting..."
32-
flask run --host=0.0.0.0 --port=5050 &
42+
if ! pgrep -f "flask run --host=0.0.0.0 --port=$FLASK_PORT" > /dev/null; then
43+
echo "Flask app is not running. Starting..." >> "$LOG_FILE"
44+
flask run --host=0.0.0.0 --port="$FLASK_PORT" &
3345
else
34-
echo "Flask app is already running."
46+
echo "Flask app is already running." >> "$LOG_FILE"
3547
fi

0 commit comments

Comments
 (0)