activerecord-zabbix 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,7 +8,7 @@ Although some attempt `may be` (later) made to facilitate this integrating seaml
8
8
  Quick Start
9
9
  -----------
10
10
 
11
- `gem install activerecord-zabbix` # once published... (to rubygems-org)
11
+ `gem install activerecord-zabbix`
12
12
 
13
13
  <pre>
14
14
 
@@ -35,5 +35,13 @@ end
35
35
 
36
36
  </pre>
37
37
 
38
+ Schema (partially implemented)
39
+ ------------------------------
38
40
 
39
- [Schema Diagram](https://docs.google.com/drawings/d/12sIp0gAaoAlLOVluyiSLSFYhTiuw8txoUL67BDUVxvc/edit)
41
+ ![Schema Diagram](https://github.com/cluetechnologies/activerecord-zabbix/raw/develop/schema.png)
42
+
43
+ [Schema Diagram - Googledoc](https://docs.google.com/drawings/d/12sIp0gAaoAlLOVluyiSLSFYhTiuw8txoUL67BDUVxvc/edit)
44
+
45
+
46
+
47
+ [cloudseed](http://cloudseed.co.za) infrastructure monitored by [zabbix](http://www.zabbix.co.za)
@@ -19,31 +19,31 @@ Gem::Specification.new do |spec|
19
19
  spec.files = [
20
20
 
21
21
  #
22
- # du -a lib/ spec/ README* *.gemspec | awk '{print($2)}' | while read file; do echo "'$file',"; done
22
+ # du -a lib spec README* *.gemspec | awk '{print($2)}' | while read file; do echo "'$file',"; done
23
23
  #
24
24
 
25
- 'lib//activerecord-zabbix.rb',
26
- 'lib//boot.rb',
27
- 'lib//zabbix/connect.rb',
28
- 'lib//zabbix/function.rb',
29
- 'lib//zabbix/host.rb',
30
- 'lib//zabbix/item.rb',
31
- 'lib//zabbix/trigger.rb',
32
- 'lib//zabbix/version.rb',
33
- 'lib//zabbix/zabbix.rb',
34
- 'lib//zabbix',
35
- 'lib/',
36
- 'spec//README',
37
- 'spec//spec_helper.rb',
38
- 'spec//zabbix/connect_spec.rb',
39
- 'spec//zabbix/function_spec.rb',
40
- 'spec//zabbix/host_spec.rb',
41
- 'spec//zabbix/item_spec.rb',
42
- 'spec//zabbix/trigger_spec.rb',
43
- 'spec//zabbix',
44
- 'spec/',
25
+ 'lib/activerecord-zabbix.rb',
26
+ 'lib/boot.rb',
27
+ 'lib/zabbix/connect.rb',
28
+ 'lib/zabbix/function.rb',
29
+ 'lib/zabbix/host.rb',
30
+ 'lib/zabbix/item.rb',
31
+ 'lib/zabbix/trigger.rb',
32
+ 'lib/zabbix/version.rb',
33
+ 'lib/zabbix/zabbix.rb',
34
+ 'lib/zabbix',
35
+ 'lib',
36
+ 'spec/README',
37
+ 'spec/spec_helper.rb',
38
+ 'spec/zabbix/connect_spec.rb',
39
+ 'spec/zabbix/function_spec.rb',
40
+ 'spec/zabbix/host_spec.rb',
41
+ 'spec/zabbix/item_spec.rb',
42
+ 'spec/zabbix/trigger_spec.rb',
43
+ 'spec/zabbix',
44
+ 'spec',
45
45
  'README.md',
46
- 'activerecord-zabbix.gemspec' #,
46
+ 'activerecord-zabbix.gemspec'
47
47
 
48
48
  ]
49
49
 
@@ -17,6 +17,12 @@ module Zabbix
17
17
 
18
18
  @logger = logger
19
19
 
20
+ @logger.info(
21
+
22
+ "CONNECT: Zabbix::connect({:host => '#{config[:host]}',:database => '#{config[:database]}'})"
23
+
24
+ ) unless @logger.nil?
25
+
20
26
  if config.nil?
21
27
 
22
28
  config = load_standard_rails_things_for_db__and_feel_free_to_rename_this_function
@@ -24,17 +30,34 @@ module Zabbix
24
30
  end
25
31
 
26
32
  begin
27
-
28
- ActiveRecord::Base.establish_connection(
29
33
 
30
- :adapter => config[:adapter],
31
- :host => config[:host],
32
- :database => config[:database],
33
- :username => config[:username],
34
- :password => config[:password]
34
+ if config[:port].nil?
35
+
36
+ ActiveRecord::Base.establish_connection(
37
+
38
+ :adapter => config[:adapter],
39
+ :host => config[:host],
40
+ :database => config[:database],
41
+ :username => config[:username],
42
+ :password => config[:password]
43
+
44
+ )
45
+
46
+ else
47
+
48
+ ActiveRecord::Base.establish_connection(
49
+
50
+ :adapter => config[:adapter],
51
+ :host => config[:host],
52
+ :database => config[:database],
53
+ :username => config[:username],
54
+ :password => config[:password],
55
+ :port => config[:port]
56
+
57
+ )
58
+
59
+ end
35
60
 
36
- )
37
-
38
61
  rescue Exception => e
39
62
 
40
63
  #
@@ -2,8 +2,8 @@ module Zabbix
2
2
 
3
3
  class Function < ::ActiveRecord::Base
4
4
 
5
- set_table_name "functions"
6
- set_primary_key "functionid"
5
+ self.table_name = 'functions'
6
+ self.primary_key = 'functionid'
7
7
 
8
8
  belongs_to :item, :class_name => "Item", :foreign_key => "itemid"
9
9
  belongs_to :trigger, :class_name => "Trigger", :foreign_key => "triggerid"
data/lib/zabbix/host.rb CHANGED
@@ -2,8 +2,8 @@ module Zabbix
2
2
 
3
3
  class Host < ::ActiveRecord::Base
4
4
 
5
- set_table_name "hosts"
6
- set_primary_key "hostid"
5
+ self.table_name = 'hosts'
6
+ self.primary_key = 'hostid'
7
7
 
8
8
  default_scope where(:status => [0,1] )
9
9
  scope :monitored, where(:status => 0)
@@ -18,9 +18,8 @@ module Zabbix
18
18
  #has_many :groups, :through => :host_group
19
19
  #has_many :host_template, :class_name => "HostTemplate", :foreign_key => "hostid"
20
20
  #has_many :templates, :through => :host_template
21
-
22
-
23
- #belongs_to :proxy, :class_name => "Proxy", :foreign_key => "proxy_hostid"
21
+
22
+ belongs_to :proxy, :class_name => "Proxy", :foreign_key => "proxy_hostid"
24
23
 
25
24
  #def item_last_value(key, value, time_shift_tolerance = 480)
26
25
  # items.where("key_ = ? and lastvalue = ? and lastclock >=", key, value.to_s, Time.now.to_i - time_shift_tolerance)
data/lib/zabbix/item.rb CHANGED
@@ -2,9 +2,9 @@ module Zabbix
2
2
 
3
3
  class Item < ::ActiveRecord::Base
4
4
 
5
- set_table_name "items"
6
- set_primary_key "itemid"
7
- set_inheritance_column "dodge_rails_assumptions_about_type_column" # this is not an single inheritance table
5
+ self.table_name = 'items'
6
+ self.primary_key = 'itemid'
7
+ self.inheritance_column = 'dodge_rails_pollymorph_assumptions_about_type_column'
8
8
 
9
9
  belongs_to :host, :class_name => "Host", :foreign_key => "hostid"
10
10
  has_many :functions, :class_name => "Function", :foreign_key => "itemid"
@@ -2,8 +2,10 @@ module Zabbix
2
2
 
3
3
  class Trigger < ::ActiveRecord::Base
4
4
 
5
- set_table_name "triggers"
6
- set_primary_key "triggerid"
5
+ self.table_name = 'triggers'
6
+ self.primary_key = 'triggerid'
7
+ self.inheritance_column = 'dodge_rails_pollymorph_assumptions_about_type_column'
8
+
7
9
 
8
10
  has_many :functions, :class_name => "Function", :foreign_key => "triggerid"
9
11
  #
@@ -2,7 +2,7 @@ GEM_NAME = 'activerecord-zabbix'
2
2
 
3
3
  module Zabbix
4
4
 
5
- Version = VERSION = '0.1.0'
5
+ Version = VERSION = '0.1.1'
6
6
 
7
7
  end
8
8
 
data/lib/zabbix/zabbix.rb CHANGED
@@ -3,6 +3,8 @@ require 'zabbix/version'
3
3
  require 'zabbix/connect'
4
4
 
5
5
  require 'zabbix/host'
6
+ require 'zabbix/proxy'
6
7
  require 'zabbix/item'
7
8
  require 'zabbix/function'
8
9
  require 'zabbix/trigger'
10
+ require 'zabbix/event'
data/spec/spec_helper.rb CHANGED
@@ -1 +1,34 @@
1
1
  require 'activerecord-zabbix'
2
+
3
+ class Logger
4
+
5
+ def initialize( parameter = :noisey )
6
+ @parameter = parameter
7
+ end
8
+
9
+ def on
10
+ @parameter = :noisey
11
+ end
12
+
13
+ def off
14
+ @parameter = :silent
15
+ end
16
+
17
+ def method_missing( symbol, *args, &block )
18
+ puts "LOG.#{symbol}: #{args}" unless @parameter == :silent
19
+ end
20
+
21
+ #
22
+ # rspec won't match unless for these unles they'r defined
23
+ #
24
+ def info( msg )
25
+ puts "LOG.info: [#{msg}]" unless @parameter == :silent
26
+ end
27
+
28
+ def warn( msg )
29
+ puts "LOG.warn: [#{msg}]" unless @parameter == :silent
30
+ end
31
+
32
+ end
33
+
34
+ LOG = Logger.new :silent
@@ -4,6 +4,7 @@ describe Zabbix do
4
4
 
5
5
  before :each do
6
6
 
7
+ LOG.on
7
8
 
8
9
  CONFIG = {
9
10
 
@@ -25,7 +26,7 @@ describe Zabbix do
25
26
 
26
27
  )
27
28
 
28
- Zabbix.connect( nil, nil )
29
+ Zabbix.connect( CONFIG, LOG )
29
30
 
30
31
  end
31
32
 
metadata CHANGED
@@ -1,98 +1,81 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: activerecord-zabbix
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
11
6
  platform: ruby
12
- authors:
13
- - ""
14
- - ""
15
- - ""
7
+ authors:
8
+ - ''
9
+ - ''
10
+ - ''
16
11
  - Richard
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2012-06-27 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
15
+ date: 2012-07-09 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
24
18
  name: activerecord
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
27
20
  none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 3
32
- segments:
33
- - 0
34
- version: "0"
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
35
25
  type: :runtime
36
- version_requirements: *id001
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
37
33
  description: This is not a rails app.
38
34
  email: ops@clue.co.za
39
35
  executables: []
40
-
41
36
  extensions: []
42
-
43
37
  extra_rdoc_files: []
44
-
45
- files:
46
- - lib//activerecord-zabbix.rb
47
- - lib//boot.rb
48
- - lib//zabbix/connect.rb
49
- - lib//zabbix/function.rb
50
- - lib//zabbix/host.rb
51
- - lib//zabbix/item.rb
52
- - lib//zabbix/trigger.rb
53
- - lib//zabbix/version.rb
54
- - lib//zabbix/zabbix.rb
55
- - spec//README
56
- - spec//spec_helper.rb
57
- - spec//zabbix/connect_spec.rb
58
- - spec//zabbix/function_spec.rb
59
- - spec//zabbix/host_spec.rb
60
- - spec//zabbix/item_spec.rb
61
- - spec//zabbix/trigger_spec.rb
38
+ files:
39
+ - lib/activerecord-zabbix.rb
40
+ - lib/boot.rb
41
+ - lib/zabbix/connect.rb
42
+ - lib/zabbix/function.rb
43
+ - lib/zabbix/host.rb
44
+ - lib/zabbix/item.rb
45
+ - lib/zabbix/trigger.rb
46
+ - lib/zabbix/version.rb
47
+ - lib/zabbix/zabbix.rb
48
+ - spec/README
49
+ - spec/spec_helper.rb
50
+ - spec/zabbix/connect_spec.rb
51
+ - spec/zabbix/function_spec.rb
52
+ - spec/zabbix/host_spec.rb
53
+ - spec/zabbix/item_spec.rb
54
+ - spec/zabbix/trigger_spec.rb
62
55
  - README.md
63
56
  - activerecord-zabbix.gemspec
64
57
  homepage: https://github.com/cluetechnologies/activerecord-zabbix
65
58
  licenses: []
66
-
67
59
  post_install_message:
68
60
  rdoc_options: []
69
-
70
- require_paths:
61
+ require_paths:
71
62
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
63
+ required_ruby_version: !ruby/object:Gem::Requirement
73
64
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
70
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
90
75
  requirements: []
91
-
92
76
  rubyforge_project:
93
- rubygems_version: 1.8.5
77
+ rubygems_version: 1.8.24
94
78
  signing_key:
95
79
  specification_version: 3
96
80
  summary: ActiveRecord access into Zabbix
97
81
  test_files: []
98
-