Sha256: e5e769820122775ea2beec581a139325ed5cbe88d68a89cf99623caee11c795c
Contents?: true
Size: 1.02 KB
Versions: 20
Compression:
Stored size: 1.02 KB
Contents
class Riemann::Babbler::Plugin::Iptables < Riemann::Babbler::Plugin def init plugin.set_default(:service, 'iptables') plugin.set_default(:rules_file, '/etc/network/iptables') plugin.set_default(:interval, 60) end def run_plugin File.exists? plugin.rules_file end def delete_counters(str) str.gsub(/\[\d+\:\d+\]/, '').strip end def collect current_rules = shell('iptables-save').split("\n").map do |x| x[0] == "#" ? nil : delete_counters(x) # delete counters and comments end.compact.join("\n") saved_rules = File.read(plugin.rules_file).split("\n").map do |x| x[0] == "#" ? nil : delete_counters(x) # delete counters and comments end.compact.join("\n") status = current_rules == saved_rules ? 'ok' : 'critical' { :service => "#{plugin.service} #{plugin.rules_file}", :state => status, # status 'ok' will be minimized :description => "#{plugin.service} rules different between file: #{plugin.rules_file} and iptables-save" } end end
Version data entries
20 entries across 20 versions & 1 rubygems