cloudstack-nagios 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,9 @@ module CloudstackNagios
8
8
  map %w(-v --version) => :version
9
9
 
10
10
  class_option :config,
11
- default: ENV['HOME'] ? File.join(Dir.home, '.cloudstack-nagios.yml') : '',
11
+ default: ENV['HOME'] ?
12
+ File.join(Dir.home, '.cloudstack-nagios.yml') :
13
+ '/var/icinga/.cloudstack-nagios.yml',
12
14
  desc: 'location of your cloudstack-nagios configuration file'
13
15
 
14
16
  class_option :environment,
@@ -7,7 +7,10 @@ class NagiosConfig < CloudstackNagios::Base
7
7
  aliases: '-t'
8
8
  def hosts
9
9
  host_template = load_template(options[:template])
10
- puts host_template.result(routers: cs_routers)
10
+ puts host_template.result(
11
+ routers: cs_routers,
12
+ date: date_string
13
+ )
11
14
  end
12
15
 
13
16
  desc "services", "generate nagios services configuration for virtual routers"
@@ -16,8 +19,21 @@ class NagiosConfig < CloudstackNagios::Base
16
19
  default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_routers_services.cfg.erb'),
17
20
  aliases: '-t'
18
21
  def services
22
+ bin_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'bin'))
23
+ config_file = options[:config]
19
24
  service_template = load_template(options[:template])
20
- puts service_template.result(routers: cs_routers)
25
+ puts service_template.result(
26
+ routers: cs_routers,
27
+ bin_path: bin_path,
28
+ config_file: config_file,
29
+ date: date_string
30
+ )
31
+ end
32
+
33
+ no_commands do
34
+ def date_string
35
+ Time.new.strftime("%d.%m.%Y - %H:%M:%S")
36
+ end
21
37
  end
22
38
 
23
39
  end
@@ -2,8 +2,9 @@ module CloudstackNagios
2
2
  module Helper
3
3
  def load_template(template_path)
4
4
  if File.file?(template_path)
5
- templ = File.read(template_path)
6
- return Erubis::Eruby.new(templ)
5
+ templ = Erubis::Eruby.new(File.read template_path)
6
+ templ.filename = template_path
7
+ return templ
7
8
  else
8
9
  say "Error: template not found #{template_path}"
9
10
  exit 1
@@ -2,12 +2,12 @@
2
2
  #
3
3
  # Host configuration file
4
4
  #
5
- # Created by:
6
- # Date: <%= Time.new.strftime("%d.%m.%Y %H:%M:%S") -%>
5
+ # Created by: cloudstack-nagios
6
+ # Date: <%= date %>
7
7
  # Version: Nagios 3.x config file
8
8
  #
9
9
  # --- DO NOT EDIT THIS FILE BY HAND ---
10
- # cloudstack-cli will overwite all manual settings during the next update
10
+ # cloudstack-nagios will overwite all manual settings during the next update
11
11
  #
12
12
  ###############################################################################
13
13
 
@@ -23,7 +23,7 @@ define host {
23
23
  host_name <%= router['name'] %>
24
24
  display_name <%= router['name'] %> (<%= <%= router['linklocalip'] %>)<%= " - #{router['project']}" if router['project'] %><%= " - #{router['zonename'] %>
25
25
  address <%= router['linklocalip'] %>
26
- use Linux-Host,host-pnp
26
+ use Linux-Host,host-pnp
27
27
  hostgroups Cloudstack-SystemVM
28
28
  check_command check-host-alive
29
29
  register 1
@@ -37,4 +37,4 @@ define host {
37
37
  #
38
38
  # END OF FILE
39
39
  #
40
- ###############################################################################
40
+ ###############################################################################
@@ -1,10 +1,10 @@
1
1
 
2
2
  ###############################################################################
3
3
  #
4
- # Host configuration file
4
+ # Service configuration file
5
5
  #
6
- # Created by:
7
- # Date: <%= Time.new.strftime("%d.%m.%Y %H:%M:%S") -%>
6
+ # Created by: cloudstack-nagios
7
+ # Date: <%= date %>
8
8
  # Version: Nagios 3.x config file
9
9
  #
10
10
  # --- DO NOT EDIT THIS FILE BY HAND ---
@@ -14,25 +14,25 @@
14
14
 
15
15
  define command {
16
16
  command_name cs-nagios_check-memory
17
- command_line /usr/local/bin/cs-nagios check memory -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
17
+ command_line <%= bin_path -%>/cs-nagios check memory -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config <%= config_file %>
18
18
  register 1
19
19
  }
20
20
 
21
21
  define command {
22
22
  command_name cs-nagios_check-cpu
23
- command_line /usr/local/bin/cs-nagios check cpu -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
23
+ command_line <%= bin_path -%>/cs-nagios check cpu -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config <%= config_file %>
24
24
  register 1
25
25
  }
26
26
 
27
27
  define command {
28
28
  command_name cs-nagios_check-network
29
- command_line /usr/local/bin/cs-nagios check network -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
29
+ command_line <%= bin_path -%>/cs-nagios check network -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config <%= config_file %>
30
30
  register 1
31
31
  }
32
32
 
33
33
  define command {
34
34
  command_name cs-nagios_check-rootfsrw
35
- command_line /usr/local/bin/cs-nagios check rootfs_rw -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
35
+ command_line <%= bin_path -%>/cs-nagios check rootfs_rw -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config <%= config_file %>
36
36
  register 1
37
37
  }
38
38
 
@@ -74,8 +74,8 @@ define service {
74
74
 
75
75
  ###############################################################################
76
76
  #
77
- # Host configuration file
77
+ # Service configuration file
78
78
  #
79
79
  # END OF FILE
80
80
  #
81
- ###############################################################################
81
+ ###############################################################################
@@ -1,3 +1,3 @@
1
1
  module CloudstackNagios
2
- VERSION = "0.3.1"
3
- end
2
+ VERSION = "0.3.2"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack-nagios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: