This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|