Skip to content

Commit

Permalink
! Adapting to the new logfile output
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Werschlein committed Apr 20, 2011
1 parent 4123bdc commit 7e69e6f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 31 deletions.
2 changes: 1 addition & 1 deletion last_puppetrun
Expand Up @@ -46,7 +46,7 @@ class PuppetRuns
# extracts the host name from that. Otherwise returns nil.
#
def parse_last_run(str)
if md=str.match(/puppet puppetmasterd\[\d+\]: Compiled catalog for (.+) in .* seconds/)
if md=str.match(/puppet puppet-master\[\d+\]: Compiled catalog for (.+) in environment \w+ in .* seconds/)
md.captures.first
end
end
Expand Down
45 changes: 29 additions & 16 deletions spec/fixtures/syslog
@@ -1,16 +1,29 @@
Jan 25 15:40:05 puppet puppetmasterd[884]: Compiled catalog for elara.example.com in 0.20 seconds
Jan 25 15:40:13 puppet puppetmasterd[884]: Compiled catalog for keskonrix.example.com in 0.13 seconds
Jan 25 15:40:40 puppet puppetmasterd[907]: Compiled catalog for ls2.example.com in 0.25 seconds
Jan 25 15:40:57 puppet puppetmasterd[838]: Compiled catalog for mimas.example.com in 1.60 seconds
Jan 25 15:41:03 puppet puppetmasterd[838]: Compiled catalog for neso.example.com in 0.07 seconds
Jan 25 15:41:37 puppet puppetd[15852]: Retrieving plugin
Jan 25 15:41:41 puppet puppetmasterd[907]: Compiled catalog for puppet.example.com in 1.54 seconds
Jan 25 15:41:41 puppet puppetd[15852]: Caching catalog for puppet.example.com
Jan 25 15:41:44 puppet puppetd[15852]: Applying configuration version '1264430500'
Jan 25 15:41:48 puppet puppetd[15852]: Finished catalog run in 5.29 seconds
Jan 25 15:41:50 puppet puppetmasterd[884]: Compiled catalog for hyperion.example.com in 1.45 seconds
Jan 25 15:41:51 puppet puppetmasterd[838]: Compiled catalog for kale.example.com in 0.18 seconds
Jan 25 15:42:57 puppet puppetmasterd[884]: Compiled catalog for deimos.example.com in 0.29 seconds
Jan 25 15:43:14 puppet puppetmasterd[907]: Compiled catalog for gironimo.example.com in 0.14 seconds
Jan 25 15:43:24 puppet puppetmasterd[861]: Compiled catalog for mimas.example.com in 1.94 seconds
Jan 25 15:44:19 puppet puppetmasterd[838]: Compiled catalog for mimas.example.com in 0.27 seconds
Apr 20 17:27:44 puppet puppet-master[13903]: Compiled catalog for ls0.example.com in environment production in 1.15 seconds
Apr 20 16:48:55 puppet puppet-master[14006]: Reparsing /etc/puppet/puppet.conf
Apr 20 16:48:55 puppet puppet-master[14006]: You have configuration parameter $report specified in [puppetd], which is a deprecated section. I'm assuming you meant [agent]
Apr 20 16:48:55 puppet puppet-master[13903]: Compiled catalog for puppet.example.com in environment production in 3.09 seconds
Apr 20 16:48:56 puppet puppet-agent[14755]: Caching catalog for puppet.example.com
Apr 20 16:48:56 puppet puppet-master[14027]: Reparsing /etc/puppet/puppet.conf
Apr 20 16:48:56 puppet puppet-master[14027]: You have configuration parameter $report specified in [puppetd], which is a deprecated section. I'm assuming you meant [agent]
Apr 20 16:48:57 puppet puppet-agent[14755]: (/User[foo]) Provider useradd does not support features manages_passwords; not managing attribute password
Apr 20 16:48:57 puppet puppet-agent[14755]: (/User[bar]) Provider useradd does not support features manages_passwords; not managing attribute password
Apr 20 16:48:58 puppet puppet-agent[14755]: Applying configuration version '1303310934'
Apr 20 16:48:58 puppet puppet-master[14049]: Reparsing /etc/puppet/puppet.conf
Apr 20 16:48:58 puppet puppet-master[14049]: You have configuration parameter $report specified in [puppetd], which is a deprecated section. I'm assuming you meant [agent]
Apr 20 16:49:02 puppet puppet-agent[14755]: Finished catalog run in 5.03 seconds
Apr 20 16:49:15 puppet puppet-master[14006]: Unrecognised escape sequence '\;' in file /etc/puppet/manifests/classes/storage.pp at line 66
Apr 20 16:49:17 puppet puppet-master[14006]: Compiled catalog for thor.example.com in environment production in 2.46 seconds
Apr 20 16:49:37 puppet puppet-master[14027]: Unrecognised escape sequence '\;' in file /etc/puppet/manifests/classes/storage.pp at line 66
Apr 20 16:49:39 puppet puppet-master[14027]: Compiled catalog for spike.example.com in environment production in 2.47 seconds
Apr 20 16:49:40 puppet puppet-master[14006]: DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module 's_nagios' when no
0.24.x clients are present
Apr 20 16:49:55 puppet puppet-master[14027]: Compiled catalog for ls6.example.com in environment production in 0.63 seconds
Apr 20 16:51:09 puppet puppet-master[14049]: Denying access: Forbidden request: esa-cci.example.com(192.168.176.23) access to /file_metadata/plugins [search] at line 0
Apr 20 16:51:09 puppet puppet-master[14049]: Forbidden request: esa-cci.example.com(192.168.176.23) access to /file_metadata/plugins [search] at line 0
Apr 20 16:51:09 puppet puppet-master[14027]: Denying access: Forbidden request: esa-cci.example.com(192.168.176.23) access to /file_metadata/plugins [find] at line 0
Apr 20 16:51:09 puppet puppet-master[14027]: Forbidden request: esa-cci.example.com(192.168.176.23) access to /file_metadata/plugins [find] at line 0
Apr 20 16:51:11 puppet puppet-master[14006]: Denying access: Forbidden request: esa-cci.example.com(192.168.176.23) access to /catalog/esa-cci.example.com [find] at line 0
Apr 20 16:51:11 puppet puppet-master[14006]: Forbidden request: esa-cci.example.com(192.168.176.23) access to /catalog/esa-cci.example.com [find] at line 0
Apr 20 16:51:35 puppet puppet-master[13963]: Unrecognised escape sequence '\;' in file /etc/puppet/manifests/classes/storage.pp at line 66
Apr 20 16:51:37 puppet puppet-master[13963]: Compiled catalog for ls16.example.com in environment production in 2.65 seconds
Apr 20 16:51:44 puppet puppet-master[14006]: Compiled catalog for gardener.example.com in environment production in 0.71 seconds
28 changes: 14 additions & 14 deletions spec/unit/last_puppetrun_spec.rb
Expand Up @@ -19,7 +19,7 @@ def fixture(name)
attr_reader :return_value
before(:each) do
flexmock(instance, :run =>
"+ amaltheo.geo.uzh.ch (D6:1A:1B:37:C0:C9:63:14:19:CE:10:C5:B7:92:DA:2B)\n+ anthex.geo.uzh.ch (16:46:55:D2:FD:E7:FE:3D:41:CD:C3:AC:C4:E4:47:4F)\n+ arcsda.geo.uzh.ch (EF:41:9C:93:B3:E9:DE:44:56:56:F0:12:E5:63:F3:29)\n+ bbs.geo.uzh.ch (0A:C4:48:A6:80:41:CB:9B:35:BA:5A:54:24:75:91:32)\n+ beanstalker.geo.uzh.ch (A5:25:0D:53:D6:97:CF:E4:8E:A1:AF:8F:6B:F2:8A:42)\n+ belly.geo.uzh.ch (AD:A6:3A:10:EA:F1:9F:46:A6:88:F4:79:2D:59:C2:F5)\n"
"+ amaltheo.example.com (D6:1A:1B:37:C0:C9:63:14:19:CE:10:C5:B7:92:DA:2B)\n+ anthex.example.com (16:46:55:D2:FD:E7:FE:3D:41:CD:C3:AC:C4:E4:47:4F)\n+ arcsda.example.com (EF:41:9C:93:B3:E9:DE:44:56:56:F0:12:E5:63:F3:29)\n+ bbs.example.com (0A:C4:48:A6:80:41:CB:9B:35:BA:5A:54:24:75:91:32)\n+ beanstalker.example.com (A5:25:0D:53:D6:97:CF:E4:8E:A1:AF:8F:6B:F2:8A:42)\n+ belly.example.com (AD:A6:3A:10:EA:F1:9F:46:A6:88:F4:79:2D:59:C2:F5)\n"
)

