class Fluent::Plugin::ShodanAlert
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_shodan_alert.rb, line 23 def configure(conf) super @client = Shodanz::Client.new(key: @api_key) begin log.info "Shodan client properly registered", client_info: @client.info rescue RuntimeError => exception raise Fluent::ConfigError.new "Invalid Shodan API key" end end
multi_workers_ready?()
click to toggle source
# File lib/fluent/plugin/in_shodan_alert.rb, line 19 def multi_workers_ready? false end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_shodan_alert.rb, line 34 def start super timer_execute("shodan_#{self.class.name}#{@alert_id.nil? ? "_#{@alert_id}" : '' }".to_sym, @interval, repeat: true, &method(:run)) end
Private Instance Methods
process_alert(alert)
click to toggle source
# File lib/fluent/plugin/in_shodan_alert.rb, line 52 def process_alert(alert) router.emit( (@tag.nil? ? alert['shodan']['alert']['name'] : @tag), Fluent::EventTime.parse(alert['timestamp']), alert ) end
run()
click to toggle source
# File lib/fluent/plugin/in_shodan_alert.rb, line 42 def run log.debug "Start polling Shodan alerts", alert_id: @alert_id if @alert_id.nil? @client.streaming_api.alerts { |alert| process_alert(alert) } else @client.streaming_api.alert(@alert_id) { |alert| process_alert(alert) } end end