influxdb-cli 0.0.5 → 0.0.6
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/README.md +2 -2
- data/bin/influxdb-cli +2 -0
- data/lib/influxdb_client/client.rb +19 -4
- data/lib/influxdb_client/version.rb +1 -1
- data/spec/influxdb_client/client_spec.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c5faca92da1f2362bcd999e8007d92d3b91e82
|
4
|
+
data.tar.gz: 7eee7f66b1b30f644d1a9b29c51142bdb909e989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7839991a77721868443e099662cf3aec93a14a883158594c09584fbb7dbff239b2a7c86649558a1eeb359654950d522a61898b55cbec6a15d3b26086be0fd4b3
|
7
|
+
data.tar.gz: 0b9b02d642bbe109775e395499ac63e01030ca426d3b28aa813f6770e344236babcbc1377008bbb98c0687239041378d09e22c7c3b9571eb893efe5de9e3b93b
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
InfluxDB-CLI
|
2
2
|
============
|
3
3
|
|
4
|
-
Ruby CLI for InfluxDB is a simple Ruby console (empowered with [Pry](https://github.com/pry/pry)) connected to an InfluxDB server
|
4
|
+
Ruby CLI for InfluxDB is a simple Ruby console (empowered with [Pry](https://github.com/pry/pry)) connected to an InfluxDB server using given parameters. In order to connect to InfluxDB, it uses [influxdb-ruby](https://github.com/influxdb/influxdb-ruby), so you can access any avaiable method from influxdb-ruby in the console through the `db` variable i.e.: `db.write_point(name, data)`, `db.query('SELECT value FROM response_times')` etc.
|
5
5
|
|
6
6
|
[](http://travis-ci.org/phstc/influxdb-cli)
|
7
7
|
|
@@ -43,7 +43,7 @@ or
|
|
43
43
|
|
44
44
|
```shell
|
45
45
|
influxdb-cli -u user -p password -d database -h sandbox.influxdb.org --port 9061
|
46
|
-
Connecting to {"host"=>"sandbox.influxdb.org", "port"=>"9061", "username"=>"
|
46
|
+
Connecting to {"host"=>"sandbox.influxdb.org", "port"=>"9061", "username"=>"username", "password"=>"password", "database"=>"database"}
|
47
47
|
✔ ready
|
48
48
|
```
|
49
49
|
|
data/bin/influxdb-cli
CHANGED
@@ -48,7 +48,9 @@ def db; InfluxDBClientTasks.db; end
|
|
48
48
|
# i.e. query('select value from response_times')
|
49
49
|
#
|
50
50
|
# @see InfluxDB::Client#query
|
51
|
+
# @see InfluxDBClient::Client.print_tabularize
|
51
52
|
#
|
53
|
+
# @param query [String] the query
|
52
54
|
# @return [Hash] the number of points per time series i.e. { 'response_times.count' => 10 }
|
53
55
|
def query(query)
|
54
56
|
result = db.query(query)
|
@@ -4,13 +4,19 @@ module InfluxDBClient
|
|
4
4
|
class Client
|
5
5
|
QUERY_LANGUAGE_MATCHER = /\A\s*((delete\s+from|select\s+.+\s+from)\s.+)\z/i
|
6
6
|
|
7
|
+
# Prints a tabularized output from a query result.
|
8
|
+
#
|
9
|
+
# @param result [Hash] the {InfluDB::Client#query result}
|
10
|
+
# @param output [STDOUT] the output to `puts` the results
|
11
|
+
# @return [Hash] the number of points per time series i.e. { 'response_times.count' => 10 }
|
7
12
|
def self.print_tabularize(result, output=$stdout)
|
8
13
|
number_of_points = {}
|
9
14
|
result.keys.each do |series|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
if result[series].any?
|
16
|
+
output.puts generate_table(series, result)
|
17
|
+
else
|
18
|
+
output.puts "No results found for #{series}"
|
19
|
+
end
|
14
20
|
# empty line between time series output
|
15
21
|
output.puts
|
16
22
|
# count total per time series
|
@@ -18,6 +24,15 @@ module InfluxDBClient
|
|
18
24
|
end
|
19
25
|
number_of_points
|
20
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def self.generate_table(series, result)
|
31
|
+
headings = result[series].first.keys
|
32
|
+
rows = result[series].collect(&:values)
|
33
|
+
|
34
|
+
Terminal::Table.new title: series, headings: headings, rows: rows
|
35
|
+
end
|
21
36
|
end
|
22
37
|
end
|
23
38
|
|
@@ -56,6 +56,30 @@ module InfluxDBClient
|
|
56
56
|
|
57
57
|
described_class.print_tabularize(result, output)
|
58
58
|
end
|
59
|
+
|
60
|
+
context 'when empty results' do
|
61
|
+
let(:result) { { series1: [{ value1: 1, value2: 2 }],
|
62
|
+
series2: [] } }
|
63
|
+
|
64
|
+
it 'puts no results found' do
|
65
|
+
output = double 'Output'
|
66
|
+
table = double 'Table'
|
67
|
+
Terminal::Table.stub(new: table)
|
68
|
+
|
69
|
+
# should print series1
|
70
|
+
expect(output).to receive(:puts).once.with(table)
|
71
|
+
# no results for series 2
|
72
|
+
expect(output).to receive(:puts).once.with('No results found for series2')
|
73
|
+
# line break for series
|
74
|
+
expect(output).to receive(:puts).twice.with(no_args)
|
75
|
+
|
76
|
+
described_class.print_tabularize(result, output)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns series count' do
|
80
|
+
expect(described_class.print_tabularize(result)).to eq({ 'series1.count' => 1, 'series2.count' => 0 })
|
81
|
+
end
|
82
|
+
end
|
59
83
|
end
|
60
84
|
end
|
61
85
|
end
|