@return_value = instance.controlled_hosts
Expand All @@ -28,11 +28,11 @@ def fixture(name)
it "should be a list" do
return_value.should be_an_instance_of(Array)
end
it "should include 'anthex.geo.uzh.ch'" do
return_value.should include('anthex.geo.uzh.ch')
it "should include 'anthex.example.com'" do
return_value.should include('anthex.example.com')
end
it "should include 'belly.geo.uzh.ch'" do
return_value.should include('belly.geo.uzh.ch')
it "should include 'belly.example.com'" do
return_value.should include('belly.example.com')
end
end
describe "#each_log_line yields" do
Expand All @@ -48,8 +48,8 @@ def fixture(name)

it "should yield each line of the log with a timestamp" do
yields.should include([
Time.parse('Jan 25 15:41:50'),
'puppet puppetmasterd[884]: Compiled catalog for hyperion.example.com in 1.45 seconds'])
Time.parse('Apr 20 16:49:39'),
'puppet puppet-master[14027]: Compiled catalog for spike.example.com in environment production in 2.47 seconds'])
end
end
describe "#each_successful_run yields" do
Expand All @@ -59,15 +59,15 @@ def fixture(name)

flexmock(instance).
should_receive(:each_log_line).
and_yield([Time.now, 'puppet puppetmasterd[884]: Compiled catalog for hyperion.geo.uzh.ch in 1.45 seconds']).
and_yield([Time.now, "puppet puppetd[15852]: (//Node[ubuntu]/Service[ssh]) Failed to call refresh on Service[ssh]: Could not stop Service[ssh]: Execution of '/etc/init.d/ssh stop' returned 1: at /etc/puppet/manifests/templates/ubuntu.pp:48"])

