This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #2 from github/servers_info

expose information about name and ntp servers
  • Loading branch information...
2 parents 3dd7280 + 91a5128 commit 577cdd42fbc0cb9225e0b6062b6486813bce65e6 David Calavera committed Sep 20, 2012
View
@@ -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]
@@ -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
@@ -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

0 comments on commit 577cdd4

Please sign in to comment.