Sha256: bc0467f7bb013792c3a4814f4e857a36f2e0715d54e2bcf9509c6ef27a9390f9

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

class ScheduleByIntervalJob
  include Sidekiq::Worker

  sidekiq_options queue: 'my_nagios_monitoring'

  def perform(options, one_by_one = false)

    # Run each Check separately (new ssh connection for each check even common host)
    if one_by_one
      MyNagios::Check.enabled.not_snoozed.where(interval: options['interval']).each do |check|
        MonitoringJob.perform_async(check)
      end

      return
    end

    # Optimized variant, group checks, run all necessary checks with one ssh connection
    MyNagios::Check.enabled.not_snoozed.where(interval: options['interval']).group_by{|check| { host: check.host, user: check.user, pem_key: check.pem_key } }.each do |config, checks|
      MonitoringJob.perform_async(checks.map(&:id), config)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_nagios-0.0.22 app/jobs/schedule_by_interval_job.rb