Skip to content

Commit

Permalink
add support for system_vm checks
Browse files Browse the repository at this point in the history
  • Loading branch information
niwo committed Sep 19, 2014
1 parent 2fe35e2 commit 6102864
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
cloudstack-nagios (0.15.0)
cloudstack_client (~> 0.5, >= 0.5.0)
cloudstack_client (~> 0.7, >= 0.7.1)
erubis (~> 2.7.0)
highline (~> 1.6.20)
sshkit (~> 1.3.0)
Expand All @@ -11,7 +11,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
cloudstack_client (0.6.4)
cloudstack_client (0.7.1)
erubis (2.7.0)
highline (1.6.21)
json (1.8.1)
Expand All @@ -28,7 +28,7 @@ GEM
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.19.1)
tins (1.3.2)
tins (1.3.3)

PLATFORMS
ruby
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ hostgroups
zone_hosts
router_hosts
router_services
system_vm_hosts
system_vm_services
capacities
async_jobs
storage_pools
Expand All @@ -87,10 +89,9 @@ For all vm checks access to the cloudstack management network is required in ord

#### Types

There are 3 different types of system vm's:
cloudstack-nagios differentiates between 2 different types of system vm's:
* routers: `cs-nagios check router`
* secondary storage vms: `cs-nagios check sec_stor_vm`
* console proxies: `cs-nagios check console_proxy`
* secondary storage vms and console proxies: `cs-nagios check system_vm`

#### Checks

Expand All @@ -108,10 +109,11 @@ Checks for routers
* conntrack_connections, check the number of conntrack connections and set proper limits if needed
* active_ftp - make sure conntrack_ftp and nf_nat_ftp modules are loaded and enable it if needed

Example:
Examples:

```sh
$ cs-nagios check router network --host 10.100.9.161
$ cs-nagios check system_vm network --host 10.100.9.161
$ cs-nagios check router active_ftp --host 10.100.9.177
```

#### Enabling snmpd checks for system vms
Expand Down
6 changes: 3 additions & 3 deletions cloudstack-nagios.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Gem::Specification.new do |gem|

gem.add_development_dependency('rdoc')
gem.add_development_dependency('rake', '~> 10.3.1')
gem.add_dependency('cloudstack_client', '~> 0.5', '>= 0.5.0')

gem.add_dependency('cloudstack_client', '~> 0.7', '>= 0.7.1')
gem.add_dependency('thor', '~> 0.19.1')
gem.add_dependency('erubis', '~> 2.7.0')
gem.add_dependency('sshkit', '~> 1.3.0')
gem.add_dependency('highline', '~> 1.6.20')
end
end
13 changes: 4 additions & 9 deletions lib/cloudstack-nagios/commands/check.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "cloudstack-nagios/commands/system_vm"
require "cloudstack-nagios/commands/router"
require "cloudstack-nagios/commands/capacity"

class Check < CloudstackNagios::Base
Expand Down Expand Up @@ -33,19 +34,13 @@ class Check < CloudstackNagios::Base
desc "router SUBCOMMAND ...ARGS", "router checks"
subcommand :router, Router

desc "sec_stor_vm SUBCOMMAND ...ARGS", "secondary storage vm checks"
subcommand :sec_stor_vm, SecStorVm

desc "console_proxy SUBCOMMAND ...ARGS", "console proxy checks"
subcommand :console_proxy, ConsoleProxy
desc "system_vm SUBCOMMAND ...ARGS", "system vm checks"
subcommand :system_vm, SystemVm

desc "capacity SUBCOMMAND ...ARGS", "capacity checks"
subcommand :capacity, Capacity

desc "storage_pool SUBCOMMAND ...ARGS", "storage_pool checks"
subcommand :capacity, Capacity

desc "capacity", "check capacity of storage_pool"
desc "storage_pool", "check capacity of storage_pool"
option :pool_name, required: true
option :zone
option :over_provisioning, type: :numeric, default: 1.0,
Expand Down
3 changes: 0 additions & 3 deletions lib/cloudstack-nagios/commands/console_proxy.rb

This file was deleted.

6 changes: 4 additions & 2 deletions lib/cloudstack-nagios/commands/nagios_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def generate(*configs)
end

