kanrisuru 0.16.16 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/kanrisuru/core/mount/commands/umount.rb +1 -1
- data/lib/kanrisuru/core/system/commands/history.rb +29 -0
- data/lib/kanrisuru/core/system/commands/nproc.rb +15 -0
- data/lib/kanrisuru/core/system/commands/sysctl.rb +26 -0
- data/lib/kanrisuru/core/system/commands.rb +3 -0
- data/lib/kanrisuru/core/system/parser.rb +2 -0
- data/lib/kanrisuru/core/system/parsers/history.rb +18 -0
- data/lib/kanrisuru/core/system/parsers/sysctl.rb +73 -0
- data/lib/kanrisuru/core/transfer/commands/wget.rb +20 -6
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/system_spec.rb +24 -0
- data/spec/functional/core/transfer_spec.rb +27 -11
- data/spec/support/shared_examples/integration/core/system.rb +26 -0
- data/spec/unit/core/system_spec.rb +3 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80ead7b757f8228b63f2908df9163f726e99ec27dcd2b88f7a5ff197e98f8008
|
4
|
+
data.tar.gz: 8393af4b3e03f583981b06eaa384b47527882870289df125d4887f98abb293b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2268c08d84aa9cf09232900c7d2ccd489cb9de12aa77c3fdc9666eb8859d41b072a932d0afb0d6ed2818978e641dee1569ddeda30f417466f7bd1a8150206cb9
|
7
|
+
data.tar.gz: e4ef880302b200deafb4c69e703cfb79fc4162d20d6b6269a635e0277f790c4c872299513cab53edeb395f20e15660fda09ba7d0c135b8ebf97d67b7464e1859
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## Kanrisuru 0.19.0 (January 25, 2022) ##
|
2
|
+
* Add readonly version of `sysctl` command with test cases.
|
3
|
+
|
4
|
+
## Kanrisuru 0.18.0 (January 23, 2022) ##
|
5
|
+
* Add `history` command with test cases.
|
6
|
+
|
7
|
+
## Kanrisuru 0.17.0 (January 20, 2022) ##
|
8
|
+
* Add `nproc` command with test cases.
|
9
|
+
|
10
|
+
## Kanrisuru 0.16.17 (January 10, 2022) ##
|
11
|
+
* Add additional options to `wget` command.
|
12
|
+
* Rename some options to better reflect options from wget program.
|
13
|
+
|
1
14
|
## Kanrisuru 0.16.16 (January 08, 2022) ##
|
2
15
|
* Fix issue with `download` command when downloading directories from remote server.
|
3
16
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module System
|
6
|
+
def history(opts = {})
|
7
|
+
histfile = opts[:histfile] || '~/.bash_history'
|
8
|
+
|
9
|
+
command = Kanrisuru::Command.new("HISTFILE=#{histfile}; history -r; history")
|
10
|
+
|
11
|
+
if Kanrisuru::Util.present?(opts[:delete])
|
12
|
+
command.append_arg('-d', Kanrisuru::Util.array_join_string(opts[:delete], ' '))
|
13
|
+
elsif Kanrisuru::Util.present?(opts[:clear])
|
14
|
+
command.append_flag('-c')
|
15
|
+
elsif Kanrisuru::Util.present?(opts[:n])
|
16
|
+
command << opts[:n]
|
17
|
+
end
|
18
|
+
|
19
|
+
execute_shell(command)
|
20
|
+
|
21
|
+
Kanrisuru::Result.new(command) do |cmd|
|
22
|
+
return if Kanrisuru::Util.present?(opts[:delete]) || Kanrisuru::Util.present?(opts[:clear])
|
23
|
+
|
24
|
+
Parser::History.parse(cmd)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module System
|
6
|
+
def nproc(opts = {})
|
7
|
+
command = Kanrisuru::Command.new('nproc')
|
8
|
+
command.append_flag('--all', opts[:all])
|
9
|
+
execute_shell(command)
|
10
|
+
|
11
|
+
Kanrisuru::Result.new(command, &:to_i)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module System
|
6
|
+
def sysctl(variable = nil)
|
7
|
+
command = Kanrisuru::Command.new('sysctl')
|
8
|
+
|
9
|
+
## Some older versions have a bug with 255 exit code being returned
|
10
|
+
command.append_valid_exit_code(255)
|
11
|
+
|
12
|
+
if Kanrisuru::Util.present?(variable)
|
13
|
+
command << variable
|
14
|
+
else
|
15
|
+
command.append_flag('--all')
|
16
|
+
end
|
17
|
+
|
18
|
+
execute_shell(command)
|
19
|
+
|
20
|
+
Kanrisuru::Result.new(command) do |cmd|
|
21
|
+
Parser::Sysctl.parse(cmd)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'commands/cpu_info'
|
4
4
|
require_relative 'commands/free'
|
5
|
+
require_relative 'commands/history'
|
5
6
|
require_relative 'commands/kernel_statistics'
|
6
7
|
require_relative 'commands/kill'
|
7
8
|
require_relative 'commands/last'
|
@@ -9,9 +10,11 @@ require_relative 'commands/load_average'
|
|
9
10
|
require_relative 'commands/load_env'
|
10
11
|
require_relative 'commands/lscpu'
|
11
12
|
require_relative 'commands/lsof'
|
13
|
+
require_relative 'commands/nproc'
|
12
14
|
require_relative 'commands/poweroff'
|
13
15
|
require_relative 'commands/ps'
|
14
16
|
require_relative 'commands/reboot'
|
17
|
+
require_relative 'commands/sysctl'
|
15
18
|
require_relative 'commands/uptime'
|
16
19
|
require_relative 'commands/w'
|
17
20
|
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'parsers/kernel_statistics'
|
4
|
+
require_relative 'parsers/history'
|
4
5
|
require_relative 'parsers/last'
|
5
6
|
require_relative 'parsers/load_average'
|
6
7
|
require_relative 'parsers/load_env'
|
7
8
|
require_relative 'parsers/lscpu'
|
8
9
|
require_relative 'parsers/lsof'
|
9
10
|
require_relative 'parsers/ps'
|
11
|
+
require_relative 'parsers/sysctl'
|
10
12
|
require_relative 'parsers/uptime'
|
11
13
|
require_relative 'parsers/w'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module System
|
6
|
+
module Parser
|
7
|
+
class History
|
8
|
+
def self.parse(command)
|
9
|
+
lines = command.to_a
|
10
|
+
lines.map do |line|
|
11
|
+
line.split(/^\d+\s+/)[1]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Kanrisuru
|
5
|
+
module Core
|
6
|
+
module System
|
7
|
+
module Parser
|
8
|
+
class Sysctl
|
9
|
+
class << self
|
10
|
+
def parse(command)
|
11
|
+
result = {}
|
12
|
+
|
13
|
+
lines = command.to_a
|
14
|
+
lines.each do |line|
|
15
|
+
next if line.include?("permission denied on key")
|
16
|
+
|
17
|
+
keys, value = parse_line(line)
|
18
|
+
next if Kanrisuru::Util.blank?(value)
|
19
|
+
|
20
|
+
hash = build_nested_hash(keys, value)
|
21
|
+
result = merge_recursively(result, hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
build_struct(result)
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_struct(hash)
|
28
|
+
struct = Struct.new(*hash.keys).new
|
29
|
+
|
30
|
+
hash.keys.each do |key|
|
31
|
+
struct[key] = hash[key].is_a?(Hash) ? build_struct(hash[key]) : hash[key]
|
32
|
+
end
|
33
|
+
|
34
|
+
struct
|
35
|
+
end
|
36
|
+
|
37
|
+
def merge_recursively(h1, h2)
|
38
|
+
h1.merge(h2) do |k, v1, v2|
|
39
|
+
if v1.is_a?(Hash) && v2.is_a?(Hash)
|
40
|
+
merge_recursively(v1, v2)
|
41
|
+
else
|
42
|
+
[v1, v2].flatten
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_nested_hash(array, value)
|
48
|
+
array.reverse.inject(value) { |assigned_value, key| { key => assigned_value } }
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_line(line)
|
52
|
+
string, value = line.split(' =')
|
53
|
+
return if Kanrisuru::Util.blank?(value)
|
54
|
+
|
55
|
+
string = string.strip
|
56
|
+
value = value.strip
|
57
|
+
|
58
|
+
if Kanrisuru::Util.numeric?(value)
|
59
|
+
value = value.to_i
|
60
|
+
elsif /\t+/.match(value)
|
61
|
+
## Split tab delimited strings
|
62
|
+
value = value.split(/\t/)
|
63
|
+
end
|
64
|
+
|
65
|
+
[string.split('.').map(&:to_sym), value]
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -105,7 +105,12 @@ module Kanrisuru
|
|
105
105
|
end
|
106
106
|
|
107
107
|
command.append_arg('--post-file', opts[:post_file])
|
108
|
+
command.append_arg('--method', opts[:method])
|
109
|
+
|
108
110
|
command.append_flag('--content-disposition', opts[:content_disposition])
|
111
|
+
command.append_flag('--content-on-error', opts[:content_on_error])
|
112
|
+
command.append_flag('--trust-server-names', opts[:trust_server_names])
|
113
|
+
command.append_flag('--retry-on-host-error', opts[:retry_on_host_error])
|
109
114
|
|
110
115
|
## SSL / TLS
|
111
116
|
if Kanrisuru::Util.present?(opts[:secure_protocol])
|
@@ -123,18 +128,24 @@ module Kanrisuru
|
|
123
128
|
command.append_arg('--ca-directory', opts[:ca_directory])
|
124
129
|
command.append_arg('--random-file', opts[:random_file])
|
125
130
|
command.append_arg('--egd-file', opts[:egd_file])
|
131
|
+
command.append_flag('--https-only', opts[:https_only])
|
126
132
|
|
127
|
-
## FTP
|
133
|
+
## FTP / FTPS
|
128
134
|
command.append_arg('--ftp-user', opts[:ftp_user])
|
129
135
|
command.append_arg('--ftp-password', opts[:ftp_password])
|
130
136
|
command.append_flag('--no-remove-listing', opts[:no_remove_listing])
|
131
137
|
command.append_flag('--no-glob', opts[:no_glob])
|
132
138
|
command.append_flag('--no-passive-ftp', opts[:no_passive_ftp])
|
133
139
|
command.append_flag('--retr-symlinks', opts[:retr_symlinks])
|
140
|
+
command.append_flag('--preserve-permissions', opts[:preserve_permissions])
|
141
|
+
command.append_flag('--ftps-implicit', opts[:ftps_implicit])
|
142
|
+
command.append_flag('--no-ftps-resume-ssl', opts[:no_ftps_resume_ssl])
|
143
|
+
command.append_flag('--ftps-clear-data-connection', opts[:ftps_clear_data_connection])
|
144
|
+
command.append_flag('--ftps-fallback-to-ftp', opts[:ftps_fallback_to_ftp])
|
134
145
|
|
135
146
|
## Recursive Retrieval
|
136
147
|
command.append_flag('--recursive', opts[:recursive])
|
137
|
-
command.append_arg('--level', opts[:
|
148
|
+
command.append_arg('--level', opts[:level])
|
138
149
|
command.append_flag('--delete-after', opts[:delete_after])
|
139
150
|
command.append_flag('--convert-links', opts[:convert_links])
|
140
151
|
command.append_flag('--backup-converted', opts[:backup_converted])
|
@@ -143,10 +154,13 @@ module Kanrisuru
|
|
143
154
|
command.append_flag('--strict-comments', opts[:strict_comments])
|
144
155
|
|
145
156
|
## Recursive Accept/Reject
|
146
|
-
command.append_arg('--accept', Kanrisuru::Util.array_join_string(opts[:
|
147
|
-
command.append_arg('--reject', Kanrisuru::Util.array_join_string(opts[:
|
148
|
-
command.append_arg('--
|
149
|
-
command.append_arg('--
|
157
|
+
command.append_arg('--accept', Kanrisuru::Util.array_join_string(opts[:accept]))
|
158
|
+
command.append_arg('--reject', Kanrisuru::Util.array_join_string(opts[:reject]))
|
159
|
+
command.append_arg('--accept-regex', opts[:accept_regex])
|
160
|
+
command.append_arg('--reject-regex', opts[:reject_regex])
|
161
|
+
command.append_arg('--regex_type', opts[:regex_type])
|
162
|
+
command.append_arg('--domains', Kanrisuru::Util.array_join_string(opts[:domains]))
|
163
|
+
command.append_arg('--exclude-domains', Kanrisuru::Util.array_join_string(opts[:exclude_domains]))
|
150
164
|
command.append_arg('--follow-tags', Kanrisuru::Util.array_join_string(opts[:follow_tags]))
|
151
165
|
command.append_arg('--ignore-tags', Kanrisuru::Util.array_join_string(opts[:ignore_tags]))
|
152
166
|
command.append_arg('--include-directories', Kanrisuru::Util.array_join_string(opts[:include_directories]))
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -43,6 +43,20 @@ RSpec.describe Kanrisuru::Core::System do
|
|
43
43
|
end.to raise_error(ArgumentError)
|
44
44
|
end
|
45
45
|
|
46
|
+
it 'prepares history command' do
|
47
|
+
expect_command(host.history, 'HISTFILE=~/.bash_history; history -r; history')
|
48
|
+
expect_command(host.history(histfile: '~/.history', n: 100),
|
49
|
+
'HISTFILE=~/.history; history -r; history 100')
|
50
|
+
expect_command(host.history(clear: true),
|
51
|
+
'HISTFILE=~/.bash_history; history -r; history -c')
|
52
|
+
expect_command(host.history(delete: 5),
|
53
|
+
'HISTFILE=~/.bash_history; history -r; history -d 5')
|
54
|
+
expect_command(host.history(delete: [23, 30]),
|
55
|
+
'HISTFILE=~/.bash_history; history -r; history -d 23 30')
|
56
|
+
expect_command(host.history(delete: '-7'),
|
57
|
+
'HISTFILE=~/.bash_history; history -r; history -d -7')
|
58
|
+
end
|
59
|
+
|
46
60
|
it 'prepares kernel_statistics command' do
|
47
61
|
expect_command(host.kernel_statistics, 'cat /proc/stat')
|
48
62
|
end
|
@@ -79,6 +93,11 @@ RSpec.describe Kanrisuru::Core::System do
|
|
79
93
|
expect_command(host.lsof, 'lsof -F pcuftDsin')
|
80
94
|
end
|
81
95
|
|
96
|
+
it 'prepares sysctl command' do
|
97
|
+
expect_command(host.sysctl, 'sysctl --all')
|
98
|
+
expect_command(host.sysctl('net.ipv4.conf.all'), 'sysctl net.ipv4.conf.all')
|
99
|
+
end
|
100
|
+
|
82
101
|
it 'prepares poweroff command' do
|
83
102
|
expect_command(host.poweroff, 'shutdown')
|
84
103
|
expect_command(host.poweroff(cancel: true), 'shutdown -c')
|
@@ -124,6 +143,11 @@ RSpec.describe Kanrisuru::Core::System do
|
|
124
143
|
end.to raise_error(ArgumentError)
|
125
144
|
end
|
126
145
|
|
146
|
+
it 'prepares nproc command' do
|
147
|
+
expect_command(host.nproc, 'nproc')
|
148
|
+
expect_command(host.nproc(all: true), 'nproc --all')
|
149
|
+
end
|
150
|
+
|
127
151
|
it 'prepares uptime command' do
|
128
152
|
expect_command(host.uptime, 'cat /proc/uptime')
|
129
153
|
end
|
@@ -97,8 +97,11 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
97
97
|
},
|
98
98
|
content_disposition: true,
|
99
99
|
secure_protocol: 'SSLv3',
|
100
|
+
content_on_error: true,
|
101
|
+
trust_server_names: true,
|
102
|
+
retry_on_host_error: true,
|
100
103
|
no_check_certificate: true),
|
101
|
-
"wget --post-data url=https%3A%2F%2Fexample.com%3Fparam%3D123 --content-disposition --secure-protocol SSLv3 --no-check-certificate #{url}")
|
104
|
+
"wget --post-data url=https%3A%2F%2Fexample.com%3Fparam%3D123 --content-disposition --content-on-error --trust-server-names --retry-on-host-error --secure-protocol SSLv3 --no-check-certificate #{url}")
|
102
105
|
|
103
106
|
expect do
|
104
107
|
host.wget(url, secure_protocol: 'SSL')
|
@@ -115,27 +118,37 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
115
118
|
|
116
119
|
expect_command(host.wget(url,
|
117
120
|
certificate: '~/cert.pem',
|
121
|
+
https_only: true,
|
118
122
|
certificate_type: 'PEM',
|
119
123
|
private_key: '~/key.pem',
|
120
124
|
private_key_type: 'PEM',
|
121
125
|
ca_certificate: '~/ca.pem',
|
122
126
|
random_file: '~/random'),
|
123
|
-
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}")
|
127
|
+
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random --https-only #{url}")
|
124
128
|
|
125
129
|
## FTP
|
126
|
-
expect_command(host.wget(
|
130
|
+
expect_command(host.wget('ftp.example.com',
|
127
131
|
ftp_user: 'admin',
|
128
132
|
ftp_password: '12345678',
|
129
133
|
no_remove_listing: true,
|
130
134
|
no_glob: true,
|
131
135
|
no_passive_ftp: true,
|
132
|
-
retr_symlinks: true
|
133
|
-
|
136
|
+
retr_symlinks: true,
|
137
|
+
preserve_permissions: true),
|
138
|
+
'wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks --preserve-permissions ftp.example.com')
|
139
|
+
|
140
|
+
expect_command(host.wget('ftps.example.com',
|
141
|
+
ftp_user: 'admin',
|
142
|
+
ftp_password: '12345678',
|
143
|
+
ftps_implicit: true,
|
144
|
+
no_ftps_resume_ssl: true,
|
145
|
+
ftps_fallback_to_ftp: true,
|
146
|
+
ftps_clear_data_connection: true), 'wget --ftp-user admin --ftp-password 12345678 --ftps-implicit --no-ftps-resume-ssl --ftps-clear-data-connection --ftps-fallback-to-ftp ftps.example.com')
|
134
147
|
|
135
148
|
## Recursive Retrieval
|
136
149
|
expect_command(host.wget(url,
|
137
150
|
recursive: true,
|
138
|
-
|
151
|
+
level: 10,
|
139
152
|
delete_after: true,
|
140
153
|
convert_links: true,
|
141
154
|
backup_converted: true,
|
@@ -146,10 +159,13 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
146
159
|
|
147
160
|
## Recursive Accept/Reject
|
148
161
|
expect_command(host.wget(url,
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
162
|
+
accept: ['.txt', '.html'],
|
163
|
+
reject: ['.csv'],
|
164
|
+
accept_regex: 'https://*',
|
165
|
+
regect_regex: 'ftp*',
|
166
|
+
regex_type: 'posix',
|
167
|
+
domains: ['example.com'],
|
168
|
+
exclude_domains: ['hackernews.com'],
|
153
169
|
follow_tags: %w[a div span],
|
154
170
|
ignore_tags: %w[area link],
|
155
171
|
include_directories: ['/gems'],
|
@@ -159,6 +175,6 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
159
175
|
span_hosts: true,
|
160
176
|
relative: true,
|
161
177
|
no_parent: true),
|
162
|
-
"wget --accept .txt,.html --reject .csv --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}")
|
178
|
+
"wget --accept .txt,.html --reject .csv --accept-regex https://* --regex_type posix --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}")
|
163
179
|
end
|
164
180
|
end
|
@@ -50,6 +50,12 @@ RSpec.shared_examples 'system' do |os_name, host_json, _spec_dir|
|
|
50
50
|
expect(result.days).to be >= 0
|
51
51
|
end
|
52
52
|
|
53
|
+
it 'gets history' do
|
54
|
+
result = host.history
|
55
|
+
expect(result).to be_success
|
56
|
+
expect(result.data).to be_instance_of(Array)
|
57
|
+
end
|
58
|
+
|
53
59
|
it 'kills pids' do
|
54
60
|
command = 'sleep 100000 > /dev/null 2>&1 &'
|
55
61
|
|
@@ -94,6 +100,20 @@ RSpec.shared_examples 'system' do |os_name, host_json, _spec_dir|
|
|
94
100
|
expect(result.cpus.length).to eq(host.cpu.cores)
|
95
101
|
end
|
96
102
|
|
103
|
+
it 'gets kernel sysctl info' do
|
104
|
+
result = host.sysctl
|
105
|
+
expect(result).to be_success
|
106
|
+
expect(result).to respond_to :net
|
107
|
+
expect(result).to respond_to :kernel
|
108
|
+
expect(result).to respond_to :dev
|
109
|
+
|
110
|
+
result = host.sysctl('net.ipv4.conf')
|
111
|
+
expect(result).to be_success
|
112
|
+
expect(result).to respond_to :net
|
113
|
+
expect(result.net).to respond_to :ipv4
|
114
|
+
expect(result.net.ipv4).to respond_to :conf
|
115
|
+
end
|
116
|
+
|
97
117
|
it 'gets login details' do
|
98
118
|
host.su('root')
|
99
119
|
|
@@ -108,6 +128,12 @@ RSpec.shared_examples 'system' do |os_name, host_json, _spec_dir|
|
|
108
128
|
expect(result).to be_success
|
109
129
|
end
|
110
130
|
|
131
|
+
it 'gets nproc count' do
|
132
|
+
result = host.nproc
|
133
|
+
expect(result).to be_success
|
134
|
+
expect(result.to_i).to be > 0
|
135
|
+
end
|
136
|
+
|
111
137
|
it 'gets process details' do
|
112
138
|
result = host.ps
|
113
139
|
|
@@ -25,12 +25,15 @@ RSpec.describe Kanrisuru::Core::System do
|
|
25
25
|
expect(host).to respond_to(:lscpu)
|
26
26
|
expect(host).to respond_to(:load_average)
|
27
27
|
expect(host).to respond_to(:free)
|
28
|
+
expect(host).to respond_to(:history)
|
28
29
|
expect(host).to respond_to(:ps)
|
29
30
|
expect(host).to respond_to(:kill)
|
30
31
|
expect(host).to respond_to(:kernel_statistics)
|
31
32
|
expect(host).to respond_to(:kstat)
|
32
33
|
expect(host).to respond_to(:lsof)
|
34
|
+
expect(host).to respond_to(:nproc)
|
33
35
|
expect(host).to respond_to(:last)
|
36
|
+
expect(host).to respond_to(:sysctl)
|
34
37
|
expect(host).to respond_to(:uptime)
|
35
38
|
expect(host).to respond_to(:w)
|
36
39
|
expect(host).to respond_to(:who)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel_tests
|
@@ -307,6 +307,7 @@ files:
|
|
307
307
|
- lib/kanrisuru/core/system/commands.rb
|
308
308
|
- lib/kanrisuru/core/system/commands/cpu_info.rb
|
309
309
|
- lib/kanrisuru/core/system/commands/free.rb
|
310
|
+
- lib/kanrisuru/core/system/commands/history.rb
|
310
311
|
- lib/kanrisuru/core/system/commands/kernel_statistics.rb
|
311
312
|
- lib/kanrisuru/core/system/commands/kill.rb
|
312
313
|
- lib/kanrisuru/core/system/commands/last.rb
|
@@ -314,12 +315,15 @@ files:
|
|
314
315
|
- lib/kanrisuru/core/system/commands/load_env.rb
|
315
316
|
- lib/kanrisuru/core/system/commands/lscpu.rb
|
316
317
|
- lib/kanrisuru/core/system/commands/lsof.rb
|
318
|
+
- lib/kanrisuru/core/system/commands/nproc.rb
|
317
319
|
- lib/kanrisuru/core/system/commands/poweroff.rb
|
318
320
|
- lib/kanrisuru/core/system/commands/ps.rb
|
319
321
|
- lib/kanrisuru/core/system/commands/reboot.rb
|
322
|
+
- lib/kanrisuru/core/system/commands/sysctl.rb
|
320
323
|
- lib/kanrisuru/core/system/commands/uptime.rb
|
321
324
|
- lib/kanrisuru/core/system/commands/w.rb
|
322
325
|
- lib/kanrisuru/core/system/parser.rb
|
326
|
+
- lib/kanrisuru/core/system/parsers/history.rb
|
323
327
|
- lib/kanrisuru/core/system/parsers/kernel_statistics.rb
|
324
328
|
- lib/kanrisuru/core/system/parsers/last.rb
|
325
329
|
- lib/kanrisuru/core/system/parsers/load_average.rb
|
@@ -327,6 +331,7 @@ files:
|
|
327
331
|
- lib/kanrisuru/core/system/parsers/lscpu.rb
|
328
332
|
- lib/kanrisuru/core/system/parsers/lsof.rb
|
329
333
|
- lib/kanrisuru/core/system/parsers/ps.rb
|
334
|
+
- lib/kanrisuru/core/system/parsers/sysctl.rb
|
330
335
|
- lib/kanrisuru/core/system/parsers/uptime.rb
|
331
336
|
- lib/kanrisuru/core/system/parsers/w.rb
|
332
337
|
- lib/kanrisuru/core/system/types.rb
|
@@ -706,7 +711,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
706
711
|
- !ruby/object:Gem::Version
|
707
712
|
version: '0'
|
708
713
|
requirements: []
|
709
|
-
rubygems_version: 3.
|
714
|
+
rubygems_version: 3.3.5
|
710
715
|
signing_key:
|
711
716
|
specification_version: 4
|
712
717
|
summary: Manage remote servers over ssh with ruby.
|