class Router

Public Instance Methods

active_ftp() click to toggle source
   # File lib/cloudstack-nagios/commands/router.rb
35 def active_ftp
36   begin
37     host = systemvm_host
38     active_ftp_enabled = false
39     modules = %w(nf_conntrack_ftp, nf_nat_ftp)
40     on host do |h|
41       lsmod = capture(:lsmod)
42       active_ftp_enabled = lsmod.include?('nf_conntrack_ftp') &&
43         lsmod.include?('nf_nat_ftp')
44       unless active_ftp_enabled
45         # load the modules in the kernel
46         execute(:modprobe, 'nf_conntrack_ftp')
47         execute(:modprobe, 'nf_nat_ftp')
48         # load the modules at next server boot
49         execute(:echo, '"nf_conntrack_ftp" >> /etc/modules')
50         execute(:echo, '"nf_nat_ftp" >> /etc/modules')
51         active_ftp_enabled = true
52       end
53     end
54   rescue SSHKit::Command::Failed
55     active_ftp_enabled = false
56   rescue => e
57     exit_with_failure(e)
58   end
59   status = active_ftp_enabled ? 0 : 2
60   puts "ACTIVE_FTP #{active_ftp_enabled ? 'OK - active_ftp enabled' : 'CRITICAL - active_ftp NOT enabled'}"
61   exit status
62 end
conntrack_connections() click to toggle source
   # File lib/cloudstack-nagios/commands/router.rb
11 def conntrack_connections
12   begin
13     host = systemvm_host
14     default_max = 1000000
15     netfilter_path = "/proc/sys/net/netfilter/"
16     current, max = 0
17     on host do |h|
18       max     = capture("cat #{netfilter_path}nf_conntrack_max").to_i
19       current = capture("cat #{netfilter_path}nf_conntrack_count").to_i
20     end
21     if max < default_max
22       on host do |h|
23         execute :echo, "#{default_max} > #{netfilter_path}nf_conntrack_max"
24       end
25     end
26     data = check_data(max, current, options[:warning], options[:critical])
27     puts "CONNTRACK_CONNECTIONS #{RETURN_CODES[data[0]]} - usage = #{data[1]}% (#{current.round(0)}/#{max.round(0)}) | usage=#{data[1]}% current=#{current.round(0)} max=#{max.round(0)}"
28     exit data[0]
29   rescue => e
30     exit_with_failure(e)
31   end
32 end
rootfs_rw() click to toggle source
  # File lib/cloudstack-nagios/commands/router.rb
6 def rootfs_rw
7   invoke :fs_rw
8 end