and_yield([Time.now, 'puppet puppet-master[14006]: Compiled catalog for fooservices.example.com in environment production in 0.70 seconds']).
and_yield([Time.now, "puppet puppetd[15852]: (//Node[ubuntu]/Service[ssh]) Failed to call refresh on Service[ssh]: Could not stop Service[ssh]: Execution of '/etc/init.d/ssh stop' returned 1: at /etc/puppet/manifests/templates/ubuntu.pp:48"]).
and_yield([Time.now, "puppet puppet-agent[14755]: Caching catalog for puppet.example.com"])
@runs = []
instance.each_successful_run { |stuff| @runs << stuff }
end

it "should include hyperion" do
runs.map { |(ts,host)| host }.should include('hyperion.geo.uzh.ch')
it "should include fooservices" do
runs.map { |(ts,host)| host }.should include('fooservices.example.com')
end
end

Expand All @@ -78,8 +78,8 @@ def fixture(name)
instance.parse_logfile
end

it "should initialize last_run('mimas.geo.uzh.ch')" do
instance.last['elara.example.com'].should_not be_nil
it "should initialize last_run('thor.example.com')" do
instance.last['thor.example.com'].should_not be_nil
end
end
end
Expand Down

0 comments on commit 7e69e6f

Please sign in to comment.