Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from github/servers_info

expose information about name and ntp servers
  • Loading branch information...
commit 577cdd42fbc0cb9225e0b6062b6486813bce65e6 2 parents 3dd7280 + 91a5128
David Calavera authored
View
2  enterprise-ohai.gemspec
@@ -2,7 +2,7 @@ dir = File.dirname(__FILE__)
Gem::Specification.new do |s|
s.name = 'enterprise-ohai'
- s.version = '0.1.7'
+ s.version = '0.1.8'
s.summary = s.description = 'Ohai plugins for enterprise.'
s.authors = %w[GitHub]
View
12 lib/enterprise/ohai/plugins/linux/ntp.rb
@@ -0,0 +1,12 @@
+provides 'ntp'
+
+ntp_config_file = '/etc/ntp.conf'
+
+ntp_config = Mash.new
+
+if File.exists?(ntp_config_file)
+ lines = File.readlines(ntp_config_file)
+ ntp_config[:servers] = lines.grep(/^server/).map {|l| l.split(" ").last }
+end
+
+ntp ntp_config
View
13 lib/enterprise/ohai/plugins/linux/resolv.rb
@@ -0,0 +1,13 @@
+provides 'resolv'
+
+resolv_config_file = '/etc/resolv.conf'
+ip = %r{((?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5]))}
+
+resolv_config = Mash.new
+
+if File.exist?(resolv_config_file)
+ lines = File.readlines(resolv_config_file)
+ resolv_config[:name_servers] = lines.grep(/^nameserver #{ip}$/).map {|l| l[ip, 1] }
+end
+
+resolv resolv_config
Please sign in to comment.
Something went wrong with that request. Please try again.