Class: Router

Inherits:
SystemVm show all
Defined in:
lib/cloudstack-nagios/commands/router.rb

Constant Summary

Constants included from CloudstackNagios::Helper

CloudstackNagios::Helper::RETURN_CODES

Instance Attribute Summary

Attributes inherited from CloudstackNagios::Base

#config

Instance Method Summary collapse

Methods inherited from SystemVm

#cpu, #disk_usage, #fs_rw, #memory, #network

Methods inherited from CloudstackNagios::Base

exit_on_failure?

Methods included from CloudstackNagios::Helper

#check_data, #cs_routers, #cs_system_vms, #exit_with_failure, #load_template, #storage_pools

Instance Method Details

#active_ftpObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cloudstack-nagios/commands/router.rb', line 35

def active_ftp
  begin
    host = systemvm_host
    active_ftp_enabled = false
    modules = %w(nf_conntrack_ftp, nf_nat_ftp)
    on host do |h|
      lsmod = capture(:lsmod)
      active_ftp_enabled = lsmod.include?('nf_conntrack_ftp') &&
        lsmod.include?('nf_nat_ftp')
      unless active_ftp_enabled
        # load the modules in the kernel
        execute(:modprobe, 'nf_conntrack_ftp')
        execute(:modprobe, 'nf_nat_ftp')
        # load the modules at next server boot
        execute(:echo, '"nf_conntrack_ftp" >> /etc/modules')
        execute(:echo, '"nf_nat_ftp" >> /etc/modules')
        active_ftp_enabled = true
      end
    end
  rescue SSHKit::Command::Failed
    active_ftp_enabled = false
  rescue => e
    exit_with_failure(e)
  end
  status = active_ftp_enabled ? 0 : 2
  puts "ACTIVE_FTP #{active_ftp_enabled ? 'OK - active_ftp enabled' : 'CRITICAL - active_ftp NOT enabled'}"
  exit status
end

#conntrack_connectionsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cloudstack-nagios/commands/router.rb', line 11

def conntrack_connections
  begin
    host = systemvm_host
    default_max = 1000000
    netfilter_path = "/proc/sys/net/netfilter/"
    current, max = 0
    on host do |h|
      max     = capture("cat #{netfilter_path}nf_conntrack_max").to_i
      current = capture("cat #{netfilter_path}nf_conntrack_count").to_i
    end
    if max < default_max
      on host do |h|
        execute :echo, "#{default_max} > #{netfilter_path}nf_conntrack_max"
      end
    end
    data = check_data(max, current, options[:warning], options[:critical])
    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)}"
    exit data[0]
  rescue => e
    exit_with_failure(e)
  end
end

#rootfs_rwObject



6
7
8
# File 'lib/cloudstack-nagios/commands/router.rb', line 6

def rootfs_rw
  invoke :fs_rw
end