· 8 years ago · Feb 19, 2018, 07:34 AM
1#!/usr/bin/ruby
2
3require 'rubygems'
4require 'pony'
5
6# -k Sender com.apple.backupd-auto
7# This option specifies what recorded the log.
8
9# -k Time ge -48h
10# This filters out anything before 48 hours ago.
11
12result = `syslog -k Sender com.apple.backupd-auto -k Time ge -48h`
13
14if result.length > 1
15 Pony.mail(:to => "EMAIL_TO_SEND_TO",
16 :via => :smtp,
17 :via_options=> {
18 :address => 'smtp.gmail.com',
19 :port => '587',
20 :enable_starttls_auto => true,
21 :user_name => "EMAIL_TO_SEND_FROM",
22 :password => "EMAIL_PASSWORD",
23 :authentication => :plain,
24 :domain => 'gmail.com'
25 },
26 :subject => 'Backup Failure',
27 :body => result)
28end