zabbix-monitor 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d62efd8efb5101a7ee8573dc7703ff1808a99052
4
- data.tar.gz: 654a0b6511265333477a3184cb6444f7b9b7d506
3
+ metadata.gz: 12d1f8315102ff4b17ac77c9353c7f36118fa66c
4
+ data.tar.gz: fb155b2c351ef2637a8acc6e8bb2434c1cf0819a
5
5
  SHA512:
6
- metadata.gz: a31b40d780051fc453afd55b0c2e4831e906b4f3739b27b2e4dc7a1e3f900417c9c33f44c0966b44ac5507410372fb0eac57cd401c127ea4fbd0662eef29cf14
7
- data.tar.gz: 9bc5e2267cf60e84b7c4c3d26e4b6f817425be76952a4e6a99466f0603040c541bbe768a85e3b8e2f4068ac7c83af0f3389141b6bbd0d0e438d8759ca2711cb8
6
+ metadata.gz: 5b113b81926b4c51174a10223b849a5b823636c7ccfadb8a5b33bb97d7569a590eccc67c44fa3bf4f617a0465beab5447f6bab1ab0617e409b4a0a7ae506ab24
7
+ data.tar.gz: 766a16529f22c2d8097bd44cc82da091f8f45bb47889fea4974d24b49d995f296db54f1f19f74f1112929b8c71d765e855ce3e82ff12b7e8a7ce46b54c465e62
data/.travis.yml CHANGED
@@ -12,4 +12,9 @@ matrix:
12
12
  allow_failures:
13
13
  - rvm: ruby-head
14
14
  - rvm: jruby-head
15
+
16
+ addons:
17
+ code_climate:
18
+ repo_token: af39e5d1bbdd46699d027fd4eee89ed4cfa9d560eeafccf1293423651d0d6b0c
19
+
15
20
  script: "bundle exec rake spec"
data/CHANGELOG.md CHANGED
@@ -1,11 +1,20 @@
1
1
  # Zabbix Monitor Changelog
2
2
 
3
- ### TBA
4
- - 100% code coverage
5
- - 100% documented
3
+ ### v0.0.3 (TBA)
4
+
5
+ - Added codeclimate coverage
6
+
7
+ ### v0.0.2 (2014-04-24)
8
+
9
+ - Added :file mode
10
+ - Write monitoring data to `tmp/zabbix-stats.yml`
11
+ - Read values with `$ zabbix_reader test`
12
+ - Added specs
13
+ - Added documentation
6
14
  - Added services:
7
- - Travis CI
8
- - Rdoc
15
+ - Travis CI
16
+ - Rdoc
9
17
 
10
18
  ### v0.0.1 (2014-04-17)
19
+
11
20
  - Initial release
