-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor-temp-usage.sh
More file actions
executable file
·69 lines (52 loc) · 1.85 KB
/
monitor-temp-usage.sh
File metadata and controls
executable file
·69 lines (52 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# Monitor temporary directory usage during benchmark execution
# Source shared environment variables
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/env.sh"
# Usage function
usage() {
cat <<EOF
Usage: $0 <system>
Monitor temp directory usage for a specific benchmark system.
Arguments:
system The benchmark system to monitor (datafusion, duckdb, etc.)
Examples:
$0 datafusion # Monitor DataFusion temp directory
$0 duckdb # Monitor DuckDB temp directory
The script will monitor: ${MOUNT_POINT}/<system>/temp/
EOF
exit 1
}
# Check if system argument is provided
if [[ $# -ne 1 ]]; then
echo "Error: System argument is required"
echo
usage
fi
SYSTEM="$1"
# Set temp directory based on system
TEMP_DIR="${MOUNT_POINT}/${SYSTEM}/temp"
# Check if temp directory exists
if [[ ! -d "${TEMP_DIR}" ]]; then
echo "Warning: Temp directory does not exist: ${TEMP_DIR}"
echo "Creating directory..."
mkdir -p "${TEMP_DIR}"
fi
echo "Monitoring temp directory for ${SYSTEM}: ${TEMP_DIR}"
echo "Press Ctrl+C to stop"
echo ""
echo "Timestamp | Files | Total Size | Details"
echo "-------------------------|-------|------------|------------------"
while true; do
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
if [[ -d "${TEMP_DIR}" ]]; then
FILE_COUNT=$(find "${TEMP_DIR}" -type f 2>/dev/null | wc -l)
TOTAL_SIZE=$(du -sh "${TEMP_DIR}" 2>/dev/null | awk '{print $1}')
# Get details of largest files
LARGEST=$(find "${TEMP_DIR}" -type f -exec ls -lh {} \; 2>/dev/null | sort -k5 -hr | head -3 | awk '{print $5}' | tr '\n' ' ')
printf "%s | %5d | %10s | %s\n" "$TIMESTAMP" "$FILE_COUNT" "$TOTAL_SIZE" "$LARGEST"
else
printf "%s | %5s | %10s | Directory not found\n" "$TIMESTAMP" "N/A" "N/A"
fi
sleep 1
done