virtop 0.1.0 → 0.1.1
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/bin/virtop +58 -38
- data/lib/virtop.rb +1 -1
- metadata +4 -21
data/bin/virtop
CHANGED
@@ -11,7 +11,7 @@ include Virtop
|
|
11
11
|
# Show some lines of help.
|
12
12
|
if ['-h', '--help'].include? ARGV.first
|
13
13
|
$stderr.puts <<EOF
|
14
|
-
#{$0} [libvirt-uri]
|
14
|
+
#{$0} {[libvirt-uri]}
|
15
15
|
|
16
16
|
libvirt-uri is optional. Default is qemu:///system (for the local libvirt
|
17
17
|
daemon). See http://libvirt.org/uri.html for URI format.
|
@@ -27,24 +27,36 @@ end
|
|
27
27
|
# Connection URL will be qemu:///system if nothing else is given as the first
|
28
28
|
# parameter.
|
29
29
|
if ARGV.size < 1
|
30
|
-
|
30
|
+
urls = ['qemu:///system']
|
31
31
|
else
|
32
|
-
|
32
|
+
urls = []
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
ARGV.each do |url|
|
35
|
+
uri = URI.parse url
|
36
|
+
|
37
|
+
# Works around a deadlock if path is empty.
|
38
|
+
if uri.scheme == 'qemu+ssh' and uri.path == ''
|
39
|
+
raise Exception.new 'Invalid url specified: ' + uri.to_s
|
40
|
+
else
|
41
|
+
urls.push uri.to_s
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
46
|
+
connections = []
|
47
|
+
|
42
48
|
# Open the connection to the libvirt ressource or print out error message.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
urls.each do |url|
|
50
|
+
thread = Thread.start do
|
51
|
+
begin
|
52
|
+
connections.push Libvirt::open url
|
53
|
+
rescue Libvirt::ConnectionError
|
54
|
+
$stderr.puts 'Connection failed: ' + url.to_s
|
55
|
+
exit 1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
thread.join
|
48
60
|
end
|
49
61
|
|
50
62
|
# Initialize ncurses context. Clear and print details for each domain in a 10s
|
@@ -66,22 +78,24 @@ begin
|
|
66
78
|
n.keypad true
|
67
79
|
|
68
80
|
# Add topmost meta information lines to ncurses screen.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
connections.each do |c|
|
82
|
+
begin
|
83
|
+
n.addstr(
|
84
|
+
c.hostname.upcase +
|
85
|
+
"\n" +
|
86
|
+
' cores ' + c.cores +
|
87
|
+
' cpus ' + c.cpus +
|
88
|
+
' ghz ' + c.ghz +
|
89
|
+
' arch ' + c.arch +
|
90
|
+
"\n" +
|
91
|
+
' mem ' + c.mem +
|
92
|
+
' free ' + c.memfree +
|
93
|
+
"\n" +
|
94
|
+
' version ' + c.version +
|
95
|
+
"\n\n"
|
96
|
+
)
|
97
|
+
rescue Libvirt::Error
|
98
|
+
end
|
85
99
|
end
|
86
100
|
|
87
101
|
# Initialize table (columns).
|
@@ -95,15 +109,17 @@ begin
|
|
95
109
|
)
|
96
110
|
|
97
111
|
# Add information of each domain to table.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
112
|
+
connections.each do |c|
|
113
|
+
c.domains.each do |d|
|
114
|
+
t.add_row(
|
115
|
+
d.name,
|
116
|
+
d.state,
|
117
|
+
d.mem,
|
118
|
+
d.mem_max,
|
119
|
+
d.cpu_num,
|
120
|
+
d.cpu_time
|
121
|
+
)
|
122
|
+
end
|
107
123
|
end
|
108
124
|
|
109
125
|
# Sort table by chosen column.
|
@@ -133,4 +149,8 @@ ensure
|
|
133
149
|
Ncurses.echo
|
134
150
|
Ncurses.cbreak
|
135
151
|
Ncurses.endwin
|
152
|
+
|
153
|
+
connections.each do |c|
|
154
|
+
c.close
|
155
|
+
end
|
136
156
|
end
|
data/lib/virtop.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- henning mueller
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-08-11 00:00:00 +02:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,11 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 2
|
31
|
-
- 4
|
32
|
-
- 2
|
33
24
|
version: 1.2.4.2
|
34
25
|
type: :runtime
|
35
26
|
version_requirements: *id001
|
@@ -41,10 +32,6 @@ dependencies:
|
|
41
32
|
requirements:
|
42
33
|
- - ">="
|
43
34
|
- !ruby/object:Gem::Version
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
- 3
|
47
|
-
- 0
|
48
35
|
version: 0.3.0
|
49
36
|
type: :runtime
|
50
37
|
version_requirements: *id002
|
@@ -78,21 +65,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
65
|
requirements:
|
79
66
|
- - ">="
|
80
67
|
- !ruby/object:Gem::Version
|
81
|
-
segments:
|
82
|
-
- 0
|
83
68
|
version: "0"
|
84
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
70
|
none: false
|
86
71
|
requirements:
|
87
72
|
- - ">="
|
88
73
|
- !ruby/object:Gem::Version
|
89
|
-
segments:
|
90
|
-
- 0
|
91
74
|
version: "0"
|
92
75
|
requirements: []
|
93
76
|
|
94
77
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.
|
78
|
+
rubygems_version: 1.6.2
|
96
79
|
signing_key:
|
97
80
|
specification_version: 3
|
98
81
|
summary: The top for virtual machines (libvirt).
|