routers = configs.include?("router_hosts") ? cs_routers : nil
system_vms = configs.include?("system_vm_hosts") ? cs_system_vms : nil
pools = configs.include?("storage_pools") ? storage_pools : nil
zones = client.list_zones
config_name = configs.size == 1 ?
Expand All @@ -51,6 +52,7 @@ def generate(*configs)
template = load_template(tmpl_file)
output += template.result(
routers: routers,
system_vms: system_vms,
bin_path: bin_path,
if_speed: options[:if_speed],
config_file: options[:config],
Expand Down Expand Up @@ -78,7 +80,7 @@ def list
no_commands do

def get_configs(configs = [])
all_configs = %w(hostgroups zone_hosts router_hosts router_services capacities async_jobs storage_pools)
all_configs = %w(hostgroups zone_hosts router_hosts router_services system_vm_hosts system_vm_services capacities async_jobs storage_pools)
if configs.size == 0
return all_configs
else
Expand All @@ -102,4 +104,4 @@ def bin_path
end
end

end
end
4 changes: 3 additions & 1 deletion lib/cloudstack-nagios/commands/router.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require "cloudstack-nagios/commands/system_vm"

class Router < SystemVm

desc "rootfs_rw", "check if the rootfs is read/writeable on host"
def rootfs_rw
fs_rw(mount_point: '/')
invoke :fs_rw
end

desc "conntrack_connections", "check the number of conntrack connections"
Expand Down
3 changes: 0 additions & 3 deletions lib/cloudstack-nagios/commands/sec_stor_vm.rb

This file was deleted.

4 changes: 0 additions & 4 deletions lib/cloudstack-nagios/commands/system_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,3 @@ def systemvm_host
end

end

require "cloudstack-nagios/commands/router"
require "cloudstack-nagios/commands/sec_stor_vm"
require "cloudstack-nagios/commands/console_proxy"
4 changes: 4 additions & 0 deletions lib/cloudstack-nagios/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def cs_routers
routers += client.list_routers(projectid: -1, status: 'Running')
end

def cs_system_vms
vms = client.list_system_vms
end

def storage_pools
storage_pools = client.list_storage_pools.select do |pool|
pool['state'].downcase == 'up'
Expand Down
15 changes: 15 additions & 0 deletions lib/cloudstack-nagios/templates/cloudstack_system_vm_hosts.cfg.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% system_vms.each do |vm| -%>
<% if vm['privateip'] -%>
define host {
host_name <%= vm['name'] %>
display_name <%= vm['name'] %> (<%= vm['privateip'] %>) - <%= vm['zonename'] %>
address <%= vm['privateip'] %>
use Linux-Host,host-pnp
hostgroups CloudstackSystemVm
check_command check-host-alive
register 1
}

<% end -%>
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

define command {
command_name cs-nagios_check_systemvm-memory
command_line <%= bin_path -%>cs-nagios check system_vm memory -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
register 1
}

define command {
command_name cs-nagios_check_systemvm-cpu
command_line <%= bin_path -%>cs-nagios check system_vm cpu -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
register 1
}

define command {
command_name cs-nagios_check_systemvm-network
command_line <%= bin_path -%>cs-nagios check system_vm network -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --if-speed <%= if_speed %> --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
register 1
}

define command {
command_name cs-nagios_check_systemvm-fsrw
command_line <%= bin_path -%>cs-nagios check system_vm fs_rw -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
register 1
}

define command {
command_name cs-nagios_check_systemvm-diskusage
command_line <%= bin_path -%>cs-nagios check system_vm disk_usage -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -P $ARG3$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
register 1
}

define service {
hostgroup_name CloudstackSystemVm
service_description Cloudstack Virtual System VM Memory
display_name Cloudstack Virtual System VM Memory
use Generic-Service,service-pnp
check_command cs-nagios_check_systemvm-memory!80!90
register 1
}

define service {
hostgroup_name CloudstackSystemVm
service_description Cloudstack Virtual System VM CPU
display_name Cloudstack Virtual System VM CPU
use Generic-Service,service-pnp
check_command cs-nagios_check_systemvm-cpu!80!90
register 1
}

define service {
hostgroup_name CloudstackSystemVm
service_description Cloudstack Virtual System VM Network
display_name Cloudstack Virtual System VM Network
use Generic-Service,service-pnp
check_command cs-nagios_check_systemvm-network!80!90
register 1
}

define service {
hostgroup_name CloudstackSystemVm
service_description Cloudstack Virtual System VM RootFS rw
display_name Cloudstack Virtual System VM RootFS rw
use Generic-Service,service-pnp
check_command cs-nagios_check_systemvm-rootfsrw!80!90
register 1
}

define service {
hostgroup_name CloudstackSystemVm
service_description Cloudstack Virtual System VM DiskUsageRoot
display_name Cloudstack Virtual System VM DiskUsage Root
use Generic-Service,service-pnp
check_command cs-nagios_check_systemvm-diskusage!80!90!/
register 1
}

define service {
hostgroup_name CloudstackSystemVm
service_description Cloudstack Virtual System VMDiskUsageVar
display_name Cloudstack Virtual System VM DiskUsage Var
use Generic-Service,service-pnp
check_command cs-nagios_check_systemvm-diskusage!80!90!/var
register 1
}

0 comments on commit 6102864

Please sign in to comment.