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 +4 -4
- data/bin/wiot-agent-hd +6 -1
- data/lib/wiot-agent-hd/cli.rb +12 -0
- data/lib/wiot-agent-hd/metrics.rb +40 -0
- data/lib/wiot-agent-hd/version.rb +1 -1
- data/lib/wiot-agent-hd.rb +2 -52
- metadata +3 -5
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 852d516e0880626fd40e21bded8ffa7844f86dd9
|
|
4
|
+
data.tar.gz: 0b6e97877a7d556d7034bf4db32d732fd648f218
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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,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
|
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
|
-
|
|
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.
|
|
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
|