miab 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/miab.rb +58 -0
- data.tar.gz.sig +0 -0
- metadata +22 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f55a97e81e82e74208daba1ab739870e2d20a69a24f1399ecc26d311fd7758b5
|
4
|
+
data.tar.gz: 9365c7761a511133a1489f48d8f925d969972735fcd5204b439c047f85fa852a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc1f8615bb288650541853d281a6096217f2d5960fcb6de3d509012fec1fef88b70095dc8fb81c7aa2e53db2b4920f901318f2e95e28c6949e1513e9388029b3
|
7
|
+
data.tar.gz: a85242c85b472ca36301579a8439cf6557a0cda61bc8709256624d66d842e218a0a6f661cf6339090e26356aea4704c7cff4cd7420812216285be7d0f155fb76
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/miab.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
require 'net/ssh'
|
9
9
|
require 'c32'
|
10
|
+
require 'resolve/hostname'
|
10
11
|
|
11
12
|
|
12
13
|
class Miab
|
@@ -35,6 +36,8 @@ class Miab
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
# cast out the thing and hope for the best
|
40
|
+
#
|
38
41
|
def cast()
|
39
42
|
|
40
43
|
if @nodes.any? then
|
@@ -64,6 +67,8 @@ class Miab
|
|
64
67
|
@results
|
65
68
|
end
|
66
69
|
|
70
|
+
# return the local date and time
|
71
|
+
#
|
67
72
|
def date()
|
68
73
|
|
69
74
|
instructions = 'date'
|
@@ -72,6 +77,8 @@ class Miab
|
|
72
77
|
|
73
78
|
end
|
74
79
|
|
80
|
+
# query the available disk space etc.
|
81
|
+
#
|
75
82
|
def disk_space()
|
76
83
|
|
77
84
|
instructions = 'df -h'
|
@@ -105,6 +112,8 @@ class Miab
|
|
105
112
|
|
106
113
|
alias df disk_space
|
107
114
|
|
115
|
+
# find out available memory etc
|
116
|
+
#
|
108
117
|
def memory()
|
109
118
|
|
110
119
|
instructions = 'free -h'
|
@@ -117,17 +126,66 @@ class Miab
|
|
117
126
|
@results[@host][:memory] = {total: total, used: used, available: avail}
|
118
127
|
|
119
128
|
end
|
129
|
+
|
130
|
+
# query the ping time
|
131
|
+
#
|
132
|
+
def ping()
|
133
|
+
|
134
|
+
resolver = Resolve::Hostname.new
|
135
|
+
ip = resolver.getaddress(@host)
|
136
|
+
puts ('ip: ' + ip.inspect).debug if @debug
|
137
|
+
valid = pingecho(ip)
|
138
|
+
puts ('valid: ' + valid.inspect).debug if @debug
|
139
|
+
|
140
|
+
@results[@host][:ping] = if valid then
|
141
|
+
a = [valid]
|
142
|
+
4.times {sleep 0.01; a << pingecho(ip)}
|
143
|
+
(a.min * 1000).round(3)
|
144
|
+
else
|
145
|
+
nil
|
146
|
+
end
|
120
147
|
|
148
|
+
end
|
149
|
+
|
150
|
+
# query the path of the current working directory
|
151
|
+
#
|
121
152
|
def pwd()
|
122
153
|
instructions = 'pwd'
|
123
154
|
r = @ssh ? @ssh.exec!(instructions) : system(instructions)
|
124
155
|
@results[@host][:pwd] = r.chomp
|
125
156
|
end
|
126
157
|
|
158
|
+
# query the CPU temperature
|
159
|
+
#
|
127
160
|
def temperature()
|
128
161
|
instructions = 'cat /sys/class/thermal/thermal_zone0/temp'
|
129
162
|
r = @ssh ? @ssh.exec!(instructions) : system(instructions)
|
130
163
|
@results[@host][:temperature] = r.chomp
|
131
164
|
end
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
|
169
|
+
def pingecho(host, timeout=5, service="echo")
|
170
|
+
|
171
|
+
elapsed = nil
|
172
|
+
time = Time.new
|
173
|
+
|
174
|
+
begin
|
175
|
+
|
176
|
+
Timeout.timeout(timeout) do
|
177
|
+
s = TCPSocket.new(host, service)
|
178
|
+
s.close
|
179
|
+
end
|
180
|
+
|
181
|
+
rescue Errno::ECONNREFUSED
|
182
|
+
return Time.now - time
|
183
|
+
rescue Timeout::Error, StandardError
|
184
|
+
return false
|
185
|
+
end
|
186
|
+
|
187
|
+
# it should not reach this far
|
188
|
+
return true
|
189
|
+
end
|
132
190
|
|
133
191
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
9irKsAp/hZt3dTbQOtnSlc9XREZZdegwOgu1FEqBqviNIn9R28OR237HExiWXwmw
|
36
36
|
HDTFIjk8XBqTunABuFUgr4qx
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-09-
|
38
|
+
date: 2019-09-14 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: net-ssh
|
@@ -77,6 +77,26 @@ dependencies:
|
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0.2'
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: resolve-hostname
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.1.0
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0.1'
|
80
100
|
description:
|
81
101
|
email: james@jamesrobertson.eu
|
82
102
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|