Several months ago I was tasked to prove that our brand new Caching Server was actually doing it’s job. I had already setup CacheWarmer with an hourly custom script/cronjob, so I knew when new iOS builds would come out, we wouldn’t be crippled.
SNMP could technically be an option but the Caching Service relies on random high ports. We could make assumptions, but that still wouldn’t be good enough to justify why we had this installed in out data center. Anecdotally, I knew it was working: Our users noticed app store improvements, I noticed app store improvements, but our executives wanted metrics.
Apple’s Server information is very minimal and that’s being generous. E-mailing screenshots filled with squiggly line isn’t good enough. Maybe the logs can help?
Reading the Advanced Caching Documentation page, I went ahead and enabled “LogClientIdentity” by running the following command.
sudo serveradmin settings caching:LogClientIdentity = 1
After looking at the generated log files, I knew I was on to something. The logs gave me everything I needed, but with roughly 30,000 machines possibly hitting our caching server, the logs were enormous. I needed to figure out something.
Cacher is a bash script that if configured as a daily cronjob, will e-mail you daily statistics on your devices.
Cacher requires the following:
- OS X Yosemite 10.10.3
- Server 4.1 with Alerts Enabled
Currently there are two branches: Master and HTML:
- Master -> Outputs a standard message to Server 4’s alert mechanism.
- HTML -> Adds some html to the outputted message to trick Server 4’s alert mechanism into sending indented text.
Here is an example e-mail alert from the HTML branch.
Installation is pretty simple:
- Download Cacher from either branch (I personally use the HTML branch).
- Place it somewhere on your OS X Caching Server.
- Setup a cronjob/LaunchD
Create a folder and download it
mkdir -p /Users/Shared/Cacher curl "https://raw.githubusercontent.com/erikng/Cacher/HTML/Cacher" -o "/Users/Shared/Cacher/Cacher"
Make sure it can be executed
chmod a+x /Users/Shared/Cacher/Cacher
Create a root cronjob. This is required for the alert mechanism to work. Alternatively you could create a LaunchDaemon as well, but I find this easier.
sudo env EDITOR=nano crontab -e
Nano will open. Put in your preferred e-mail time alert. I personally have an e-mail sent at 6:30 AM every day.
30 6 * * * /Users/Shared/Cacher/Cacher
After entering this into nano, use hit CTRL+X and save it. If successful, crontab will give you an installation status. If you need more information on setting up a different time, please see this maclife article
Now sit back, wait until tomorrow to see your new statistics and wonder why Apple doesn’t have something like already.