This commit is contained in:
LORENZO\pacio 2024-12-30 16:48:00 +01:00
commit 1ba2f63ca5
4 changed files with 71 additions and 0 deletions

28
docker-compose.yml Normal file
View File

@ -0,0 +1,28 @@
services:
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
node_exporter:
image: prom/node-exporter:latest
ports:
- "9100:9100"
command:
- '--collector.textfile.directory=/etc/node_exporter'
volumes:
- ./node_exporter:/etc/node_exporter
grafana:
image: grafana/grafana:latest
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
volumes:
grafana_data:

View File

11
prometheus.yml Normal file
View File

@ -0,0 +1,11 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['node_exporter:9100']

View File

@ -0,0 +1,32 @@
#!/bin/bash
# File: monitor_multiple_tenants_size.sh
OUTPUT_DIR="../node_exporter" # Directory where the metrics file will be written
METRICS_FILE="$OUTPUT_DIR/tenants_size.prom" # The file containing metrics
# Tenant folders and names - provide each tenant's name and the corresponding folder path
declare -A TENANTS
TENANTS=(
["Tenant1"]="/path/to/tenant1"
["Tenant2"]="/another/path/to/tenant2"
["Tenant3"]="/some/other/path/to/tenant3"
# Add more tenants as needed
)
# Ensure output directory exists
mkdir -p "$OUTPUT_DIR"
# Clear the metrics file to start fresh
> "$METRICS_FILE"
# Iterate through the tenants
for tenant_name in "${!TENANTS[@]}"; do
tenant_folder="${TENANTS[$tenant_name]}"
if [ -d "$tenant_folder" ]; then # Check if the folder exists
folder_size=$(du -sb "$tenant_folder" | awk '{print $1}') # Get the size in bytes
# Write the metric to the metrics file
echo "tenant_folder_size_bytes{tenant=\"$tenant_name\",folder=\"$tenant_folder\"} $folder_size" >> "$METRICS_FILE"
else
echo "Directory $tenant_folder for tenant $tenant_name does not exist!"
fi
done