netid-tools 0.3.11 → 0.4.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.
- data/README.md +5 -1
- data/VERSION +1 -1
- data/bin/ua_check +9 -8
- data/lib/netid-tools.rb +22 -11
- data/netid-tools.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -43,7 +43,7 @@ Executables
|
|
43
43
|
Methods
|
44
44
|
=======
|
45
45
|
|
46
|
-
## Netid#validate_netid?(netid)
|
46
|
+
## Netid::validate_netid?(netid) / Netid#validate_netid?(netid)
|
47
47
|
|
48
48
|
### What it does
|
49
49
|
|
@@ -143,6 +143,10 @@ The NetID you want to check
|
|
143
143
|
Version History
|
144
144
|
===============
|
145
145
|
|
146
|
+
## 0.4.0
|
147
|
+
|
148
|
+
* Switch most methods from Class->Instance
|
149
|
+
|
146
150
|
## 0.3.10
|
147
151
|
|
148
152
|
* Add -p flag for full process check on hosts.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bin/ua_check
CHANGED
@@ -41,28 +41,29 @@ user.each do |netid|
|
|
41
41
|
puts "#{netid}".bold.green
|
42
42
|
puts "-"*netid.length
|
43
43
|
results = 0
|
44
|
+
checkr = Netid.new(netid,system_user)
|
44
45
|
hosts.each do |host|
|
45
|
-
result =
|
46
|
+
result = checkr.check_for_mysql_presence(host)
|
46
47
|
if result
|
47
48
|
results += 1
|
48
49
|
puts "MySQLd detected on #{result[0]}:#{result[1]}".blue
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
result =
|
53
|
+
result = checkr.check_for_localhome
|
53
54
|
if result
|
54
55
|
puts "Localhome: #{result}".cyan
|
55
56
|
else
|
56
57
|
puts "No localhome detected"
|
57
58
|
end
|
58
59
|
|
59
|
-
puts "Webtypes set: #{
|
60
|
+
puts "Webtypes set: #{checkr.check_webtype}"
|
60
61
|
|
61
62
|
puts "No MySQLds Detected".bold.blue if results == 0
|
62
63
|
|
63
64
|
if options[:processes]
|
64
65
|
hosts.each do |host|
|
65
|
-
processes =
|
66
|
+
processes = checkr.get_processes(host)
|
66
67
|
if processes
|
67
68
|
puts "\nProcesses for #{host}:\n".cyan
|
68
69
|
processes.each do |l|
|
@@ -72,9 +73,9 @@ user.each do |netid|
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
unless options[:concise]
|
76
|
+
unless options[:concise]
|
77
|
+
puts "\n"
|
78
|
+
checkr.quota_check
|
79
|
+
end
|
76
80
|
puts "\n"
|
77
|
-
Netid.quota_check(netid,system_user)
|
78
|
-
end
|
79
|
-
puts "\n"
|
80
81
|
end
|
data/lib/netid-tools.rb
CHANGED
@@ -2,6 +2,13 @@ require 'net/ssh'
|
|
2
2
|
require 'colored'
|
3
3
|
|
4
4
|
class Netid
|
5
|
+
attr_accessor :netid, :system_user
|
6
|
+
|
7
|
+
def initialize(netid,system_user=nil)
|
8
|
+
@netid = netid
|
9
|
+
@system_user = system_user
|
10
|
+
end
|
11
|
+
|
5
12
|
def self.validate_netid?(netid)
|
6
13
|
if netid.to_s.length > 8 || netid !~ /^[a-zA-Z][\w-]{0,7}$/
|
7
14
|
false
|
@@ -10,9 +17,13 @@ class Netid
|
|
10
17
|
end
|
11
18
|
end
|
12
19
|
|
13
|
-
def
|
20
|
+
def validate_netid?(netid)
|
21
|
+
Netid.validate_netid?(netid)
|
22
|
+
end
|
23
|
+
|
24
|
+
def check_for_mysql_presence(host)
|
14
25
|
Net::SSH.start(host,system_user, {auth_methods: %w( publickey )}) do |ssh|
|
15
|
-
output = ssh.exec!("ps -U #{
|
26
|
+
output = ssh.exec!("ps -U #{netid} -u #{netid} u")
|
16
27
|
if output =~ /mysql/
|
17
28
|
/port=(?<port>\d+)/ =~ output
|
18
29
|
[host,port]
|
@@ -22,13 +33,13 @@ class Netid
|
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
25
|
-
def
|
36
|
+
def get_processes(host)
|
26
37
|
output = ""
|
27
38
|
Net::SSH.start(host,system_user,{auth_methods: %w(publickey)}) do |ssh|
|
28
|
-
if /no such user/i =~ ssh.exec!("id #{
|
39
|
+
if /no such user/i =~ ssh.exec!("id #{netid}")
|
29
40
|
output = nil
|
30
41
|
else
|
31
|
-
output = ssh.exec!("ps -f --user=#{
|
42
|
+
output = ssh.exec!("ps -f --user=#{netid}").lines
|
32
43
|
end
|
33
44
|
end
|
34
45
|
if output.nil? || output.count == 1
|
@@ -38,10 +49,10 @@ class Netid
|
|
38
49
|
end
|
39
50
|
end
|
40
51
|
|
41
|
-
def
|
52
|
+
def check_for_localhome
|
42
53
|
host = 'ovid02.u.washington.edu'
|
43
54
|
Net::SSH.start(host,system_user, {auth_methods: %w( publickey )}) do |ssh|
|
44
|
-
output = ssh.exec!("cpw -poh #{
|
55
|
+
output = ssh.exec!("cpw -poh #{netid}")
|
45
56
|
if output =~ /Unknown/
|
46
57
|
false
|
47
58
|
else
|
@@ -50,18 +61,18 @@ class Netid
|
|
50
61
|
end
|
51
62
|
end
|
52
63
|
|
53
|
-
def
|
64
|
+
def check_webtype
|
54
65
|
host = 'ovid02.u.washington.edu'
|
55
66
|
Net::SSH.start(host,system_user, {auth_methods: %w( publickey )}) do |ssh|
|
56
|
-
ssh.exec!("webtype -user #{
|
67
|
+
ssh.exec!("webtype -user #{netid}").chomp
|
57
68
|
end
|
58
69
|
end
|
59
70
|
|
60
71
|
|
61
|
-
def
|
72
|
+
def quota_check
|
62
73
|
host = 'ovid02.u.washington.edu'
|
63
74
|
Net::SSH.start(host,system_user, {auth_methods: %w( publickey )}) do |ssh|
|
64
|
-
result = ssh.exec!("quota #{
|
75
|
+
result = ssh.exec!("quota #{netid}").chomp
|
65
76
|
result = result.split("\n")
|
66
77
|
result.delete_at(0) if result.first == ''
|
67
78
|
result.each_with_index do |line,index|
|
data/netid-tools.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netid-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -204,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
204
|
version: '0'
|
205
205
|
segments:
|
206
206
|
- 0
|
207
|
-
hash:
|
207
|
+
hash: 3490936327379327628
|
208
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
209
|
none: false
|
210
210
|
requirements:
|