If your supporting Mac’s in your environment, you probably have come across TimeMachine, Apple’s answer to backups to a local disk or NAS.
While configuring TimeMachine on a Mac is very easy, and good Admin wants to keep track that these backups are actually being run on a regular basis. The problem with this is that Apple doesn’t give you a way to easily monitor this. But I went digging, and found a way.
TimeMachine does have a utility installed on the Mac, and you can get some data from it into Zabbix, but it’s not enough to be really useful. If you’re curious, here are the Items I configured. Note I do a little dancing to parse the output of these system.run[] commands, but they should work well on any Mac.
Note that these commands are being run on the Mac itself, and that Zabbix is running them via the Agent. This works well, but our problem still remains as these functions tell us basic info about the backup, but not the last time that one was really run.
In order to sense last time TimeMachine was run, we exploit the drive needing attached to the Mac, as when TimeMachine makes a backup, it has to attach to a disk, even if it’s a on the network. All we need to do is check a date stamp on a directory, and you can get an approximate time of the last backup. In Zabbix this means we can use a few variables.
- {$TIMEMACHINE_BACKUP_PATH} — The path off the root of the disk which should be the same for all your Macs on the network, like /Volumes/TimeMachine_Disk
- {$MY_BACKUP_PREFIX} — Often times the name if the Mac, like “TOMSMAC”
… and then use the zbx_mac_timemachine_backups_templates.json template that you can import into Zabbix and then change variable names. Note that while {$TIMEMACHINE_BACKUP_PATH} is probably fine for all your Macs who use the same TimeMachine directory to back up their files, the {$MY_BACKUP_PREFIX} should be configured at the Host level and changed to match the user’s mac’s name.