data/README.md CHANGED
@@ -2,10 +2,12 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/zabbix-monitor.png)][gemversion]
3
3
  [![Build Status](https://secure.travis-ci.org/sping/zabbix-monitor.png?branch=master)][travis]
4
4
  [![Code Climate](https://codeclimate.com/github/sping/zabbix-monitor.png)][codeclimate]
5
+ [![Coverage](https://codeclimate.com/github/sping/zabbix-monitor/coverage.png)][coverage]
5
6
 
6
7
  [gemversion]: http://badge.fury.io/rb/zabbix-monitor
7
8
  [travis]: http://travis-ci.org/sping/zabbix-monitor
8
9
  [codeclimate]: https://codeclimate.com/github/sping/zabbix-monitor
10
+ [coverage]: https://codeclimate.com/github/sping/zabbix-monitor
9
11
 
10
12
  Zabbix monitoring for Ruby apps. Works with pushing and polling: push data to the agent server with zabbix_sender or collect data with the Zabbix agent.
11
13
 
@@ -38,6 +40,8 @@ To include the rake tasks in your application, add the following line to your Ra
38
40
  Place your Zabbix Monitoring configuration in an initializer:
39
41
 
40
42
  ```ruby
43
+ require 'zabbix'
44
+
41
45
  Zabbix.configure do |config|
42
46
  config.config_file_path = '/etc/zabbix/zabbix_agentd.conf'
43
47
  # optional, defaults to ./log/#{RACK_ENV}.log
@@ -58,7 +62,7 @@ Put the host name as configured in your Zabbix server config in `config.host_nam
58
62
  Set the `config.mode` to one of the following options:
59
63
 
60
64
  - `:push` uses the Zabbix agent to push the data to the Zabbix server
61
- - `:file` writes the data to tmp/zabbix/monitor
65
+ - `:file` writes the data to tmp/zabbix-stats.yml
62
66
  - `:stdout` writes the data to the stdout
63
67
 
64
68
  Put your monitoring rules in `config.rules`. Each rule contains a Ruby command to be executed by the Zabbix Monitor and the key as configured on the Zabbix Server.
@@ -67,6 +71,30 @@ Start running your monitoring jobs with:
67
71
 
68
72
  $ rake zabbix:collect_data
69
73
 
74
+ ### File mode
75
+
76
+ In `:file` mode, monitoring var can be read from the monitoring file using `zabbix_reader` command.
77
+ Create a script that's been executed by the Zabbix daemon:
78
+
79
+ ```bash
80
+ #! /bin/bash
81
+ cd /path/to/app/
82
+ echo $( RAILS_ENV=production bundle exec zabbix_reader $1 )
83
+ ```
84
+
85
+ To speed up the reading of variables, you can also use awk to look for variables. Create the following script instead:
86
+
87
+ ```bash
88
+ #! /bin/bash
89
+ cd /path/to/app/
90
+
91
+ if [ -f tmp/zabbix-stats.yml ]
92
+ then
93
+ echo $( awk -F: -v var=$1 '$0 ~ var {$1=""; print $0; exit}' tmp/zabbix-stats.yml )
94
+ else
95
+ echo Zabbix monitor file not found
96
+ fi
97
+ ```
70
98
 
71
99
  ## Changelog
72
100
 
data/TODO.md CHANGED
@@ -1,5 +1,5 @@
1
- # Todo
1
+ # Zabbix Monitor Todo
2
2
 
3
- - Create :file mode
4
- - Make ActiveRecord independent
5
- - Make schedule frequency configurable
3
+ - Make Rufus Schedulere ActiveRecord independent
4
+ - Make schedule frequency configurable
5
+ - Capistrano integration / recipes
data/lib/tasks/zabbix.rb CHANGED
@@ -1,15 +1,24 @@
1
1
  require 'zabbix'
2
+ require 'dante'
2
3
 
3
4
  namespace :zabbix do
4
5
  desc 'Collect data for Zabbix'
5
- task :collect_once => :environment do
6
+ task :run_once => :environment do
6
7
  Zabbix.logger.info "[Rake] executing #collect_once"
7
8
  Zabbix::Monitor.new.collect_data
8
9
  end
9
10
 
10
11
  desc 'Collect data for Zabbix every minute'
11
- task :collect_data => :environment do
12
- Zabbix.logger.info "[Rake] executing #collect_data, setting up Rufus"
13
- Zabbix::Monitor.new.schedule
12
+ task :start => :environment do
13
+ Zabbix.logger.info "[Rake] executing #start, setting up Rufus"
14
+ Dante::Runner.new('zabbix-monitor').execute(:daemonize => true, :pid_path => 'tmp/zabbix-monitor.pid', :log_path => 'log/zabbix-monitor.log') do
15
+ Zabbix::Monitor.new.schedule
16
+ end
17
+ end
18
+
19
+ desc 'Stop collecting data for Zabbix'
20
+ task :stop => :environment do
21
+ Zabbix.logger.info "[Rake] executing #stop, stopping daemon"
22
+ Dante::Runner.new('zabbix-monitor').execute(:kill => true, :pid_path => 'tmp/zabbix-monitor.pid')
14
23
  end
15
24
  end
@@ -100,7 +100,7 @@ module Zabbix
100
100
  #
101
101
  # @return [void]
102
102
  def to_stdout key, value
103
- puts "#{key}: #{value}"
103
+ $stdout.puts "#{key}: #{value}"
104
104
  end
105
105
  end
106
106
  end
data/spec/monitor_spec.rb CHANGED
@@ -147,7 +147,7 @@ describe Zabbix::Monitor do
147
147
 
148
148
  describe "#to_stdout" do
149
149
  it 'receives the key and value as a puts command' do
150
- expect(monitor).to receive(:puts).with('key: the value')
150
+ expect(STDOUT).to receive(:puts).with('key: the value')
151
151
  monitor.send(:to_stdout, 'key', 'the value')
152
152
  end
153
153
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'pry'
2
2
  require 'simplecov'
3
+ require "codeclimate-test-reporter"
3
4
 
5
+ CodeClimate::TestReporter.start
4
6
  SimpleCov.start do
5
7
  add_filter '/spec/'
6
8
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'zabbix-monitor'
7
- spec.version = '0.0.2'
7
+ spec.version = '0.0.3'
8
8
  spec.authors = ['Robert Jan de Gelder', 'Manuel van Rijn']
9
9
  spec.email = ['r.degelder@sping.nl', 'm.vanrijn@sping.nl']
10
10
  spec.description = 'Zabbix application monitoring'
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_dependency 'rufus-scheduler', '~> 3.0'
21
21
  spec.add_dependency 'yell', '~> 2.0'
22
+ spec.add_dependency 'dante', '~> 0.2.0'
22
23
 
23
24
  spec.add_development_dependency 'rake'
24
25
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -27,4 +28,5 @@ Gem::Specification.new do |spec|
27
28
  spec.add_development_dependency 'pry-nav'
28
29
  spec.add_development_dependency 'yard'
29
30
  spec.add_development_dependency 'simplecov'
31
+ spec.add_development_dependency 'codeclimate-test-reporter'
30
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Jan de Gelder
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-24 00:00:00.000000000 Z
12
+ date: 2014-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rufus-scheduler
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: dante
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 0.2.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.2.0
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rake
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +151,20 @@ dependencies:
137
151
  - - '>='
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: codeclimate-test-reporter
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
140
168
  description: Zabbix application monitoring
141
169
  email:
142
170
  - r.degelder@sping.nl