Class: Neetob::CLI::MonthlyAudit::InstancesAndAddons::Cronitor::SetupCorrectlyForHelpCenter

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

Constant Summary collapse

APPS_TO_IGNORE =
[
  "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) ⇒ SetupCorrectlyForHelpCenter

Returns a new instance of SetupCorrectlyForHelpCenter.



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

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.



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

def all_monitors
  @all_monitors
end

Instance Method Details

#runObject



22
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
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/cronitor/setup_correctly_for_help_center.rb', line 22

def run
  ui.success "### 3.3.2. Checking whether Cronitor monitors are set up correctly for Help Centers"

  apps_data = [["App", "Monitor for Application help center present",
"Monitor for Application help center 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_help_center_present = "No"
    monitor_for_app_help_center_enabled = "No"
    ui.info("Checking Application help center monitor for #{app}", print_to_audit_log: false)
    application_help_center_monitor = all_monitors.select { |monitor|
 monitor[:name].downcase == "#{app} Help Center".downcase }.first

    if application_help_center_monitor.nil?
      comments = "Monitor not present"
    else
      monitor_for_app_help_center_present = "Yes"
      if application_help_center_monitor[:paused]
        comments = "Monitor is paused"
      else
        monitor_for_app_help_center_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} help center",
        description: " Monitor for Application help center present:#{monitor_for_app_help_center_present}
        \n Monitor for Application help center enabled:#{monitor_for_app_help_center_enabled} \n  #{comments}"
        )
      audit_passed += " #{issue_url}"
    end

    apps_data << [app, monitor_for_app_help_center_present, monitor_for_app_help_center_enabled, comments,
audit_passed]
  end

  ui.print_table(apps_data)
end