facter 1.1.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +63 -0
- data/COPYING +416 -251
- data/Rakefile +30 -277
- data/bin/facter +60 -7
- data/install.rb +303 -289
- data/lib/facter.rb +280 -137
- data/lib/facter/memory.rb +62 -0
- data/lib/facter/processor.rb +52 -0
- metadata +32 -34
- data/CHANGES +0 -21
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# memory.rb
|
3
|
+
# Additional Facts for memory/swap usage
|
4
|
+
#
|
5
|
+
# Copyright (C) 2006 Mooter Media Ltd
|
6
|
+
# Author: Matthew Palmer <matt@solutionsfirst.com.au>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or
|
9
|
+
# modify it under the terms of the GNU General Public License
|
10
|
+
# as published by the Free Software Foundation (version 2 of the License)
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
|
18
|
+
|
19
|
+
module Facter::Memory
|
20
|
+
require 'thread'
|
21
|
+
|
22
|
+
def self.meminfo_number(tag)
|
23
|
+
memsize = ""
|
24
|
+
Thread::exclusive do
|
25
|
+
File.readlines("/proc/meminfo").each do |l|
|
26
|
+
if l =~ /^#{tag}:\s+(\d+)\s+(\S+)/
|
27
|
+
memsize = scale_number($1.to_f, $2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
memsize
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.scale_number(size, multiplier)
|
36
|
+
suffixes = ['', 'kB', 'MB', 'GB', 'TB']
|
37
|
+
|
38
|
+
s = suffixes.shift
|
39
|
+
while s != multiplier
|
40
|
+
s = suffixes.shift
|
41
|
+
end
|
42
|
+
|
43
|
+
while size > 1024.0
|
44
|
+
size /= 1024.0
|
45
|
+
s = suffixes.shift
|
46
|
+
end
|
47
|
+
|
48
|
+
return "%.2f %s" % [size, s]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
{:MemorySize => "MemTotal",
|
53
|
+
:MemoryFree => "MemFree",
|
54
|
+
:SwapSize => "SwapTotal",
|
55
|
+
:SwapFree => "SwapFree"}.each do |fact, name|
|
56
|
+
Facter.add(fact) do
|
57
|
+
confine :kernel => :linux
|
58
|
+
setcode do
|
59
|
+
Facter::Memory.meminfo_number(name)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# processor.rb
|
3
|
+
# Additional Facts about the machine's CPUs
|
4
|
+
#
|
5
|
+
# Copyright (C) 2006 Mooter Media Ltd
|
6
|
+
# Author: Matthew Palmer <matt@solutionsfirst.com.au>
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# This program is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU General Public License
|
11
|
+
# as published by the Free Software Foundation (version 2 of the License)
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'thread'
|
22
|
+
|
23
|
+
if Facter.kernel == "Linux"
|
24
|
+
processor_num = -1
|
25
|
+
processor_list = []
|
26
|
+
Thread::exclusive do
|
27
|
+
File.readlines("/proc/cpuinfo").each do |l|
|
28
|
+
if l =~ /processor\s+:\s+(\d+)/
|
29
|
+
processor_num = $1.to_i
|
30
|
+
elsif l =~ /model name\s+:\s+(.*)\s*$/
|
31
|
+
processor_list[processor_num] = $1 unless processor_num == -1
|
32
|
+
processor_num = -1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Facter.add("ProcessorCount") do
|
38
|
+
confine :kernel => :linux
|
39
|
+
setcode do
|
40
|
+
processor_list.length.to_s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
processor_list.each_with_index do |desc, i|
|
45
|
+
Facter.add("Processor#{i}") do
|
46
|
+
confine :kernel => :linux
|
47
|
+
setcode do
|
48
|
+
desc
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -3,57 +3,55 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: facter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2006-
|
6
|
+
version: 1.3.3
|
7
|
+
date: 2006-06-28 00:00:00 -05:00
|
8
8
|
summary: Facter collects Operating system facts.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: dev@reductivelabs.com
|
12
12
|
homepage: http://reductivelabs.com/projects/facter
|
13
|
-
rubyforge_project:
|
13
|
+
rubyforge_project: facter
|
14
14
|
description: Facter is a module for collecting simple facts about a host Operating system.
|
15
15
|
autorequire:
|
16
16
|
default_executable: facter
|
17
17
|
bindir: bin
|
18
|
-
has_rdoc:
|
18
|
+
has_rdoc: false
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
27
26
|
signing_key:
|
28
27
|
cert_chain:
|
29
28
|
authors:
|
30
|
-
|
29
|
+
-
|
31
30
|
files:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
- install.rb
|
32
|
+
- TODO
|
33
|
+
- LICENSE
|
34
|
+
- Rakefile
|
35
|
+
- README
|
36
|
+
- CHANGELOG
|
37
|
+
- INSTALL
|
38
|
+
- COPYING
|
39
|
+
- bin/facter
|
40
|
+
- lib/facter.rb
|
41
|
+
- lib/facter/processor.rb
|
42
|
+
- lib/facter/memory.rb
|
43
|
+
- etc/facter.conf
|
43
44
|
test_files: []
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
- "--line-numbers"
|
50
|
-
extra_rdoc_files:
|
51
|
-
- README
|
52
|
-
- LICENSE
|
53
|
-
- TODO
|
54
|
-
- CHANGES
|
45
|
+
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
extra_rdoc_files: []
|
49
|
+
|
55
50
|
executables:
|
56
|
-
|
51
|
+
- facter
|
57
52
|
extensions: []
|
53
|
+
|
58
54
|
requirements: []
|
59
|
-
|
55
|
+
|
56
|
+
dependencies: []
|
57
|
+
|
data/CHANGES
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
1.1.1:
|
2
|
-
Fixed a bug that occurs when you ask for the value of an unregistered
|
3
|
-
fact.
|
4
|
-
|
5
|
-
1.1.0:
|
6
|
-
Added support for OpenBSD (and probably NetBSD and FreeBSD), and significantly
|
7
|
-
refactored (heh) how facts and resolution mechanisms are added.
|
8
|
-
|
9
|
-
1.0.2:
|
10
|
-
Added SuSE distro
|
11
|
-
Added initial support for Cygwin, thanks to contributions from Eric Sorenson
|
12
|
-
|
13
|
-
1.0.1:
|
14
|
-
Added 'id' fact, which basically returns 'whoami'.
|
15
|
-
|
16
|
-
1.0:
|
17
|
-
Rewrote entirely. It's much simpler to use, and now supports
|
18
|
-
adding new fact resolution mechanisms at run-time.
|
19
|
-
|
20
|
-
1.0b1:
|
21
|
-
Initial release.
|