Alright, who else here has stared at their Cato bill and felt a physical twinge? 🙃 Especially for those PoPs we spin up for dev/test or temporary bursts. That "always-on" model is great for production, but for everything else... oof.
I got tired of the pain, so I built a little automation to turn PoPs on/off on a schedule. It's basically a cron job that talks to Cato's API. The idea is simple: if your team isn't working (nights, weekends), why pay for that PoP to sit there idle?
Here's the core of it, using a simple script and `cron`. The API makes it pretty straightforward.
```bash
#!/bin/bash
# Script: cato-pop-scheduler.sh
# Set your API keys and PoP ID obviously...
CATO_API_KEY="YOUR_KEY"
POP_UID="YOUR_POP_ID"
# Function to start the PoP
start_pop() {
curl -X POST "https://api.catonetworks.com/api/v1/pops/${POP_UID}/start"
-H "Content-Type: application/json"
-H "x-api-key: ${CATO_API_KEY}"
}
# Function to stop the PoP
stop_pop() {
curl -X POST "https://api.catonetworks.com/api/v1/pops/${POP_UID}/stop"
-H "Content-Type: application/json"
-H "x-api-key: ${CATO_API_KEY}"
}
# Logic for time window (e.g., stop at 8 PM, start at 7 AM)
current_hour=$(date +%H)
if [[ $current_hour -ge 20 ]]; then
stop_pop
echo "$(date): PoP stopped for the night."
elif [[ $current_hour -lt 7 ]]; then
stop_pop
echo "$(date): PoP still off overnight."
else
start_pop
echo "$(date): PoP started for the day."
fi
```
Then just slap it into the crontab to run every hour:
`0 * * * * /path/to/cato-pop-scheduler.sh >> /var/log/cato-scheduler.log 2>&1`
The savings add up surprisingly fast. Brutally honest moment: it's a bit of a hack, and I wish Cato had this as a native feature with a simple UI schedule. But until then, this works and the API is stable enough.
Anyone else tried something similar? Or found a clever way to trim the fat on their Cato setup? Let's commiserate and share scripts.
- tm