miab 0.1.0
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/miab.rb +118 -0
- data.tar.gz.sig +0 -0
- metadata +91 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cba50c578e52fc7d97b3c7c499df6b150084840edc5306b09d70932644b7ed54
|
4
|
+
data.tar.gz: 3c82b0a728f82ce751c175daa88144ba15f512d0e8bdefd3cdd1d0fd77ea18c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc1e00313d192742cc5b4dfe3e8a9227bf3eb71e0b41e53211e300f1a08c6c8b74f0cd829da17f8cfb7fd66b88afd18b04b5b12e762785d36b10111650ca09e9
|
7
|
+
data.tar.gz: 38efed52fc6aa009e6c1d8286d199691eb76098a1638b915988ee0dfd10e0eda9be871bf16b51a150ee9c0643a37b29facc517e406bf8d1d712eae275e5ebd20
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/lib/miab.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: miab.rb
|
4
|
+
|
5
|
+
# Desc: Message in a bottle (MIAB) is designed to execute remote commands
|
6
|
+
# through SSH for system maintenance purposes.
|
7
|
+
|
8
|
+
require 'net/ssh'
|
9
|
+
require 'c32'
|
10
|
+
|
11
|
+
|
12
|
+
class Miab
|
13
|
+
using ColouredText
|
14
|
+
|
15
|
+
def initialize(scroll, domain: nil, target: nil, pwlist: {}, password: nil,
|
16
|
+
user: nil, debug: false)
|
17
|
+
|
18
|
+
@results = {}
|
19
|
+
|
20
|
+
@scroll, @debug = scroll, debug
|
21
|
+
|
22
|
+
@nodes = if target then
|
23
|
+
|
24
|
+
target = [target] if target.is_a? String
|
25
|
+
|
26
|
+
target.inject({}) do |r,x|
|
27
|
+
host = domain ? x + '.' + domain : x
|
28
|
+
passwd = pwlist[x] || password
|
29
|
+
userhost = user ? user + '@' + host : host
|
30
|
+
r.merge({userhost => passwd})
|
31
|
+
end
|
32
|
+
|
33
|
+
else
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def cast()
|
39
|
+
|
40
|
+
if @nodes.any? then
|
41
|
+
|
42
|
+
@nodes.each do |raw_host, password|
|
43
|
+
|
44
|
+
host, user = raw_host.split(/@/,2).reverse
|
45
|
+
@host = host
|
46
|
+
@results[host] = {}
|
47
|
+
|
48
|
+
@ssh = Net::SSH.start( host, user, password: password)
|
49
|
+
eval @scroll
|
50
|
+
@ssh.close
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
else
|
55
|
+
@results[`hostname`.chomp] = {}
|
56
|
+
eval @scroll if @scroll
|
57
|
+
end
|
58
|
+
|
59
|
+
@scroll = nil
|
60
|
+
@results
|
61
|
+
end
|
62
|
+
|
63
|
+
def date()
|
64
|
+
|
65
|
+
instructions = 'date'
|
66
|
+
r = @ssh ? @ssh.exec!(instructions) : system(instructions)
|
67
|
+
@results[@host][:date] = r.chomp
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def disk_space()
|
72
|
+
|
73
|
+
instructions = 'df -h'
|
74
|
+
s = @ssh ? @ssh.exec!(instructions) : system(instructions)
|
75
|
+
|
76
|
+
@results[@host][:disk_usage] = {}
|
77
|
+
|
78
|
+
a = s.lines.grep(/\/dev\/root/)
|
79
|
+
|
80
|
+
puts ('a: ' + a.inspect).debug if @debug
|
81
|
+
|
82
|
+
if a.any? then
|
83
|
+
size, used, avail = a[0].split(/ +/).values_at(1,2,3)
|
84
|
+
|
85
|
+
@results[@host][:disk_usage][:root] = {size: size, used: used,
|
86
|
+
avail: avail}
|
87
|
+
end
|
88
|
+
|
89
|
+
a2 = s.lines.grep(/\/dev\/sda1/)
|
90
|
+
|
91
|
+
puts ('a2: ' + a2.inspect).debug if @debug
|
92
|
+
|
93
|
+
if a2.any? then
|
94
|
+
size, used, avail = a2[0].split(/ +/).values_at(1,2,3)
|
95
|
+
|
96
|
+
@results[@host][:disk_usage][:sda1] = {size: size, used: used,
|
97
|
+
avail: avail}
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
alias df disk_space
|
103
|
+
|
104
|
+
|
105
|
+
def pwd()
|
106
|
+
instructions = 'pwd'
|
107
|
+
r = @ssh ? @ssh.exec!(instructions) : system(instructions)
|
108
|
+
@results[@host][:pwd] = r.chomp
|
109
|
+
end
|
110
|
+
|
111
|
+
def temperature()
|
112
|
+
instructions = 'cat /sys/class/thermal/thermal_zone0/temp'
|
113
|
+
r = @ssh ? @ssh.exec!(instructions) : system(instructions)
|
114
|
+
@results[@host][:temperature] = r.chomp
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: miab
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwOTAxMTUwMzQ5WhcN
|
15
|
+
MjAwODMxMTUwMzQ5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC3Zv/A
|
17
|
+
/JALt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Paj3BtGprZmVE00oZw
|
32
|
+
DrTN68G5ifPDjqr4H2G1dEyOUSHILGyIMD/0e2MdMpwvrRg0pbIZXAEQ2XVXEsUH
|
33
|
+
9DP/kToMLGEqKxh1v/EY5rixA8bCE+DcQoGmJSjV7PDunHTOp9lpXZdQCgQ0ZuB2
|
34
|
+
V01VGEvW9MCUidVyPMCJ9PmArZeX+TOSCX2ULHvFC1z0V0GpTHSH4D7O9VEiE5rd
|
35
|
+
9irKsAp/hZt3dTbQOtnSlc9XREZZdegwOgu1FEqBqviNIn9R28OR237HExiWXwmw
|
36
|
+
HDTFIjk8XBqTunABuFUgr4qx
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2019-09-01 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: c32
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.2.0
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.2'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.2.0
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.2'
|
60
|
+
description:
|
61
|
+
email: james@jamesrobertson.eu
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- lib/miab.rb
|
67
|
+
homepage: https://github.com/jrobertson/miab
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.0.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Message in a bottle (MIAB) is designed to execute remote commands through
|
90
|
+
SSH for system maintenance purposes.
|
91
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|