influxdb-cli 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +22 -9
- data/bin/influxdb-cli +7 -4
- data/influxdb-cli.gemspec +3 -2
- data/lib/influxdb_client/client.rb +8 -1
- data/lib/influxdb_client/version.rb +1 -1
- data/spec/influxdb_client/client_spec.rb +19 -5
- data/spec/spec_helper.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c973d4bc6e8ab8bd0671edabb94494404fff84ee
|
4
|
+
data.tar.gz: cd28988ee12a4ca03682f1a9ecef55865c13deb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef30a9b139ad42ea041d8622ea9287dfab0e0b1064ff3a68b4096c1415576c82dcffe9bb4cfb9a84663b4cc8a9312aa4cb3d13a242693dee99ac694c2a3f74e
|
7
|
+
data.tar.gz: e167e953a7ae1ad706c8d803ca8284781b4f3b2c58b29ce415d8be17e8b9f04845d236ca5e498c13b4be62f6835dec0c153143c50422bd09ca23de9eb5192a89
|
data/.travis.yml
CHANGED
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 using given parameters. In order to connect to InfluxDB, it uses [influxdb-ruby](https://github.com/influxdb/influxdb-ruby), so you can access any
|
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 available 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
|
[![Build Status](https://secure.travis-ci.org/phstc/influxdb-cli.png)](http://travis-ci.org/phstc/influxdb-cli)
|
7
7
|
|
@@ -17,7 +17,7 @@ Usage:
|
|
17
17
|
influxdb-cli
|
18
18
|
|
19
19
|
Options:
|
20
|
-
|
20
|
+
[--host=HOST] # Hostname
|
21
21
|
# Default: localhost
|
22
22
|
[--port=PORT] # Port
|
23
23
|
# Default: 8086
|
@@ -27,6 +27,7 @@ Options:
|
|
27
27
|
# Default: root
|
28
28
|
-d, [--database=DATABASE] # Database
|
29
29
|
# Default: db
|
30
|
+
[--pretty=PRETTY] # Human readable times
|
30
31
|
```
|
31
32
|
|
32
33
|
### Usage
|
@@ -42,7 +43,7 @@ Connecting to {"host"=>"localhost", "port"=>8086, "username"=>"root", "password"
|
|
42
43
|
or
|
43
44
|
|
44
45
|
```shell
|
45
|
-
$ influxdb-cli -u user -p password -d database
|
46
|
+
$ influxdb-cli -u user -p password -d database --host sandbox.influxdb.org --port 9061
|
46
47
|
Connecting to {"host"=>"sandbox.influxdb.org", "port"=>"9061", "username"=>"username", "password"=>"password", "database"=>"database"}
|
47
48
|
✔ ready
|
48
49
|
```
|
@@ -73,18 +74,18 @@ Connecting to {"host"=>"sandbox.influxdb.org", "port"=>"9061", "username"=>"user
|
|
73
74
|
#### Write a point
|
74
75
|
|
75
76
|
```ruby
|
76
|
-
2.0.0 (main)> db.write_point('
|
77
|
+
2.0.0 (main)> db.write_point('tests', { message: 'Hello Pablo' })
|
77
78
|
|
78
|
-
2.0.0 (main)> SELECT * FROM
|
79
|
+
2.0.0 (main)> SELECT * FROM tests
|
79
80
|
|
80
81
|
+---------------+-----------------+-------------+
|
81
|
-
|
|
82
|
+
| tests |
|
82
83
|
+---------------+-----------------+-------------+
|
83
84
|
| time | sequence_number | message |
|
84
85
|
+---------------+-----------------+-------------+
|
85
86
|
| 1387287723816 | 1 | Hello Pablo |
|
86
87
|
+---------------+-----------------+-------------+
|
87
|
-
1 result found for
|
88
|
+
1 result found for tests
|
88
89
|
|
89
90
|
Query duration: 0.0s
|
90
91
|
```
|
@@ -92,7 +93,19 @@ Query duration: 0.0s
|
|
92
93
|
#### Return the last point from every time series in the database
|
93
94
|
|
94
95
|
```ruby
|
95
|
-
2.0.0 (main)> SELECT * FROM /.*/
|
96
|
+
2.0.0 (main)> SELECT * FROM /.*/ LIMIT 1
|
97
|
+
```
|
98
|
+
|
99
|
+
or to get only the name from every time series in the database.
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
2.0.0 (main)> db.query('SELECT * FROM /.*/ LIMIT 1').keys
|
103
|
+
=> [
|
104
|
+
[0] "tests",
|
105
|
+
[1] "response_times",
|
106
|
+
[2] "deploys",
|
107
|
+
[3] "..."
|
108
|
+
]
|
96
109
|
```
|
97
110
|
|
98
111
|
|
@@ -145,7 +158,7 @@ instance variables: @database @host @http @password @port @queue @username
|
|
145
158
|
|
146
159
|
### Pry commands
|
147
160
|
|
148
|
-
As influxdb-cli is empowered with Pry, all Pry awesome commands are
|
161
|
+
As influxdb-cli is empowered with Pry, all Pry awesome commands are available in the console.
|
149
162
|
|
150
163
|
#### show-source
|
151
164
|
|
data/bin/influxdb-cli
CHANGED
@@ -15,15 +15,18 @@ class InfluxDBClientTasks < Thor
|
|
15
15
|
@@db = nil
|
16
16
|
|
17
17
|
desc 'db', 'Connect to InfluxDB (default command)'
|
18
|
-
method_option :host, :default => 'localhost', :
|
18
|
+
method_option :host, :default => 'localhost', :desc => 'Hostname'
|
19
19
|
method_option :port, :default => 8086, :desc => 'Port'
|
20
|
-
method_option :username, :default => 'root', :
|
21
|
-
method_option :password, :default => 'root', :
|
22
|
-
method_option :database, :default => 'db', :
|
20
|
+
method_option :username, :default => 'root', :desc => 'Username', :aliases => '-u'
|
21
|
+
method_option :password, :default => 'root', :desc => 'Password', :aliases => '-p'
|
22
|
+
method_option :database, :default => 'db', :desc => 'Database', :aliases => '-d'
|
23
|
+
method_option :pretty, :default => nil, :desc => 'Human readable times (UTC)'
|
24
|
+
|
23
25
|
def db
|
24
26
|
puts "Connecting to #{options.inspect}"
|
25
27
|
@@db ||= InfluxDB::Client.new options[:database],
|
26
28
|
{ username: options[:username], password: options[:password], host: options[:host], port: options[:port] }
|
29
|
+
InfluxDBClient::Client.pretty = options[:pretty]
|
27
30
|
puts '✔ ready'
|
28
31
|
end
|
29
32
|
|
data/influxdb-cli.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency 'terminal-table'
|
24
24
|
|
25
25
|
gem.add_development_dependency 'rspec'
|
26
|
-
gem.add_development_dependency
|
27
|
-
gem.add_development_dependency
|
26
|
+
gem.add_development_dependency 'bundler'
|
27
|
+
gem.add_development_dependency 'rake'
|
28
|
+
gem.add_development_dependency 'pry-byebug'
|
28
29
|
end
|
29
30
|
|
@@ -31,6 +31,10 @@ module InfluxDBClient
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def self.pretty=(pretty)
|
35
|
+
@pretty = !!pretty
|
36
|
+
end
|
37
|
+
|
34
38
|
private
|
35
39
|
|
36
40
|
def self.pluralize(count, singular, plural = nil)
|
@@ -43,7 +47,10 @@ module InfluxDBClient
|
|
43
47
|
|
44
48
|
def self.generate_table(series, result_series)
|
45
49
|
headings = result_series.first.keys
|
46
|
-
rows = result_series.
|
50
|
+
rows = result_series.map do |row|
|
51
|
+
row['time'] = Time.at(row['time'] / 1000).utc.to_s if @pretty
|
52
|
+
row.values
|
53
|
+
end
|
47
54
|
|
48
55
|
Terminal::Table.new title: series, headings: headings, rows: rows
|
49
56
|
end
|
@@ -37,20 +37,34 @@ module InfluxDBClient
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '.print_tabularize' do
|
40
|
-
let(:result) { { series1: [{ value1
|
41
|
-
series2: [{ value3
|
42
|
-
{ value3
|
40
|
+
let(:result) { { series1: [{ 'time' => 1387287723816, 'value1' => 1, 'value2' => 2 }],
|
41
|
+
series2: [{ 'time' => 1394552447955, 'value3' => 3, 'value4' => 4, 'value5' => nil, 'value6' => nil },
|
42
|
+
{ 'time' => 1394664358980, 'value3' => nil, 'value4' => 4, 'value5' => 5, 'value6' => 6 }] } }
|
43
43
|
|
44
44
|
it 'generates tables' do
|
45
45
|
expect(Terminal::Table).to receive(:new).
|
46
|
-
with(title: :series1, headings: [
|
46
|
+
with(title: :series1, headings: %w[time value1 value2], rows: [[1387287723816, 1, 2]])
|
47
47
|
|
48
48
|
expect(Terminal::Table).to receive(:new).
|
49
|
-
with(title: :series2, headings: [
|
49
|
+
with(title: :series2, headings: %w[time value3 value4 value5 value6], rows: [[1394552447955, 3, 4, nil, nil], [1394664358980, nil, 4, 5, 6]])
|
50
50
|
|
51
51
|
described_class.print_tabularize(result)
|
52
52
|
end
|
53
53
|
|
54
|
+
context 'when pretty' do
|
55
|
+
before(:all) { described_class.pretty = true }
|
56
|
+
after(:all) { described_class.pretty = false }
|
57
|
+
it 'generates tables' do
|
58
|
+
expect(Terminal::Table).to receive(:new).
|
59
|
+
with(title: :series1, headings: %w[time value1 value2], rows: [['2013-12-17 13:42:03 UTC', 1, 2]])
|
60
|
+
|
61
|
+
expect(Terminal::Table).to receive(:new).
|
62
|
+
with(title: :series2, headings: %w[time value3 value4 value5 value6], rows: [['2014-03-11 15:40:47 UTC', 3, 4, nil, nil], ['2014-03-12 22:45:58 UTC', nil, 4, 5, 6]])
|
63
|
+
|
64
|
+
described_class.print_tabularize(result)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
54
68
|
it 'prints results' do
|
55
69
|
output = double 'Output'
|
56
70
|
table = double 'Table'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Cantero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: influxdb
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: Ruby CLI for InfluxDB
|
126
140
|
email:
|
127
141
|
- pablo@pablocantero.com
|