puppet -v /path/to/manifest.pp | logger -t puppet
And then we're using a splunk-alike to run ad-hon reports on the
logs.
* Tim Lank <timlank at timlank.com> [2010/09/24 06:52]:
> I'm trying to find a way to obtain the stdout (and stderr) output
> from individual puppet client configuration runs. I'd like a
> central storage of this information if possible.
--
Patrick's Law:
The permanence of a temporary solution rises in proportion with the
urgency of its initial implementation.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thanks. Can you elaborate on the puppet's reports? All I see are here: http://docs.puppetlabs.com/references/latest/report.html
Is there one that reports on the stdout&stderr of the tasks the client performs? (and not in YAML)
The remote syslog would take some coding to cull together in a coherent and readable manner for each individual client.
I believe we have a patch that should show the stderr output when an
exec task fails, but I'm curious as to why you want the stdout?
--
nigel
I understand wanting to know why an exec failed, but what are some
actual use cases where you care about the stdout of an exec resource
in Puppet?
>
> Please provide the patch# you are referring to for the on_failure stderr.
http://projects.puppetlabs.com/issues/2359 covers it.
in case this will help someone else besides me....
I've developed a simple mini-script system that can be setup on a
puppetmaster to send the stdout of the last reports for each client to
a set of email addresses. I find it convenient to get these results
in my inbox so that I can view them at a glance, review at leisure,
forward on, cut & paste elsewhere, etc...
recommendations, suggestions, comments welcome. Please improve this
and let me know what you did. If I've unknowingly re-invented
something that exists, please let me know that also.
1. /usr/local/bin/mailpuprpt (takes as a parameter a comma
separated list of email addresses & calls /usr/local/bin/getpupoutput
- performs mailing of the final summary report)
2. /usr/local/bin/getpupoutput (processes the last report file for
each client, pulls the line-oriented "message:" fields out except the
confirmation, replaces ecaped tabs with actual tabs, and calls
/usr/local/bin/reconstructstdout.pl)
3. /usr/local/bin/reconstructstdout.pl (returns the cleaned stdout -
not including puppet-added quotation marks, and replacing
puppet-escaped quotations with actual quotation marks)
1. /usr/local/bin/mailpuprpt
#!/bin/bash
die () {
echo -e "\nusage: mailpuprpt [comma separated email list]"
echo "example: mailpuprpt some...@somewhere.com,some...@somewhere.com"
exit 1
}
[ "$#" -eq 1 ] || die
/usr/local/bin/getpupoutput | mailx -s "puppet report `date`" $1
2. /usr/local/bin/getpupoutput
#!/bin/bash
REPORTDIR=/var/lib/puppet/reports
RECONSTRUCTSCRIPT=/usr/local/bin/reconstructstdout.pl
RAWPUPOUTPUT=/tmp/rawpupoutput.tmp
RECONSTRUCTEDSTDOUT=/tmp/reconstructedstdout.tmp
for i in `ls $REPORTDIR`
do
LASTREPORT=`ls -tr $REPORTDIR/$i | tail -1`
RUNTIME=`grep "time: " $REPORTDIR/$i/$LASTREPORT | tail -1 | cut -c8-`
echo -e "______________________________"
echo -e "$i $LASTREPORT $RUNTIME\n"
grep "message: " $REPORTDIR/$i/$LASTREPORT | grep -v "executed
successfully" | cut -c16- > $RAWPUPOUTPUT
$RECONSTRUCTSCRIPT
/bin/sed 's:\\t:\t:g' $RECONSTRUCTEDSTDOUT
done
3. /usr/local/bin/reconstructstdout.pl
#!/usr/bin/perl
open(RAW, "/tmp/rawpupoutput.tmp");
open(RECONSTRUCTED, ">/tmp/reconstructedstdout.tmp");
while (<RAW>) {
$line = $_;
@column = split //, $line;
$lastcol = ($#column - 1);
if (("$column[0]" eq "\"") && ("$column[$lastcol]" eq "\"")) {
my $colcounter = 1;
while ($colcounter < $lastcol) {
if (("$column[$colcounter]" eq "\\") &&
("$column[$colcounter+1]" eq "\"")) {
$colcounter++;
}
else {
print RECONSTRUCTED "$column[$colcounter]";
$colcounter++;
}
}
print RECONSTRUCTED "\n";
}
else {
print RECONSTRUCTED "$line";
}
}
close RAW;
close RECONSTRUCTED;
> I've developed a simple mini-script system that can be setup on a
> puppetmaster to send the stdout of the last reports for each client to a set
> of email addresses. I find it convenient to get these results in my inbox
> so that I can view them at a glance, review at leisure, forward on, cut &
> paste elsewhere, etc...
Isn't this what the tagmail system does?
http://docs.puppetlabs.com/references/stable/report.html
> recommendations, suggestions, comments welcome.
The main comment is a general sysadmin one: make sure you only generate noise
when something goes wrong, not when it goes right. Otherwise puppet will
rapidly overwhelm you with reports and you will never notice the problems. :)
Regards,
Daniel
--
✣ Daniel Pittman ✉ dan...@rimspace.net ☎ +61 401 155 707
♽ made with 100 percent post-consumer electrons
a huge +1!
~pete
The main difference it would appear from this and tagmail is that
tagmail constantly sends numerous emails. This script is run
on-demand or out of cron and harvests the stdout of all the last run
reports into one summary email/report. One email when you want it and
how you want it vs. hundreds or thousands every hour. I agree, this
would be way too much noise and why I didn't like the idea of tagmail.
I only want a summary once in a while, not a constant flow of them.
Thanks Daniel. I appreciate your commentary.
The main difference it would appear from this and tagmail is that
tagmail constantly sends numerous emails. This script is run
on-demand or out of cron and harvests the stdout of all the last run
reports into one summary email/report. One email when you want it and
how you want it vs. hundreds or thousands every hour. I agree, this
would be way too much noise and why I didn't like the idea of tagmail.
I only want a summary once in a while, not a constant flow of them.