checkson 0.9 → 0.91
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.
- checksums.yaml +4 -4
- data/lib/checkson/ui.rb +24 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df976ff2fcf7b747b191dd42d58ed08b21378592f6b5706fa32c26db32ff99b9
|
4
|
+
data.tar.gz: ddbc6847732551eeb853db80394e1a8bf7931f7b487c4e5c0046589b4a4f2217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64681b78f3914c5e0d74cd8d23076b912290002b7b070ff03b15033764952aa8741e11d6697b57c9fe904346028a1addb5e89e9901b96572bc520b4b9a6bee0d
|
7
|
+
data.tar.gz: 9b79ac4cb702bb119cc99e9e88bb229df229a242960b6bb8c29c04c7a97c9e64edb205295683a074f82ee350257f33b105d138e5a09f96d2de6296256d46503f
|
data/lib/checkson/ui.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
-
require 'logger'
|
5
4
|
require 'uri'
|
5
|
+
require 'json'
|
6
6
|
|
7
7
|
module Checkson
|
8
8
|
# Simple user interface for checkson
|
9
9
|
class UI
|
10
10
|
def initialize
|
11
|
+
@jsonout = []
|
12
|
+
|
11
13
|
set_default_options
|
12
14
|
parse_options
|
13
15
|
start_checks
|
@@ -29,16 +31,22 @@ module Checkson
|
|
29
31
|
c = check.klass.new(check.params)
|
30
32
|
c.check
|
31
33
|
@num_ok += 1 if c.status.eql? :ok
|
32
|
-
|
34
|
+
output_plain c, check if @opts[:verbose]
|
35
|
+
if @opts[:jsonexport]
|
36
|
+
@opts[:verbose] = false
|
37
|
+
jsonadd(c, check)
|
38
|
+
end
|
33
39
|
end
|
34
40
|
@num_failed = (@num_checks - @num_ok)
|
35
|
-
puts "-> #{@num_checks} checks performed: #{@num_ok} ok, #{@num_failed} failed"
|
41
|
+
puts "-> #{@num_checks} checks performed: #{@num_ok} ok, #{@num_failed} failed" unless @opts[:jsonexport]
|
42
|
+
output_json if @opts[:jsonexport]
|
36
43
|
end
|
37
44
|
|
38
45
|
def set_default_options
|
39
46
|
@opts = {
|
40
47
|
datasource: :file,
|
41
48
|
verbose: false,
|
49
|
+
jsonexport: false,
|
42
50
|
config_file: '/etc/checkson.rb',
|
43
51
|
endpoint: 'https://checkson.fsrv.services:8080'
|
44
52
|
}
|
@@ -50,6 +58,9 @@ module Checkson
|
|
50
58
|
opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
|
51
59
|
@opts[:verbose] = v
|
52
60
|
end
|
61
|
+
opts.on('-j', '--[no-]jsonexport', 'do output as json') do |j|
|
62
|
+
@opts[:jsonexport] = j
|
63
|
+
end
|
53
64
|
opts.on('-d', '--datasource [TYPE]', %i[file api], 'Set datasource type', '(file, api)') do |d|
|
54
65
|
@opts[:datasource] = d
|
55
66
|
end
|
@@ -68,11 +79,13 @@ module Checkson
|
|
68
79
|
end
|
69
80
|
end
|
70
81
|
end.parse!
|
71
|
-
logger = Logger.new(STDOUT)
|
72
|
-
logger.info "Using datasource `#{@opts[:datasource]}`"
|
73
82
|
end
|
74
83
|
|
75
|
-
def
|
84
|
+
def output_json
|
85
|
+
puts @jsonout.to_json
|
86
|
+
end
|
87
|
+
|
88
|
+
def output_plain(sym, check)
|
76
89
|
status_column = winsize[1] / 3 * 2
|
77
90
|
print check.description
|
78
91
|
case sym.status
|
@@ -85,6 +98,11 @@ module Checkson
|
|
85
98
|
end
|
86
99
|
end
|
87
100
|
|
101
|
+
def jsonadd(sym, check)
|
102
|
+
data = { desription: check.description, status: sym.status }
|
103
|
+
@jsonout.append(data)
|
104
|
+
end
|
105
|
+
|
88
106
|
def winsize
|
89
107
|
require 'io/console'
|
90
108
|
IO.console.winsize
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.91'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple framework for checking node facts
|
14
14
|
email: florian@fsrv.xyz
|