monitoringreporter 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.gitlab-ci.yml +73 -0
- data/.rspec +2 -0
- data/CHANGELOG +7 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/LICENSE +202 -0
- data/README.md +60 -0
- data/Rakefile +22 -0
- data/bin/monitoringreporter +24 -0
- data/lib/monitoringreporter.rb +32 -0
- data/lib/monitoringreporter/cli.rb +114 -0
- data/lib/monitoringreporter/mysql.rb +40 -0
- data/lib/monitoringreporter/mysqllibrenms.rb +192 -0
- data/lib/monitoringreporter/reporter.rb +26 -0
- data/lib/monitoringreporter/version.rb +20 -0
- data/monitoringreporter.gemspec +63 -0
- data/spec/files/localdb.sql +1469 -0
- data/spec/files/output.json +1 -0
- data/spec/files/output.text +20 -0
- data/spec/monitoringreporter/cli_spec.rb +39 -0
- data/spec/monitoringreporter/reporter_spec.rb +67 -0
- data/spec/monitoringreporter_spec.rb +23 -0
- data/spec/spec_helper.rb +47 -0
- metadata +181 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"hosts":{"up":8,"down":2,"total":10},"polling":{"average":14,"longest":{"test2.yueyehua.net":"286","test0.yueyehua.net":"152","test6.yueyehua.net":"127","test7.yueyehua.net":"99","test8.yueyehua.net":"87"},"missing":[["test5.yueyehua.net",24],["test7.yueyehua.net",22],["test0.yueyehua.net",19],["test8.yueyehua.net",18],["test1.yueyehua.net",17],["test3.yueyehua.net",16],["test9.yueyehua.net",15],["test2.yueyehua.net",13],["test6.yueyehua.net",13],["test4.yueyehua.net",11]]}}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Number of hosts UP: 8/10 (80.0%)
|
2
|
+
Number of hosts DOWN: 2/10 (20.0%)
|
3
|
+
Average polling duration: 14
|
4
|
+
Longest pollers:
|
5
|
+
- test2.yueyehua.net (286 seconds)
|
6
|
+
- test0.yueyehua.net (152 seconds)
|
7
|
+
- test6.yueyehua.net (127 seconds)
|
8
|
+
- test7.yueyehua.net (99 seconds)
|
9
|
+
- test8.yueyehua.net (87 seconds)
|
10
|
+
Missing poll count per host (estimated):
|
11
|
+
- test5.yueyehua.net: 24
|
12
|
+
- test7.yueyehua.net: 22
|
13
|
+
- test0.yueyehua.net: 19
|
14
|
+
- test8.yueyehua.net: 18
|
15
|
+
- test1.yueyehua.net: 17
|
16
|
+
- test3.yueyehua.net: 16
|
17
|
+
- test9.yueyehua.net: 15
|
18
|
+
- test2.yueyehua.net: 13
|
19
|
+
- test6.yueyehua.net: 13
|
20
|
+
- test4.yueyehua.net: 11
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2017 Richard Delaplace, Vente-Privee.Com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe MonitoringReporter::CLI do
|
20
|
+
context 'version' do
|
21
|
+
it 'prints the version.' do
|
22
|
+
out = "MonitoringReporter version #{MonitoringReporter::VERSION}\n"
|
23
|
+
expect { start(self) }.to output(out).to_stdout
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'report -s' do
|
28
|
+
it 'Runs the simulation mode and do nothing.' do
|
29
|
+
expect { start(self) }.to output('').to_stdout
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'notexistingcmd' do
|
34
|
+
it 'is an unknown command and does nothing.' do
|
35
|
+
out = "Could not find command \"notexistingcmd\".\n"
|
36
|
+
expect { start(self) }.to output(out).to_stderr
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2017 Richard Delaplace, Vente-Privee.Com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
def read_file(file)
|
20
|
+
dir = File.dirname(__FILE__)
|
21
|
+
File.read(File.join(dir, '..', 'files', file))
|
22
|
+
end
|
23
|
+
|
24
|
+
describe MonitoringReporter::CLI do # rubocop:disable Metrics/BlockLength
|
25
|
+
outfile = '/tmp/out'
|
26
|
+
opth = '-h mysql'
|
27
|
+
optu = '-u testuser'
|
28
|
+
optp = '-p testpasswd'
|
29
|
+
optd = '-d test'
|
30
|
+
optt = '-t 1501106400'
|
31
|
+
opto = "-o #{outfile}"
|
32
|
+
optf = '-f json'
|
33
|
+
|
34
|
+
context "report #{opth} #{optu} #{optp} #{optd} #{optt}" do
|
35
|
+
it 'reports from the fake database.' do
|
36
|
+
expect { start(self) }.to output(read_file('output.text')).to_stdout
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "report #{opth} #{optu} #{optp} #{optd} #{optt} #{opto}" do
|
41
|
+
it 'reports from the fake database and writes to file.' do
|
42
|
+
expect { start(self) }.to output('').to_stdout
|
43
|
+
expect { print File.read(outfile) }
|
44
|
+
.to output(read_file('output.text')).to_stdout
|
45
|
+
File.delete(outfile)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "report #{opth} #{optu} #{optp} #{optd} #{optt} #{optf}" do
|
50
|
+
it 'reports from the fake database with json format.' do
|
51
|
+
expect { start(self) }.to output(read_file('output.json')).to_stdout
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "report -h error #{optu} #{optp} #{optd} #{optt}" do
|
56
|
+
it 'does not report from an unreachable database.' do
|
57
|
+
expect { start(self) }.to raise_error(SystemExit)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'notexistingcmd' do
|
62
|
+
it 'is an unknown command and does nothing.' do
|
63
|
+
out = "Could not find command \"notexistingcmd\".\n"
|
64
|
+
expect { start(self) }.to output(out).to_stderr
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2017 Richard Delaplace, Vente-Privee.Com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe MonitoringReporter do
|
20
|
+
it 'has a version number' do
|
21
|
+
expect(MonitoringReporter::VERSION).not_to be nil
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2017 Richard Delaplace, Vente-Privee.Com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
require 'simplecov'
|
17
|
+
SimpleCov.start
|
18
|
+
|
19
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
20
|
+
require 'monitoringreporter'
|
21
|
+
require 'webmock/rspec'
|
22
|
+
|
23
|
+
# Force expect syntax over should
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.expect_with :rspec do |c|
|
26
|
+
c.syntax = :expect
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
dir = File.dirname(__FILE__)
|
31
|
+
# Load helpers
|
32
|
+
Dir[File.join(dir, 'helpers', '*.rb')].each { |file| require file }
|
33
|
+
|
34
|
+
def now
|
35
|
+
Time.new.strftime('%Y-%m-%dT%H:%M:%S%z').insert(-3, ':')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Load stubs
|
39
|
+
files = File.join(dir, 'monitoringreporter', 'stubs', '*.rb')
|
40
|
+
Dir[files].each { |file| require file }
|
41
|
+
|
42
|
+
# To test the cli
|
43
|
+
def start(caller_object, subcommand = nil)
|
44
|
+
cmd = caller_object.class.description.split(' ')
|
45
|
+
args = [subcommand, *cmd].compact
|
46
|
+
MonitoringReporter.start(args)
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: monitoringreporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Delaplace
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.41'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.41'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.23'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.23'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.12'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.12'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ruby-mysql
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.9'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.9'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: thor
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.19'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.19'
|
125
|
+
description: MonitoringReporter is a simple tool to request monitoring tool data base
|
126
|
+
and extract some information useful to be reported
|
127
|
+
email: rdelaplace@vente-privee.com
|
128
|
+
executables:
|
129
|
+
- monitoringreporter
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".gitlab-ci.yml"
|
135
|
+
- ".rspec"
|
136
|
+
- CHANGELOG
|
137
|
+
- CONTRIBUTING.md
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/monitoringreporter
|
143
|
+
- lib/monitoringreporter.rb
|
144
|
+
- lib/monitoringreporter/cli.rb
|
145
|
+
- lib/monitoringreporter/mysql.rb
|
146
|
+
- lib/monitoringreporter/mysqllibrenms.rb
|
147
|
+
- lib/monitoringreporter/reporter.rb
|
148
|
+
- lib/monitoringreporter/version.rb
|
149
|
+
- monitoringreporter.gemspec
|
150
|
+
- spec/files/localdb.sql
|
151
|
+
- spec/files/output.json
|
152
|
+
- spec/files/output.text
|
153
|
+
- spec/monitoringreporter/cli_spec.rb
|
154
|
+
- spec/monitoringreporter/reporter_spec.rb
|
155
|
+
- spec/monitoringreporter_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
homepage: https://github.com/vp-noc/monitoringreporter
|
158
|
+
licenses:
|
159
|
+
- Apache-2.0
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: 1.9.3
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.6.12
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: Tool to request monitoring tool database.
|
181
|
+
test_files: []
|