Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New data plugins

  • Loading branch information...
commit 4085831fd3f5c0ac54eeb812432be7c5a00b5a4d 1 parent 7c4a576
R.I.Pienaar authored
20 data/augeas_match/data/augeas_match_data.ddl
View
@@ -0,0 +1,20 @@
+metadata :name => "Augeas Match",
+ :description => "Allows agents and discovery to do Augeas match lookups",
+ :author => "R.I.Pienaar <rip@devco.net>",
+ :license => "Apache License, Version 2.0",
+ :version => "1.0",
+ :url => "http://marionette-collective.org/",
+ :timeout => 2
+
+dataquery :description => "Match data using Augeas" do
+ input :query,
+ :prompt => "Matcher",
+ :description => "Valid Augeas match expression",
+ :type => :string,
+ :validation => /.+/,
+ :maxlength => 50
+
+ output :size,
+ :description => "The amont of records matched",
+ :display_as => "Matched"
+end
14 data/augeas_match/data/augeas_match_data.rb
View
@@ -0,0 +1,14 @@
+module MCollective
+ module Data
+ class Augeas_match_data<Base
+ require 'augeas'
+
+ query do |what|
+ aug = Augeas.open
+
+ result[:size] = aug.match(what).size
+ end
+ end
+ end
+end
+
29 data/resource/data/resource_data.ddl
View
@@ -0,0 +1,29 @@
+metadata :name => "Puppet Managed Resources",
+ :description => "Information about Puppet managed resources",
+ :author => "R.I.Pienaar <rip@devco.net>",
+ :license => "ASL 2.0",
+ :version => "1.0",
+ :url => "http://marionette-collective.org/",
+ :timeout => 1
+
+dataquery :description => "Puppet Managed Resources" do
+ input :query,
+ :prompt => "Resource Name",
+ :description => "Valid resource name",
+ :type => :string,
+ :validation => /^.+$/,
+ :optional => true,
+ :maxlength => 120
+
+ output :managed,
+ :description => "Is the resource managed",
+ :display_as => "Managed"
+
+ output :count,
+ :description => "Total managed resources",
+ :display_as => "Count"
+
+ output :age,
+ :description => "Resources list age",
+ :display_as => "Age"
+end
23 data/resource/data/resource_data.rb
View
@@ -0,0 +1,23 @@
+module MCollective
+ module Data
+ class Resource_data<Base
+ activate_when { File.exist?("/var/lib/puppet/state/resources.txt") }
+
+ query do |resource|
+ resources = File.readlines("/var/lib/puppet/state/resources.txt").map {|l| l.chomp}
+ stat = File.stat("/var/lib/puppet/state/resources.txt")
+
+ if resource
+ result[:managed] = resources.include?(resource.downcase)
+ else
+ result[:managed] = false
+ end
+
+ result[:count] = resources.size
+ result[:age] = Time.now.to_i - stat.mtime.to_i
+ end
+ end
+ end
+end
+
+
20 data/sysctl/data/sysctl_data.ddl
View
@@ -0,0 +1,20 @@
+metadata :name => "Sysctl values",
+ :description => "Retrieve values for a given sysctl",
+ :author => "R.I.Pienaar <rip@devco.net>",
+ :license => "ASL 2.0",
+ :version => "1.0",
+ :url => "http://marionette-collective.org/",
+ :timeout => 1
+
+dataquery :description => "Sysctl values" do
+ input :query,
+ :prompt => "Variable Name",
+ :description => "Valid Variable Name",
+ :type => :string,
+ :validation => /^[\w\-\.]+$/,
+ :maxlength => 120
+
+ output :value,
+ :description => "Kernel Parameter Value",
+ :display_as => "Value"
+end
25 data/sysctl/data/sysctl_data.rb
View
@@ -0,0 +1,25 @@
+module MCollective
+ module Data
+ class Sysctl_data<Base
+ activate_when { File.exist?("/sbin/sysctl") }
+
+ query do |sysctl|
+ shell = Shell.new("/sbin/sysctl %s" % sysctl)
+ shell.runcommand
+
+ if shell.status.exitstatus == 0
+ value = shell.stdout.chomp.split(/\s*=\s*/)[1]
+
+ if value
+ value = Integer(value) if value =~ /^\d+$/
+ value = Float(value) if value =~ /^\d+\.\d+$/
+
+ result[:value] = value
+ end
+ end
+ end
+ end
+ end
+end
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.