wiot-agent-hd 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bacdc70b161c6ecec3ee0c7c777ac84671b3aeb2
4
- data.tar.gz: 67af723498e61e57d4855b8ea279fc5d4306dfcc
3
+ metadata.gz: 852d516e0880626fd40e21bded8ffa7844f86dd9
4
+ data.tar.gz: 0b6e97877a7d556d7034bf4db32d732fd648f218
5
5
  SHA512:
6
- metadata.gz: e958b99ed66b9135b084eda572e82f4e1d8975d5c76851c2574ff04d4e791a63280d5435c1f163502307d26d8190e7ea1487f07a1dcea6d78030a983799074ab
7
- data.tar.gz: 24df6b7520c40d069e15a733dedaffca81f096f914cc0600eafe36ca8b1d7b534daff40c7ce4f3c1137f7284208a07bc28982802200974bfb911230e00c172c2
6
+ metadata.gz: 21af4266362e4f6bab41e19a9a17a55b14d52707ba1415bf8ac3fd34bef2a38de6dd21f6377daedc6aeec907203a06b6719d8abdfcab63a6ef9a9ac5ee7bc36b
7
+ data.tar.gz: 2827afe0ba682ac53f9f241ede0e10dfc6e900268fd51318e01abab04746a0933a02cd92bb52d7816d071afee0b9cb7dce5ce836aae7c862d81e9c9815cf70aa
data/bin/wiot-agent-hd CHANGED
@@ -1,3 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
3
 
3
- puts "Using our Spydec executable…"
4
+ require 'wiot-agent-hd'
5
+
6
+ # Process command line options and run WiotAgentHd
7
+ opts = WiotAgentHd::CLI.parse_options
8
+ WiotAgentHd::CLI.start(opts)
@@ -0,0 +1,12 @@
1
+ module WiotAgentHd
2
+ module CLI
3
+ def parse_options
4
+ puts "Parse options WiotAgentHd ..."
5
+ end
6
+
7
+ def start(opts)
8
+ puts "Start WiotAgentHd ..."
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,40 @@
1
+ require 'sys/filesystem'
2
+ require 'wiot-sdk'
3
+
4
+ include Sys
5
+
6
+ module WiotAgentHd
7
+ def metric
8
+ p 'Host name: ' + server_name
9
+ Filesystem.mounts.each { |mount|
10
+ next unless valid_mount_type mount
11
+
12
+ stat = Filesystem.stat(mount.mount_point)
13
+
14
+ metric = WiotSdk::Metric.new
15
+ metric.add 'os', RbConfig::CONFIG['host_os']
16
+ metric.add 'server_name', server_name
17
+ metric.add 'partition', mount.name
18
+ metric.add 'mount_point', mount.mount_point
19
+ metric.add 'type', mount.mount_type
20
+ metric.add 'total_space', stat.bytes_total.to_gb.to_s + unit
21
+ metric.add 'free_space', stat.bytes_free.to_gb.to_s + unit
22
+ metric.add 'unit', unit
23
+ metric.add 'use_percet_space', stat.percent_used.round(2).to_s
24
+ }
25
+ end
26
+
27
+ def self.valid_mount_type(mount)
28
+ mount.mount_type == 'ext4'
29
+ end
30
+
31
+ def self.unit
32
+ 'GB'
33
+ end
34
+
35
+ def self.server_name
36
+ ip = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
37
+ Socket.gethostname + '-' + ip
38
+ end
39
+
40
+ end
@@ -1,3 +1,3 @@
1
1
  module WiotAgentHd
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/wiot-agent-hd.rb CHANGED
@@ -1,54 +1,4 @@
1
- require 'wiot-agent-hd/version'
2
-
3
- require 'sys/filesystem'
4
- require 'wiot-sdk'
5
-
6
- include Sys
7
-
8
- module WiotAgentHd
9
- def self.monitor
10
- p 'Host name: ' + server_name
11
- Filesystem.mounts.each { |mount|
12
- next unless valid_mount_type mount
13
-
14
- stat = Filesystem.stat(mount.mount_point)
15
-
16
- WiotSdk.init_json
17
- metric = Metric.new
18
- metric.add 'os', RbConfig::CONFIG['host_os']
19
- metric.add 'server_name', server_name
20
- metric.add 'partition', mount.name
21
- metric.add 'mount_point', mount.mount_point
22
- metric.add 'type', mount.mount_type
23
- metric.add 'total_space', stat.bytes_total.to_gb.to_s + unit
24
- metric.add 'free_space', stat.bytes_free.to_gb.to_s + unit
25
- metric.add 'unit', unit
26
- metric.add 'use_percet_space', stat.percent_used.round(2).to_s
27
1
 
28
- send metric # catch exceptions and logger
29
- }
30
- end
31
-
32
- private
33
-
34
- def self.valid_mount_type(mount)
35
- mount.mount_type == 'ext4'
36
- end
37
-
38
- def self.unit
39
- 'GB'
40
- end
41
-
42
- def self.server_name
43
- ip = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
44
- Socket.gethostname + '-' + ip
45
- end
46
-
47
- def self.project
48
- 'hardware-monitor/hd'
49
- end
2
+ require 'wiot-agent-hd/version'
3
+ require 'wiot-agent-hd/cli'
50
4
 
51
- def self.api
52
- 'hardware-monitor/hd'
53
- end
54
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiot-agent-hd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gorums
@@ -56,8 +56,6 @@ description: This gem is a WatchIoT Agent use to monitor the hard drivers.
56
56
  email:
57
57
  - acksecurity@hotmail.com
58
58
  executables:
59
- - console
60
- - setup
61
59
  - wiot-agent-hd
62
60
  extensions: []
63
61
  extra_rdoc_files: []
@@ -68,10 +66,10 @@ files:
68
66
  - LICENSE
69
67
  - README.md
70
68
  - Rakefile
71
- - bin/console
72
- - bin/setup
73
69
  - bin/wiot-agent-hd
74
70
  - lib/wiot-agent-hd.rb
71
+ - lib/wiot-agent-hd/cli.rb
72
+ - lib/wiot-agent-hd/metrics.rb
75
73
  - lib/wiot-agent-hd/version.rb
76
74
  - wiot-agent-hd.gemspec
77
75
  homepage: http://www.watchiot.com
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "wiot-agent-hd"
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
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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