init
This commit is contained in:
commit
1ba2f63ca5
28
docker-compose.yml
Normal file
28
docker-compose.yml
Normal 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:
|
||||||
0
node_exporter/placeholder
Normal file
0
node_exporter/placeholder
Normal file
11
prometheus.yml
Normal file
11
prometheus.yml
Normal 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']
|
||||||
32
scripts/monitor_folder_size.sh
Normal file
32
scripts/monitor_folder_size.sh
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user