-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-cache-stats.sh
More file actions
executable file
·44 lines (37 loc) · 1.38 KB
/
check-cache-stats.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.38 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
#!/bin/bash
# Cache Statistics Monitor
# Run this to see how well your cache is performing
echo "=== CSFloat Cache Statistics ==="
echo ""
# Total cached items
TOTAL=$(sudo -u postgres psql -d cs2floatapi -t -c "SELECT COUNT(*) FROM items;")
echo "Total Cached Items: $TOTAL"
# Items cached in last hour
RECENT=$(sudo -u postgres psql -d cs2floatapi -t -c "SELECT COUNT(*) FROM items WHERE updated > NOW() - INTERVAL '1 hour';")
echo "Cached (Last Hour): $RECENT"
# Items cached in last 24h
DAY=$(sudo -u postgres psql -d cs2floatapi -t -c "SELECT COUNT(*) FROM items WHERE updated > NOW() - INTERVAL '24 hours';")
echo "Cached (Last 24h): $DAY"
# Most popular weapons
echo ""
echo "Top 5 Most Cached Weapons:"
sudo -u postgres psql -d cs2floatapi -t -c "
SELECT weapon_type, COUNT(*) as count
FROM (
SELECT defindex,
CASE defindex
WHEN 7 THEN 'AK-47'
WHEN 9 THEN 'AWP'
WHEN 16 THEN 'M4A4'
WHEN 60 THEN 'M4A1-S'
WHEN 40 THEN 'USP-S'
ELSE 'Other'
END as weapon_type
FROM items
) AS weapons
GROUP BY weapon_type
ORDER BY count DESC
LIMIT 5;
" | sed 's/^/ /'
echo ""
echo "Cache Health: $(if [ $TOTAL -gt 100 ]; then echo '✅ Excellent'; elif [ $TOTAL -gt 10 ]; then echo '✅ Good'; else echo '⚠️ Building...'; fi)"