File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ # !/usr/bin/perl
2
+ use strict;
3
+ use warnings;
4
+ use Data::Dumper;
5
+ use YAML::Syck;
6
+ use POSIX qw( strftime) ;
7
+ use Getopt::Long;
8
+
9
+ # get all the warnings for a given host for today.
10
+
11
+ GetOptions(
12
+ " r|reportsdir=s" => \( my $reportsdir = ' /var/lib/puppet/reports' ),
13
+ " h|host=s" => \( my $host = ' *' ),
14
+ " d|date=s" => \( my $date = strftime(' %Y%m%d' , localtime ) ),
15
+ " debug" => \( my $debug = 0 ),
16
+ );
17
+
18
+ die " Please supply a host\n " unless $host ;
19
+
20
+ for my $report ( glob (" $reportsdir /$host /$date *.yaml" ) ) {
21
+ my @messages ;
22
+ my $reportdump = LoadFile( $report );
23
+
24
+ for my $log (@{ $reportdump -> {logs } }) {
25
+ next if $log -> {level } =~ / notice/ ;
26
+ $log -> {level } =~ s / ^:// ;
27
+ my $message = $log -> {level } . " : " . $log -> {message } . " " . $log -> {source };
28
+
29
+ print " $report : $message \n " ;
30
+ }
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments