# frozen_string_literal: true module Neetob class CLI module MonthlyAudit module InstancesAndAddons module Cronitor class SetupCorrectlyForLandingPages < CLI::Base APPS_TO_IGNORE = [ "NeetoAuth", "NeetoTower" ] def initialize super() end def run ui.success "### 3.3.3. Checking whether Cronitor monitors are set up correctly for landing pages" all_monitors = Neetob::CLI::Cronitor::GetAllMonitors.new.run apps_data = [["App", "Monitor for Application landing page present", "Monitor for Application landing page enabled", "Comments", "Audit Passed"]] ui.info("\n", print_to_audit_log: false) Neetob::CLI::Sre::Base::RESOURCES.keys.each do |app| comments = nil audit_passed = "No" monitor_for_app_landing_page_present = "No" monitor_for_app_landing_page_enabled = "No" ui.info("Checking Application landing page monitor for #{app}", print_to_audit_log: false) application_landing_page_monitor = all_monitors.select { |monitor| monitor[:name].downcase == "#{app} Homepage".downcase }.first if application_landing_page_monitor.nil? comments = "Monitor not present" else monitor_for_app_landing_page_present = "Yes" if application_landing_page_monitor[:paused] comments = "Monitor is paused" else monitor_for_app_landing_page_enabled = "Yes" audit_passed = "Yes" end end if (audit_passed == "No") && APPS_TO_IGNORE.map(&:downcase).include?(app.downcase.to_s) audit_passed = "Ignored" end apps_data << [app, monitor_for_app_landing_page_present, monitor_for_app_landing_page_enabled, comments, audit_passed] end ui.print_table(apps_data) end end end end end end end