33 lines
1.1 KiB
Bash
33 lines
1.1 KiB
Bash
#!/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
|