blackstack-nodes 1.2.11 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack-nodes.rb +61 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc21a5ad0c4b17836d8f63f5adf7b376ae8e274135b6371e40ee263cc7181aa7
|
4
|
+
data.tar.gz: 4bfe763d33a8bded730860508dc66ce97177d8718f13a80a998f90f09929e7e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc436cf1f7378481b0064cd8fb1b464e4c3a833b682cbcc1bfe72cd6dce85b839f7b09318325ec4bc1da26e64e947873755a05d161b8cca9083f2cc68f21e690
|
7
|
+
data.tar.gz: 4886dbf65cdbed4e5a7eb31eccf4f216b83163f5dd18c25ad6f069e672b4c4af8f3d0953d3a9ff174ad10a28b3dff5938e5544c501d2421b5e7a16dab74c9cfd
|
data/lib/blackstack-nodes.rb
CHANGED
@@ -129,13 +129,12 @@ module BlackStack
|
|
129
129
|
else
|
130
130
|
s = command
|
131
131
|
end
|
132
|
-
#puts
|
133
|
-
#puts "s: #{s}"
|
134
132
|
s
|
135
133
|
end
|
136
134
|
|
137
135
|
def exec(command, sudo=true)
|
138
|
-
|
136
|
+
code = self.code(command, sudo)
|
137
|
+
s = self.ssh.exec!(code)
|
139
138
|
s
|
140
139
|
end # def exec
|
141
140
|
|
@@ -175,6 +174,65 @@ module BlackStack
|
|
175
174
|
raise 'reboot failed' if !success
|
176
175
|
end # def reboot
|
177
176
|
|
177
|
+
# Return a hash descriptor of the status of the node
|
178
|
+
def usage()
|
179
|
+
ret = {}
|
180
|
+
|
181
|
+
self.connect
|
182
|
+
|
183
|
+
ret[:b_total_memory] = self.ssh.exec!('cat /proc/meminfo | grep MemTotal').delete('^0-9').to_i*1024
|
184
|
+
ret[:kb_total_memory] = ret[:b_total_memory] / 1024
|
185
|
+
ret[:mb_total_memory] = ret[:kb_total_memory] / 1024
|
186
|
+
ret[:gb_total_memory] = ret[:mb_total_memory] / 1024
|
187
|
+
|
188
|
+
ret[:kb_free_memory] = self.ssh.exec!('cat /proc/meminfo | grep MemFree').delete('^0-9').to_i
|
189
|
+
ret[:mb_free_memory] = ret[:kb_free_memory] / 1024
|
190
|
+
ret[:gb_free_memory] = ret[:mb_free_memory] / 1024
|
191
|
+
|
192
|
+
# run bash commend to get the total disk space
|
193
|
+
ret[:mb_total_disk] = self.ssh.exec!('df -m / | tail -1 | awk \'{print $2}\'').to_i
|
194
|
+
ret[:gb_total_disk] = ret[:mb_total_disk] / 1024
|
195
|
+
# run bash command to get the free disk space
|
196
|
+
ret[:mb_free_disk] = self.ssh.exec!('df -m / | tail -1 | awk \'{print $4}\'').to_i
|
197
|
+
ret[:gb_free_disk] = ret[:mb_free_disk] / 1024
|
198
|
+
|
199
|
+
# run bash command to get hostname
|
200
|
+
ret[:hostname] = self.ssh.exec!('hostname').strip!
|
201
|
+
|
202
|
+
# run bash command to get the CPU load
|
203
|
+
# reference: https://stackoverflow.com/questions/9229333/how-to-get-overall-cpu-usage-e-g-57-on-linux
|
204
|
+
ret[:cpu_load_average] = self.ssh.exec!("awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) \"%\"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)").to_s
|
205
|
+
|
206
|
+
# TODO: monitor the overall Network I/O load
|
207
|
+
|
208
|
+
# TODO: monitor the overall Disk I/O load
|
209
|
+
|
210
|
+
# mapping cpu status
|
211
|
+
ret[:cpu_architecture] = self.ssh.exec!('lscpu | grep Architecture').split(':')[1].strip!
|
212
|
+
ret[:cpu_speed] = self.ssh.exec!('lscpu | grep "CPU MHz:"').split(':')[1].strip!.to_f.round
|
213
|
+
#ret[:cpu_model] = self.ssh.exec!('lscpu | grep "Model"').split(':')[1].strip!
|
214
|
+
#ret[:cpu_type] = ret[:cpu_model].split(' ')[0]
|
215
|
+
ret[:cpu_number] = self.ssh.exec!('lscpu | grep "^CPU(s):"').split(':')[1].strip!.to_i
|
216
|
+
|
217
|
+
# mapping disk status
|
218
|
+
#self.disk_total = mb_total_disk.to_i
|
219
|
+
#self.disk_free = mb_free_disk.to_i
|
220
|
+
|
221
|
+
# mapping lan attributes
|
222
|
+
ret[:net_mac_address] = self.ssh.exec!('ifconfig | grep ether').split[1].upcase.strip.gsub(':', '-')
|
223
|
+
|
224
|
+
self.disconnect
|
225
|
+
|
226
|
+
ret
|
227
|
+
end # def usage
|
228
|
+
|
229
|
+
# return the latest `n`` lines of the file specified by the `filename` parameter
|
230
|
+
def tail(filename, n=10)
|
231
|
+
self.connect
|
232
|
+
s = self.ssh.exec!("tail -n #{n.to_s} #{filename}")
|
233
|
+
self.disconnect
|
234
|
+
s
|
235
|
+
end
|
178
236
|
|
179
237
|
end # module NodeModule
|
180
238
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-nodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|