Class: Fail2Ban
- Defined in:
- lib/panda_motd/components/fail_2_ban.rb
Instance Attribute Summary
Attributes inherited from Component
#config, #errors, #name, #results
Instance Method Summary collapse
-
#initialize(motd) ⇒ Fail2Ban
constructor
A new instance of Fail2Ban.
- #process ⇒ Object
- #to_s ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(motd) ⇒ Fail2Ban
Returns a new instance of Fail2Ban.
2 3 4 |
# File 'lib/panda_motd/components/fail_2_ban.rb', line 2 def initialize(motd) super(motd, 'fail_2_ban') end |
Instance Method Details
#process ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/panda_motd/components/fail_2_ban.rb', line 6 def process @results = { jails: {} } @config['jails'].each do |jail| status = jail_status(jail) @results[:jails][jail] = { total: status[:total], current: status[:current] } end end |
#to_s ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/panda_motd/components/fail_2_ban.rb', line 20 def to_s result = "Fail2Ban:\n" @results[:jails].each do |name, stats| result += " #{name}:\n" result += " Total bans: #{stats[:total]}\n" result += " Current bans: #{stats[:current]}\n" end result.gsub(/\s$/, '') end |