Working to make basic information to be visible.

This commit is contained in:
Kalzu Rekku
2025-04-05 22:41:26 +03:00
parent 0bee8c7fd3
commit 491b17f086
4 changed files with 19 additions and 14 deletions

View File

@ -14,6 +14,7 @@ RUN apk add --no-cache sqlite-libs \
&& adduser -S -G appgroup appuser
# Copy requirements first (optimization for caching)
COPY gunicorn.conf.py .
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
@ -35,5 +36,5 @@ USER appuser
# Expose port
EXPOSE 5000
# Run the application
CMD ["python", "main.py"]
# Run the application with Gunicorn
CMD ["gunicorn", "--config", "gunicorn.conf.py", "main:app"]

View File

@ -1,5 +1,5 @@
-- Table for node authentication information (unchanged)
CREATE TABLE node_auth (
CREATE TABLE IF NOT EXISTS node_auth (
node_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_name TEXT NOT NULL UNIQUE,
api_key TEXT NOT NULL,
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS admin_keys (
);
-- Updated table for basic node information with new fields
CREATE TABLE node_info (
CREATE TABLE IF NOT EXISTS node_info (
node_id INTEGER PRIMARY KEY,
hostname TEXT NOT NULL,
node_nickname TEXT,
@ -34,7 +34,7 @@ CREATE TABLE node_info (
);
-- Table for node-to-node connection metrics
CREATE TABLE node_connections (
CREATE TABLE IF NOT EXISTS node_connections (
connection_id INTEGER PRIMARY KEY AUTOINCREMENT,
source_node_id INTEGER,
target_node_id INTEGER,
@ -46,7 +46,7 @@ CREATE TABLE node_connections (
);
-- Timeseries table for CPU usage
CREATE TABLE cpu_usage (
CREATE TABLE IF NOT EXISTS cpu_usage (
measurement_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
cpu_percent REAL,
@ -56,7 +56,7 @@ CREATE TABLE cpu_usage (
);
-- Timeseries table for memory usage
CREATE TABLE memory_usage (
CREATE TABLE IF NOT EXISTS memory_usage (
measurement_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
memory_used_mb INTEGER,
@ -67,7 +67,7 @@ CREATE TABLE memory_usage (
);
-- Timeseries table for disk usage
CREATE TABLE disk_usage (
CREATE TABLE IF NOT EXISTS disk_usage (
measurement_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
disk_used_gb INTEGER,
@ -79,7 +79,7 @@ CREATE TABLE disk_usage (
);
-- Table for network usage
CREATE TABLE network_usage (
CREATE TABLE IF NOT EXISTS network_usage (
measurement_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
bytes_sent INTEGER,
@ -91,7 +91,7 @@ CREATE TABLE network_usage (
);
-- Table process monitoring
CREATE TABLE process_stats (
CREATE TABLE IF NOT EXISTS process_stats (
measurement_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
process_count INTEGER,
@ -101,7 +101,7 @@ CREATE TABLE process_stats (
);
-- Table for monitoring configuration and alarm thresholds
CREATE TABLE monitoring_config (
CREATE TABLE IF NOT EXISTS monitoring_config (
config_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
cpu_threshold_percent REAL,
@ -116,7 +116,7 @@ CREATE TABLE monitoring_config (
);
-- Table for alarm history
CREATE TABLE alarm_history (
CREATE TABLE IF NOT EXISTS alarm_history (
alarm_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
alarm_type TEXT CHECK(alarm_type IN ('cpu', 'memory', 'disk', 'temperature',
@ -130,7 +130,7 @@ CREATE TABLE alarm_history (
);
-- Table for node status events
CREATE TABLE node_events (
CREATE TABLE IF NOT EXISTS node_events (
event_id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER,
event_type TEXT CHECK(event_type IN ('online', 'offline', 'error', 'warning')),

View File

@ -177,7 +177,7 @@
x: { ticks: { color: '#aaa' }, grid: { color: 'rgba(255, 255, 255, 0.1)' } },
y: {
min: 0,
max: 100,
max: 400,
ticks: { color: '#aaa' },
grid: { color: 'rgba(255, 255, 255, 0.1)' }
}

4
gunicorn.conf.py Normal file
View File

@ -0,0 +1,4 @@
bind = "0.0.0.0:5000"
workers = 2 # Adjust based on your needs (e.g., 2 * CPU cores + 1)
threads = 4 # Number of threads per worker
timeout = 30 # Worker timeout in seconds