Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
puppetlabs/mcollective-puppet-agent
LabattFoodService/mcollective-puppet-agent
LorcanHamill/mcollective-puppet-agent
MikaelSmith/mcollective-puppet-agent
Mischrantier/mcollective-puppet-agent
MosesMendoza/mcollective-puppet-agent
UcasRichard/mcollective-puppet-agent
abhaychrungoo/mcollective-puppet-agent
alexjfisher/mcollective-puppet-agent
andersonmills/mcollective-puppet-agent
beergeek/mcollective-puppet-agent
bennysan/mcollective-puppet-agent
bluemutedwisdom/mcollective-puppet-agent
byronsanchez/mcollective-puppet-agent
clantant/mcollective-puppet-agent
clemensw/mcollective-puppet-agent
gtmtechltd/mcollective-puppet-agent
jantman/mcollective-puppet-agent
jhg03a/mcollective-puppet-agent
jinjin123/mcollective-puppet-agent
jlambert121/mcollective-puppet-agent
joshcooper/mcollective-puppet-agent
liavkoren/mcollective-puppet-agent
llowder/mcollective-puppet-agent
m4ce/mcollective-puppet-agent
masterzen/mcollective-puppet-agent
melissa/mcollective-puppet-agent
mruzicka/mcollective-puppet-agent
mrzarquon/mcollective-puppet-agent
msutter/mcollective-puppet-agent
nicklewis/mcollective-puppet-agent
nmunagala/mcollective-puppet-agent
olivierHa/mcollective-puppet-agent
optionalg/mcollective-puppet-agent
parisiale/mcollective-puppet-agent
pdcleyn/mcollective-puppet-agent
ploubser/mcollective-puppet-agent
raphink/mcollective-puppet-agent
reidmv/mcollective-puppet-agent
richardc/mcollective-puppet-agent
saikatbanerji/mcollective-puppet-agent
shance3c/mcollective-puppet-agent
slseed1969/mcollective-puppet-agent
spandeyindia/mcollective-puppet-agent
srinivas-adivi/mcollective-puppet-agent
tczekajlo/mcollective-puppet-agent
trevor-vaughan/mcollective-puppet-agent
underscorgan/mcollective-puppet-agent
ygindin1/mcollective-puppet-agent
yo61/mcollective-puppet-agent
Nothing to show
Choose a base branch
Nothing to show
Choose a Head Repository
puppetlabs/mcollective-puppet-agent
LabattFoodService/mcollective-puppet-agent
LorcanHamill/mcollective-puppet-agent
MikaelSmith/mcollective-puppet-agent
Mischrantier/mcollective-puppet-agent
MosesMendoza/mcollective-puppet-agent
UcasRichard/mcollective-puppet-agent
abhaychrungoo/mcollective-puppet-agent
alexjfisher/mcollective-puppet-agent
andersonmills/mcollective-puppet-agent
beergeek/mcollective-puppet-agent
bennysan/mcollective-puppet-agent
bluemutedwisdom/mcollective-puppet-agent
byronsanchez/mcollective-puppet-agent
clantant/mcollective-puppet-agent
clemensw/mcollective-puppet-agent
gtmtechltd/mcollective-puppet-agent
jantman/mcollective-puppet-agent
jhg03a/mcollective-puppet-agent
jinjin123/mcollective-puppet-agent
jlambert121/mcollective-puppet-agent
joshcooper/mcollective-puppet-agent
liavkoren/mcollective-puppet-agent
llowder/mcollective-puppet-agent
m4ce/mcollective-puppet-agent
masterzen/mcollective-puppet-agent
melissa/mcollective-puppet-agent
mruzicka/mcollective-puppet-agent
mrzarquon/mcollective-puppet-agent
msutter/mcollective-puppet-agent
nicklewis/mcollective-puppet-agent
nmunagala/mcollective-puppet-agent
olivierHa/mcollective-puppet-agent
optionalg/mcollective-puppet-agent
parisiale/mcollective-puppet-agent
pdcleyn/mcollective-puppet-agent
ploubser/mcollective-puppet-agent
raphink/mcollective-puppet-agent
reidmv/mcollective-puppet-agent
richardc/mcollective-puppet-agent
saikatbanerji/mcollective-puppet-agent
shance3c/mcollective-puppet-agent
slseed1969/mcollective-puppet-agent
spandeyindia/mcollective-puppet-agent
srinivas-adivi/mcollective-puppet-agent
tczekajlo/mcollective-puppet-agent
trevor-vaughan/mcollective-puppet-agent
underscorgan/mcollective-puppet-agent
ygindin1/mcollective-puppet-agent
yo61/mcollective-puppet-agent
Nothing to show
Choose a head branch
Nothing to show
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jan 06, 2017
(MCOP-580) Improve last_run_summary logs output
This improves the logs output from last_run_summary by adding details
about the logs such as time, source etc.

The old output was considered largely pointless and we decided to make
a breaking change to improve things.  The old 'parse_log' input is
removed thus forcing code that relied on the old behaviour to fail
with a DDL error rather than later fail in weird ways when the data format
has changed
Merge pull request #72 from ripienaar/580
(MCOP-580) Improve last_run_summary logs output
Showing with 43 additions and 36 deletions.
  1. +2 −2 agent/puppet.ddl
  2. +1 −1 agent/puppet.rb
  3. +2 −2 spec/agent/puppet_agent_spec.rb
  4. +1 −1 spec/spec_helper.rb
  5. +22 −20 spec/util/puppet_agent_mgr_spec.rb
  6. +15 −10 util/puppet_agent_mgr.rb
