Re-Introducing Cacher

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.
Cacher Example
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.

Enter Cacher

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.
Cacher Example

Installation

Installation is pretty simple:

  1. Download Cacher from either branch (I personally use the HTML branch).
  2. Place it somewhere on your OS X Caching Server.
  3. Setup a cronjob/LaunchD

Example

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.

3 thoughts on “Re-Introducing Cacher

  1. Hi.

    Such an excellent tool. I’m using this to check if my IOS devices are actually using the caching server in a school. Our network is part of a much larger public network and some of the iPads don’t seem to get updates from the local cache but rather go straight to apple for them.

    I’m not getting any IOS 10.x devices showing as using the cache in the generated report, only IOS 9.x devices. Is it possible that IOS 10 is not checking for a local cache or is there a bug in the script?

    I’m running Mac OS Sierra and the latest version of caching sever.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s