lib/uppityrobot/tasks/uppityrobot.rake in uppityrobot-0.3.1 vs lib/uppityrobot/tasks/uppityrobot.rake in uppityrobot-0.4.0

- old
+ new

@@ -53,25 +53,28 @@ CSV.read(csv, headers: true).each do |row| data = row.to_hash name = data["friendly_name"] url = data["url"] + interval = data.fetch("interval", 300) begin if !current_monitors.key?(name) puts "Creating monitor: #{name} #{url}" d = { friendly_name: name, url: url, + interval: interval, type: UptimeRobot::Monitor::Type::HTTP, subtype: UptimeRobot::Monitor::SubType::HTTPS, alert_contacts: contacts } UppityRobot::Client.new(:newMonitor, d).execute - elsif current_monitors.key?(name) && current_monitors[name]["url"] != url - puts "Updating monitor: #{current_monitors[name]["url"]} TO #{url} WITH CONTACTS #{contacts}" + elsif current_monitors.key?(name) && + (current_monitors[name]["url"] != url || current_monitors[name]["interval"] != interval) + puts "Updating monitor: #{current_monitors[name]["url"]} TO #{url} [#{interval}] WITH CONTACTS #{contacts}" # avoid uptimerobot client weirdness - d = { id: current_monitors[name]["id"], url: url, alert_contacts: contacts }.dup + d = { id: current_monitors[name]["id"], url: url, interval: interval, alert_contacts: contacts }.dup UppityRobot::Client.new(:editMonitor, d).execute end rescue UptimeRobot::Error => e puts "Error processing monitor: #{data} #{e.message}" end