sys-uptime 0.5.4-x86-mingw32 → 0.6.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +145 -144
- data/MANIFEST +13 -12
- data/README +67 -14
- data/Rakefile +44 -87
- data/examples/{sys_uptime_example.rb → uptime_test.rb} +21 -21
- data/lib/unix/sys/uptime.rb +213 -0
- data/lib/windows/sys/uptime.rb +164 -158
- data/sys-uptime.gemspec +23 -21
- data/test/test_sys_uptime.rb +109 -65
- metadata +29 -50
- data/doc/uptime.txt +0 -98
- data/ext/extconf.rb +0 -28
- data/ext/sys/uptime.c +0 -250
- data/lib/linux/sys/uptime.rb +0 -101
data/CHANGES
CHANGED
@@ -1,144 +1,145 @@
|
|
1
|
-
== 0.
|
2
|
-
*
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
* Fixed the
|
13
|
-
|
14
|
-
|
15
|
-
*
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
*
|
32
|
-
*
|
33
|
-
*
|
34
|
-
*
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
*
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
* Added
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
*
|
52
|
-
|
53
|
-
|
54
|
-
*
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
*
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
*
|
64
|
-
*
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
* Added
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
long
|
79
|
-
|
80
|
-
*
|
81
|
-
*
|
82
|
-
|
83
|
-
|
84
|
-
*
|
85
|
-
*
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
*
|
95
|
-
*
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
*
|
101
|
-
*
|
102
|
-
*
|
103
|
-
*
|
104
|
-
*
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
*
|
110
|
-
* Modified
|
111
|
-
*
|
112
|
-
*
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
* Added
|
120
|
-
* Added a
|
121
|
-
*
|
122
|
-
*
|
123
|
-
*
|
124
|
-
*
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
* Added a
|
129
|
-
*
|
130
|
-
*
|
131
|
-
*
|
132
|
-
*
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
1
|
+
== 0.6.0 - 11-Dec-2011
|
2
|
+
* Switched Unix code to use FFI.
|
3
|
+
* Removed all of the C related tasks from the Rakefile and added the gem:build
|
4
|
+
and gem:install tasks.
|
5
|
+
* Internal directory layout changes, with appropriate changes to the gemspec.
|
6
|
+
|
7
|
+
== 0.5.3 - 7-May-2009
|
8
|
+
* Altered the Uptime.seconds implementation on Linux so that it works with
|
9
|
+
both Ruby 1.8.x and 1.9.x. Thanks go to Alexey Chebotar for the spot.
|
10
|
+
|
11
|
+
== 0.5.2 - 13-Dec-2008
|
12
|
+
* Fixed a date/time issue in the Windows version caused by Ruby itself.
|
13
|
+
* Fixed the Uptime.seconds, Uptime.minutes and Uptime.hours methods on MS
|
14
|
+
Windows.
|
15
|
+
* Renamed the test file to 'test_sys_uptime.rb'.
|
16
|
+
* Some minor updates to the Rakefile.
|
17
|
+
|
18
|
+
== 0.5.1 - 26-Jul-2007
|
19
|
+
* Fixed bug in the MS Windows version caused by incorrect parsing of an
|
20
|
+
MS specific date format (caused by a bug in Ruby 1.8.6). Thanks go to
|
21
|
+
Robert H. for the spot.
|
22
|
+
* Inlined the Rake installation tasks, so the install.rb file has been
|
23
|
+
removed.
|
24
|
+
* Added an 'install_gem' Rake task, and updated the README installation
|
25
|
+
instructions.
|
26
|
+
|
27
|
+
== 0.5.0 - 30-Mar-2007
|
28
|
+
* For platforms that use C code, the code now always uses the sysctl()
|
29
|
+
function if supported by your system. This replaces the platform specific
|
30
|
+
checks I was doing for the various BSD flavors.
|
31
|
+
* Fix for OS X - the Uptime.boot_time method now works.
|
32
|
+
* UptimeError is now Uptime::Error.
|
33
|
+
* Improved RDoc in the uptime.c source code.
|
34
|
+
* Added a Rakefile - users should now use the 'test' and 'install' rake tasks.
|
35
|
+
* Updates to the MANIFEST, README and uptime.txt files.
|
36
|
+
|
37
|
+
== 0.4.5 - 19-Nov-2006
|
38
|
+
* Internal layout changes, minor doc updates and gemspec improvements.
|
39
|
+
* No code changes.
|
40
|
+
|
41
|
+
== 0.4.4 - 30-Jun-2006
|
42
|
+
* Added inline rdoc documentation to the source files.
|
43
|
+
* Added a gemspec.
|
44
|
+
|
45
|
+
== 0.4.3 - 18-Dec-2005
|
46
|
+
* Changed the Linux version to pure Ruby. The current method of determining
|
47
|
+
uptime in unix.c does not work in Linux kernel 2.6+. So, from now on it
|
48
|
+
reads out of /proc/uptime.
|
49
|
+
|
50
|
+
== 0.4.2 - 6-May-2005
|
51
|
+
* Fixed a potential boot_time bug.
|
52
|
+
* Removed the version.h file. It's no longer needed since the Windows
|
53
|
+
version is pure Ruby.
|
54
|
+
* NetBSD 2.x and FreeBSD 5.x now supported.
|
55
|
+
* Removed the INSTALL file. Installation instructions are now in
|
56
|
+
the README file.
|
57
|
+
* Removed the uptime.rd file. You can generate html documentation by
|
58
|
+
running rdoc over the uptime.txt file.
|
59
|
+
* Made most documents rdoc friendly.
|
60
|
+
* Moved project to RubyForge.
|
61
|
+
|
62
|
+
== 0.4.1 - 14-Dec-2004
|
63
|
+
* Moved freebsd code into unix.c file.
|
64
|
+
* Should now work past 249 days (2**31) on systems that have utmpx.h.
|
65
|
+
* Fixed a bug with regards to boot_time, where it was possible that it would
|
66
|
+
simply be empty.
|
67
|
+
|
68
|
+
== 0.4.0 - 8-Jul-2004
|
69
|
+
* Removed all reference to the CLK_TCK constant, as per documentation from
|
70
|
+
Richard Stevens that it is deprecated and that sysconf() should be used
|
71
|
+
instead (well, I knew about this, but ignored it until now).
|
72
|
+
* Scrapped the C version for Windows in favor of a pure Ruby version that
|
73
|
+
uses win32ole + WMI.
|
74
|
+
* Added a boot_time method for Unix systems (Windows already had this).
|
75
|
+
* Added an UptimeError class on Unix systems (and replaced UptimeException
|
76
|
+
on Windows).
|
77
|
+
* Modified an internal function to raise an UptimeError if the times()
|
78
|
+
function fails. Also, it now returns an unsigned long instead of a plain
|
79
|
+
long.
|
80
|
+
* Replaced the two different test suites with a single, unified test suite.
|
81
|
+
* Cleaned up the extconf.rb script. I now assume that TestUnit is installed.
|
82
|
+
* Removed the load_avg method (which was never advertised and which I hope
|
83
|
+
you weren't using). You can find a load_avg method in the sys-cpu package.
|
84
|
+
* Changed uptime.rd2 to uptime.rd to be consistent with my other packages.
|
85
|
+
* Removed the uptime.html file - you may generate that on your own.
|
86
|
+
* Added warranty and license info.
|
87
|
+
|
88
|
+
== 0.3.2 - 30-Dec-2003
|
89
|
+
* Cleaned up some warnings that showed up with -Wall on some unix platforms
|
90
|
+
(int vs long format, explicit include)
|
91
|
+
* Minor test suite and extconf.rb changes
|
92
|
+
|
93
|
+
== 0.3.1 - 25-Jun-2003
|
94
|
+
* Modified test files to handle HP-UX extensions
|
95
|
+
* Minor doc updates
|
96
|
+
* Added the dhms() method. Actually, this was in the 0.3.0
|
97
|
+
release, I just forgot to mention it in this file :)
|
98
|
+
|
99
|
+
== 0.3.0 - 22-Jun-2003
|
100
|
+
* Added OS X support - thanks go to Mike Hall for the patch
|
101
|
+
* Fixed incorrect values in FreeBSD (again Mike Hall)
|
102
|
+
* Modified tc_unix.rb test suite to handle OS X, along with a bit
|
103
|
+
* of minor cleanup
|
104
|
+
* Removed VERSION class method. Use the constant instead
|
105
|
+
* Separated FreeBSD/OS X source into its own file (freebsd.c).
|
106
|
+
The #ifdefs were starting to get too ugly for me
|
107
|
+
|
108
|
+
== 0.2.1 - 13-May-2003
|
109
|
+
* Fixed bug in extconf.rb file, and made some major changes
|
110
|
+
* Modified test.rb for those without TestUnit
|
111
|
+
* Modified TestUnit tests - some bogus tests were removed
|
112
|
+
* Added a README file with some additional info
|
113
|
+
* Created a version.h file, so that I can keep the VERSION number
|
114
|
+
in one place
|
115
|
+
* Docs automatically included in doc directory (i.e. no more interactive
|
116
|
+
document creation)
|
117
|
+
|
118
|
+
== 0.2.0 - 13-Mar-2003
|
119
|
+
* Added MS Windows support
|
120
|
+
* Added a VERSION constant
|
121
|
+
* Added a test suite (for those with TestUnit installed)
|
122
|
+
* Internal directory layout change
|
123
|
+
* uptime.c is now split into unix.c and windows.c (and linked appropriately)
|
124
|
+
* Changelog and Manifest are now CHANGES and MANIFEST, respectively
|
125
|
+
* Many changes to extconf.rb
|
126
|
+
|
127
|
+
== 0.1.3 - 6-Jan-2003
|
128
|
+
* Added a VERSION class method
|
129
|
+
* Added a copyright notice
|
130
|
+
* Fixed up the docs a bit and moved them to the doc directory
|
131
|
+
* Changed the tarball name to match the RAA package name
|
132
|
+
* Modified test.rb script to make it better
|
133
|
+
* Changed install instructions slightly
|
134
|
+
|
135
|
+
== 0.1.2 - 25-Aug-2002
|
136
|
+
* Slight change to preprocessor commands to avoid redefining CLK_TCK on
|
137
|
+
those systems that define it in time.h
|
138
|
+
* Added an INSTALL file
|
139
|
+
|
140
|
+
== 0.1.1 - 21-Jun-2002
|
141
|
+
* The CLK_TCK constant wasn't necessarily being set correctly, which could
|
142
|
+
lead to some odd results. This has been fixed.
|
143
|
+
|
144
|
+
== 0.1.0 - 17-Jun-2002
|
145
|
+
* Initial release
|
data/MANIFEST
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
* CHANGES
|
2
|
-
* MANIFEST
|
3
|
-
* Rakefile
|
4
|
-
* README
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* ext/
|
10
|
-
*
|
11
|
-
* lib/
|
12
|
-
*
|
1
|
+
* CHANGES
|
2
|
+
* MANIFEST
|
3
|
+
* Rakefile
|
4
|
+
* README
|
5
|
+
* install.rb
|
6
|
+
* sys-uptime.gemspec
|
7
|
+
* doc/uptime.txt
|
8
|
+
* examples/test.rb
|
9
|
+
* ext/extconf.rb
|
10
|
+
* ext/sys/uptime.c
|
11
|
+
* lib/sys/linux.rb
|
12
|
+
* lib/sys/windows.rb
|
13
|
+
* test/test_sys_uptime.rb
|
data/README
CHANGED
@@ -1,14 +1,67 @@
|
|
1
|
-
= Description
|
2
|
-
|
3
|
-
|
4
|
-
= Prerequisites
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
= Description
|
2
|
+
A Ruby interface for getting system uptime information.
|
3
|
+
|
4
|
+
= Prerequisites
|
5
|
+
ffi 0.5.0 or later.
|
6
|
+
|
7
|
+
= Installation
|
8
|
+
gem install sys-uptime # Unix platforms
|
9
|
+
gem install sys-uptime --platform mswin32 # MS Windows
|
10
|
+
|
11
|
+
= Synopsis
|
12
|
+
require 'sys/uptime'
|
13
|
+
include Sys
|
14
|
+
|
15
|
+
# Get everything
|
16
|
+
p Uptime.uptime
|
17
|
+
p Uptime.dhms.join(', ')
|
18
|
+
|
19
|
+
# Get individual units
|
20
|
+
p Uptime.days
|
21
|
+
p Uptime.hours
|
22
|
+
p Uptime.minutes
|
23
|
+
p Uptime.seconds
|
24
|
+
|
25
|
+
# Get the boot time
|
26
|
+
p Uptime.boot_time
|
27
|
+
|
28
|
+
= Notes
|
29
|
+
On MS Windows the Uptime.uptime and Uptime_boot_time methods optionally
|
30
|
+
takes a host name as a single argument. The default is localhost.
|
31
|
+
|
32
|
+
The current time, users and load average are not included in this library
|
33
|
+
module, even though you may be used to seeing them with the command
|
34
|
+
line version of 'uptime'.
|
35
|
+
|
36
|
+
== Known Bugs
|
37
|
+
None that I am aware of. Please log any bugs you find on the project
|
38
|
+
website at http://www.rubyforge.org/projects/sysutils.
|
39
|
+
|
40
|
+
== Questions
|
41
|
+
"Doesn't Struct::Tms do this?" - No.
|
42
|
+
|
43
|
+
== License
|
44
|
+
Artistic 2.0
|
45
|
+
|
46
|
+
== Copyright
|
47
|
+
Copyright 2002-2010, Daniel J. Berger
|
48
|
+
|
49
|
+
All Rights Reserved. This module is free software. It may be used,
|
50
|
+
redistributed and/or modified under the same terms as Ruby itself.
|
51
|
+
|
52
|
+
== Warranty
|
53
|
+
This library is provided "as is" and without any express or
|
54
|
+
implied warranties, including, without limitation, the implied
|
55
|
+
warranties of merchantability and fitness for a particular purpose.
|
56
|
+
|
57
|
+
== Acknowledgements
|
58
|
+
Andrea Fazzi for help with the FFI version.
|
59
|
+
|
60
|
+
Mike Hall for help with the BSD side of things for the original C code.
|
61
|
+
|
62
|
+
Ola Eriksson, whose source code I shamelessly plagiarized to get a better
|
63
|
+
implementation for systems that have the utmpx.h header file for the
|
64
|
+
original C code.
|
65
|
+
|
66
|
+
== Author
|
67
|
+
Daniel J. Berger
|
data/Rakefile
CHANGED
@@ -1,87 +1,44 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
include
|
6
|
-
|
7
|
-
|
8
|
-
'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
spec.extra_rdoc_files << 'ext/sys/uptime.c'
|
46
|
-
end
|
47
|
-
|
48
|
-
Gem::Builder.new(spec).build
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "Install the sys-uptime library"
|
52
|
-
task :install => [:create] do
|
53
|
-
gem_name = Dir['*.gem'].first
|
54
|
-
sh "gem install #{gem_name}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
task :example => [:build] do
|
59
|
-
case Config::CONFIG['host_os']
|
60
|
-
when /windows|win32|cygwin|mingw|dos|mswin/
|
61
|
-
path = 'lib/windows'
|
62
|
-
when /linux/
|
63
|
-
path = 'lib/linux'
|
64
|
-
else
|
65
|
-
path = 'ext'
|
66
|
-
end
|
67
|
-
sh "ruby -I#{path} examples/sys_uptime_example.rb"
|
68
|
-
end
|
69
|
-
|
70
|
-
desc "Run the test suite"
|
71
|
-
Rake::TestTask.new("test") do |t|
|
72
|
-
task :test => :build
|
73
|
-
t.libs << 'test' << '.'
|
74
|
-
t.warning = true
|
75
|
-
t.verbose = true
|
76
|
-
|
77
|
-
case Config::CONFIG['host_os']
|
78
|
-
when /windows|win32|cygwin|mingw|dos|mswin/
|
79
|
-
t.libs << 'lib/windows'
|
80
|
-
when /linux/
|
81
|
-
t.libs << 'lib/linux'
|
82
|
-
else
|
83
|
-
t.libs << 'ext'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
task :default => :test
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc")
|
6
|
+
|
7
|
+
namespace 'gem' do
|
8
|
+
desc 'Build the sys-uptime gem'
|
9
|
+
task :create => [:clean] do
|
10
|
+
spec = eval(IO.read('sys-uptime.gemspec'))
|
11
|
+
|
12
|
+
if File::ALT_SEPARATOR
|
13
|
+
spec.require_paths = ['lib', 'lib/windows']
|
14
|
+
spec.platform = Gem::Platform::CURRENT
|
15
|
+
spec.platform.cpu = 'universal'
|
16
|
+
spec.platform.version = nil
|
17
|
+
else
|
18
|
+
spec.require_paths = ['lib', 'lib/unix']
|
19
|
+
spec.add_dependency('ffi', '>= 1.0.0')
|
20
|
+
end
|
21
|
+
|
22
|
+
Gem::Builder.new(spec).build
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Install the sys-uptime gem'
|
26
|
+
task :install => [:build] do
|
27
|
+
file = Dir["*.gem"].first
|
28
|
+
sh "gem install #{file}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Run the test suite"
|
33
|
+
Rake::TestTask.new do |t|
|
34
|
+
if File::ALT_SEPARATOR
|
35
|
+
t.libs << 'lib/windows'
|
36
|
+
else
|
37
|
+
t.libs << 'lib/unix'
|
38
|
+
end
|
39
|
+
|
40
|
+
t.warning = true
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :test
|
@@ -1,21 +1,21 @@
|
|
1
|
-
###########################################################
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# A generic test script for general futzing. You can run
|
5
|
-
# this script via the 'rake example' task.
|
6
|
-
###########################################################
|
7
|
-
require 'sys/uptime'
|
8
|
-
include Sys
|
9
|
-
|
10
|
-
print "\nGENERIC TEST SCRIPT FOR SYS-UPTIME\n\n"
|
11
|
-
puts 'VERSION: ' + Uptime::VERSION
|
12
|
-
|
13
|
-
puts "Days: " + Uptime.days.to_s
|
14
|
-
puts "Hours: " + Uptime.hours.to_s
|
15
|
-
puts "Minutes: " + Uptime.minutes.to_s
|
16
|
-
puts "Seconds: " + Uptime.seconds.to_s
|
17
|
-
puts "Uptime: " + Uptime.uptime
|
18
|
-
puts "DHMS: " + Uptime.dhms.join(', ')
|
19
|
-
puts "Boot Time: " + Uptime.boot_time.to_s
|
20
|
-
|
21
|
-
print "\nTest successful\n"
|
1
|
+
###########################################################
|
2
|
+
# uptime_test.rb
|
3
|
+
#
|
4
|
+
# A generic test script for general futzing. You can run
|
5
|
+
# this script via the 'rake example' task.
|
6
|
+
###########################################################
|
7
|
+
require 'sys/uptime'
|
8
|
+
include Sys
|
9
|
+
|
10
|
+
print "\nGENERIC TEST SCRIPT FOR SYS-UPTIME\n\n"
|
11
|
+
puts 'VERSION: ' + Uptime::VERSION
|
12
|
+
|
13
|
+
puts "Days: " + Uptime.days.to_s
|
14
|
+
puts "Hours: " + Uptime.hours.to_s
|
15
|
+
puts "Minutes: " + Uptime.minutes.to_s
|
16
|
+
puts "Seconds: " + Uptime.seconds.to_s
|
17
|
+
puts "Uptime: " + Uptime.uptime
|
18
|
+
puts "DHMS: " + Uptime.dhms.join(', ')
|
19
|
+
puts "Boot Time: " + Uptime.boot_time.to_s
|
20
|
+
|
21
|
+
print "\nTest successful\n"
|