Class: Neetob::CLI::MonthlyAudit::InstancesAndAddons::Cronitor::SetupCorrectlyForLandingPages

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/monthly_audit/instances_and_addons/cronitor/setup_correctly_for_landing_pages.rb

Constant Summary collapse

APPS_TO_IGNORE =
[
  "NeetoAuth",
  "NeetoTower"
]

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initialize(cumulative_monitors_data) ⇒ SetupCorrectlyForLandingPages

Returns a new instance of SetupCorrectlyForLandingPages.



18
19
20
21
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/cronitor/setup_correctly_for_landing_pages.rb', line 18

def initialize(cumulative_monitors_data)
  super()
  @all_monitors = cumulative_monitors_data
end

Instance Attribute Details

#all_monitorsObject (readonly)

Returns the value of attribute all_monitors.



16
17
18
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/cronitor/setup_correctly_for_landing_pages.rb', line 16

def all_monitors
  @all_monitors
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/cronitor/setup_correctly_for_landing_pages.rb', line 23

def run
  ui.success "### 3.3.3. Checking whether Cronitor monitors are set up correctly for landing pages"

  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

    if audit_passed == "No"
      repo = app_to_repo(app.to_s)
      issue_url = GithubIssueCreation.new.create_issue(
        repo:, title: "Fix missing or paused Cronitor monitor for #{app} landing page",
        description: " Monitor for Application landing page present:#{monitor_for_app_landing_page_present}
        \n Monitor for Application landing page enabled:#{monitor_for_app_landing_page_enabled} \n  #{comments}"
        )
      audit_passed += " #{issue_url}"
    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