rb2db 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4bdbba3db09f8dd30c905552a437241148f872ed
4
+ data.tar.gz: ecda043ea0a6d4f2902e7f596f2db81c6b3cd3d4
5
+ SHA512:
6
+ metadata.gz: 5aaa3dd182f9d8da366c6c65b0936d68cb361c29e586bd3deb7d641796b2e59cbdc83408e4cbbdbc9bb46ddc1038bba1975e0d68be211f85b9f412950defb376
7
+ data.tar.gz: a41eb518507d9de1a7be2cd10983bf6432aafd0cedb8ea0fdee5c9eebb23fc5ac7a07121b746db6c66396601548eb35107a357ae6d0d71547453de344649c13b
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ *~
2
+ .DS_Store
3
+ .idea*
4
+ /.bundle/
5
+ /.yardoc
6
+ /Gemfile.lock
7
+ /_yardoc/
8
+ /coverage/
9
+ /doc/
10
+ /pkg/
11
+ /spec/reports/
12
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rb2db.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Jacob Duffy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # rb2db
2
+ Write CPU and Memory info to InfluxDB with Ruby
3
+
4
+ ## Install
5
+ $ gem install rb2db
6
+
7
+ ## Config
8
+
9
+ ### InfluxDB Server
10
+ ENV['INFLUX_HOST']
11
+
12
+ ### Local Hostname
13
+ ENV['INFLUX_DB']
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rb2db"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/rb2db ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'duffy'
3
+ require 'influxdb'
4
+
5
+ # CONFIG #
6
+ # InfluxDB Server:
7
+ influx_host = ENV['INFLUX_HOST'] || "localhost"
8
+
9
+ # Local Hostname
10
+ influx_db = ENV['INFLUX_DB'] || `hostname`.strip
11
+
12
+ # Create Database for this host if it doesn't already exist
13
+ InfluxDB::Client.new(host: influx_host).create_database(influx_db)
14
+
15
+ # Connect to InfluxDB with database for this hostname selected
16
+ influxdb = InfluxDB::Client.new(influx_db, host: influx_host)
17
+
18
+ puts "Logging Started: #{influx_db} => #{influx_host}"
19
+ Process.daemon
20
+
21
+ while sleep 1
22
+ influxdb.write_points([
23
+ { series: 'cpu_percent', values: { value: Duffy::System.cpu_percent } },
24
+ { series: 'mem_total', values: { value: Duffy::System.mem_total } },
25
+ { series: 'mem_used', values: { value: Duffy::System.mem_used } },
26
+ { series: 'mem_available', values: { value: Duffy::System.mem_available } }
27
+ ])
28
+ end
29
+
@@ -0,0 +1,9 @@
1
+ module Rb2db
2
+ VERSION = "0.1.1"
3
+
4
+
5
+ # CHANGELOG
6
+ # 0.1.1 Updating gemspec to publish to RubyGems
7
+ # 0.1.0 Initial Release
8
+
9
+ end
data/lib/rb2db.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "rb2db/version"
2
+
3
+ module Rb2db
4
+ # Your code goes here...
5
+ end
data/rb2db.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rb2db/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rb2db"
8
+ spec.version = Rb2db::VERSION
9
+ spec.authors = ["Jacob Duffy"]
10
+ spec.email = ["duffy.jp@gmail.com"]
11
+
12
+ spec.summary = "Write CPU and Memory info to InfluxDB with Ruby"
13
+ spec.homepage = "https://github.com/duffyjp/rb2db"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+
23
+ spec.add_dependency 'duffy', '>= 0.3.0'
24
+ spec.add_dependency 'influxdb'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.14"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rb2db
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jacob Duffy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: duffy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: influxdb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - duffy.jp@gmail.com
72
+ executables:
73
+ - rb2db
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - exe/rb2db
85
+ - lib/rb2db.rb
86
+ - lib/rb2db/version.rb
87
+ - rb2db.gemspec
88
+ homepage: https://github.com/duffyjp/rb2db
89
+ licenses: []
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.6.12
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Write CPU and Memory info to InfluxDB with Ruby
111
+ test_files: []