View
@@ -83,9 +83,9 @@ end
action "last_run_summary", :description => "Get the summary of the last Puppet run" do
display :always
input :parse_log,
input :logs,
:description => "Whether or not to parse the logs from last_run_report.yaml",
:prompt => "Parse log from last_run_report.yaml?",
:prompt => "Parse log from last_run_report.yaml",
:optional => true,
:type => :boolean,
:default => false
View
@@ -87,7 +87,7 @@ def run(command, options)
action "last_run_summary" do
summary = @puppet_agent.load_summary
if request[:parse_log]
if request[:logs]
reply[:logs] = @puppet_agent.last_run_logs
else
reply[:logs] = {}
@@ -366,7 +366,7 @@
result[:data][:type_distribution].should == {"File" => 1, "Exec" => 2}
end
context 'parse_log' do
context 'logs' do
before :each do
@manager.stubs(:load_summary).returns({})
end
@@ -381,7 +381,7 @@
context 'true' do
it 'should call on last_run_logs' do
@manager.expects(:last_run_logs).once
@agent.call(:last_run_summary, :parse_log => true)
@agent.call(:last_run_summary, :logs => true)
end
end
end
View
@@ -32,7 +32,7 @@ def initialize_from_hash(data)
end
class Util;end
class Util::Log
attr_reader :level, :message
attr_reader :level, :message, :time, :source
@loglevel = 2
@levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit]
def self.level
@@ -288,7 +288,7 @@ module MCollective::Util
it "should return a default structure when no file is found" do
Puppet.expects(:[]).with(:lastrunreport).returns("lastrunreport")
@manager.last_run_logs.should == {}
expect(@manager.last_run_logs).to eq([])
end
it "should return log results if the file is found" do
@@ -297,15 +297,16 @@ module MCollective::Util
"last_run_report.yaml"))
Puppet.expects(:[]).with(:lastrunreport).returns(yamlfile).times(2..3)
@manager.last_run_logs.should \
== {"info" => ["Info level message"],
"err" => ["Err level message"],
"debug" => ["Debug level message"],
"warning" => ["Warning level message"],
"crit" => ["Crit level message"],
"alert" => ["Alert level message"],
"emerg" => ["Emerg level message"],
"notice" => ["Notice level message"]}
expect(@manager.last_run_logs).to eq([
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"notice", "source"=>"Puppet", "msg"=>"Notice level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"err", "source"=>"Puppet", "msg"=>"Err level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"warning", "source"=>"Puppet", "msg"=>"Warning level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"debug", "source"=>"Puppet", "msg"=>"Debug level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"crit", "source"=>"Puppet", "msg"=>"Crit level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"alert", "source"=>"Puppet", "msg"=>"Alert level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"info", "source"=>"Puppet", "msg"=>"Info level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"emerg", "source"=>"Puppet", "msg"=>"Emerg level message"}
])
end
end
@@ -828,7 +829,7 @@ module MCollective::Util
it "should return a default structure when no file is found" do
Puppet.expects(:[]).with(:lastrunreport).returns("lastrunreport")
@manager.last_run_logs.should == {}
expect(@manager.last_run_logs).to eq([])
end
it "should return log results if the file is found" do
@@ -837,15 +838,16 @@ module MCollective::Util
"last_run_report.yaml"))
Puppet.expects(:[]).with(:lastrunreport).returns(yamlfile).times(2..3)
@manager.last_run_logs.should \
== {"info" => ["Info level message"],
"err" => ["Err level message"],
"debug" => ["Debug level message"],
"warning" => ["Warning level message"],
"crit" => ["Crit level message"],
"alert" => ["Alert level message"],
"emerg" => ["Emerg level message"],
"notice" => ["Notice level message"]}
expect(@manager.last_run_logs).to eq([
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"notice", "source"=>"Puppet", "msg"=>"Notice level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"err", "source"=>"Puppet", "msg"=>"Err level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"warning", "source"=>"Puppet", "msg"=>"Warning level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"debug", "source"=>"Puppet", "msg"=>"Debug level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"crit", "source"=>"Puppet", "msg"=>"Crit level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"alert", "source"=>"Puppet", "msg"=>"Alert level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"info", "source"=>"Puppet", "msg"=>"Info level message"},
{"time_utc"=>1378216841, "time"=>1378216841, "level"=>"emerg", "source"=>"Puppet", "msg"=>"Emerg level message"}
])
end
end
View
@@ -124,18 +124,23 @@ def managed_resource_type_distribution
type_distribution
end
# loads the report file and returns log messages grouped by log levels
# Reads the last run report and extracts the log lines
#
# @return [Array<Hash>]
def last_run_logs
logs = {}
if File.exists?(Puppet[:lastrunreport])
report = YAML.load_file(Puppet[:lastrunreport])
levels = Puppet::Util::Log.levels
levels.each do |level|
logs[level.to_s] = report.logs.select {
|r| r.level == level }.map { |r| r.message.chomp }
end
return [] unless File.exists?(Puppet[:lastrunreport])
report = YAML.load_file(Puppet[:lastrunreport])
report.logs.map do |line|
{
"time_utc" => line.time.utc.to_i,
"time" => line.time.to_i,
"level" => line.level.to_s,
"source" => line.source,
"msg" => line.message.chomp
}
end
logs
end
# covert seconds to human readable string

No commit comments for this range