onering-report-plugins 0.0.3 → 0.0.4

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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-report-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: onering-client
16
- requirement: &16602500 !ruby/object:Gem::Requirement
16
+ requirement: &9959140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16602500
24
+ version_requirements: *9959140
25
25
  description: Base plugins for providing system information via the Onering client
26
26
  utility
27
27
  email: ghetzel@outbrain.com
@@ -30,7 +30,6 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
  files:
32
32
  - lib/facter/onering_properties_network.rb
33
- - lib/facter/onering_properties_netstat.rb
34
33
  - lib/facter/onering_properties_services.rb
35
34
  - lib/facter/onering_properties_chef.rb
36
35
  - lib/facter/onering_properties_physical.rb
@@ -1,86 +0,0 @@
1
- require 'resolv'
2
-
3
- protocols = %w{tcp}
4
-
5
- flags = "--numeric-hosts --numeric-ports --programs --tcp -ee"
6
-
7
- case Facter.value('osfamily').to_s.downcase
8
- when 'debian' then flags += " -W"
9
- when 'redhat' then flags += " -T"
10
- end
11
-
12
- listening = Facter::Util::Resolution.exec("netstat #{flags} -l | tr -s ' '")
13
- nonlistening = Facter::Util::Resolution.exec("netstat #{flags} | tr -s ' '")
14
-
15
- netstat = {
16
- 'listening' => [],
17
- 'connections' => []
18
- }
19
-
20
- def getcommandline(pid)
21
- return nil unless pid.to_i > 0
22
- (File.read("/proc/#{pid}/cmdline").to_s.strip.chomp.squeeze("\u0000").squeeze("\0").gsub("\u0000", ' ').gsub("\0", ' '))
23
- end
24
-
25
- listening.lines.to_a[2..-1].each do |line|
26
- protocol, recvq, sendq, local, foreign, state, user, inode, program = line.split(' ', 9)
27
- next unless protocols.include?(protocol)
28
-
29
- local = local.split(':')
30
- foreign = foreign.split(':')
31
- local_host = local[-2]
32
- local_port = local[-1]
33
- foreign_host = foreign[-2]
34
- foreign_port = foreign[-1]
35
- pid = program.split('/').first
36
-
37
- netstat['listening'] << {
38
- "protocol" => protocol,
39
- "address" => local_host,
40
- "fqdn" => (Resolv.getname(local_host) rescue nil),
41
- "port" => local_port.to_i,
42
- "user" => user,
43
- "program" => {
44
- "pid" => pid.to_i,
45
- "command" => getcommandline(pid)
46
- }
47
- }
48
- end
49
-
50
- nonlistening.lines.to_a[2..-1].each do |line|
51
- protocol, recvq, sendq, local, foreign, state, user, inode, program = line.split(' ', 9)
52
- next unless protocols.include?(protocol)
53
-
54
- local = local.split(':')
55
- foreign = foreign.split(':')
56
- local_host = local[-2]
57
- local_port = local[-1]
58
- foreign_host = foreign[-2]
59
- foreign_port = foreign[-1]
60
- pid = program.split('/').first
61
-
62
- netstat['connections'] << {
63
- "protocol" => protocol,
64
- "from" => {
65
- "address" => local_host,
66
- "port" => local_port.to_i
67
- },
68
- "to" => {
69
- "address" => foreign_host,
70
- "fqdn" => (Resolv.getname(foreign_host) rescue nil),
71
- "port" => foreign_port.to_i
72
- },
73
- "user" => user,
74
- "state" => state.downcase,
75
- "program" => {
76
- "pid" => pid.to_i,
77
- "command" => getcommandline(pid)
78
- }
79
- }
80
- end
81
-
82
- Facter.add("netstat") do
83
- setcode do
84
- netstat
85
- end
86
- end