This file is indexed.

/usr/sbin/octo_syslog2iso8601 is in octopussy 1.0.6-0ubuntu2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/perl

=head1 NAME

syslog2iso8601 - Octopussy program to convert 'syslog format' logs to 'iso8601' logs

=head1 SYNOPSIS

syslog2iso8601 --device <device> --service <service> 

=head1 DESCRIPTION

=cut

use strict;
use warnings;
use Readonly;

use Getopt::Long;

use DateTime;
use DateTime::Format::Strptime;

use AAT::Utils qw( ARRAY );
use Octopussy;
use Octopussy::Logs;

Readonly my $PROG_NAME    => 'syslog2iso8601';
Readonly my $PROG_VERSION => Octopussy::Version();

my $help;
my ($opt_device, $opt_service, $opt_timezone) = (undef, undef, undef);

=head1 FUNCTIONS

=head2 Help()

Prints Help

=cut

sub Help
{
    my $help_str = <<"EOF";

$PROG_NAME (version $PROG_VERSION)

 Usage: $PROG_NAME --device <device> --service <service> --timezone <+/-HH:MM>

EOF

    print $help_str;
    if (!defined $opt_device)
    {
        print ' ' . Octopussy::Device::String_List(undef) . "\n";
    }
    elsif (!defined $opt_service)
    {
        print ' '
            . Octopussy::Device::String_Services(ARRAY($opt_device)) . "\n";
    }
    print "\n";

    exit;
}

#
# MAIN
#

my $status = GetOptions(
    'h'         => \$help,
    'help'      => \$help,
    'device=s'  => \$opt_device,
    'service=s' => \$opt_service,
    'timezone=s' => \$opt_timezone,
);

Help()
    if ((!$status)
    || ($help)
    || (!defined $opt_device)
    || (!defined $opt_service)
    || (!defined $opt_timezone));

my ($files, $total) =
    Octopussy::Logs::Get_TimePeriod_Files($opt_device, $opt_service, '197001010000', '202001010000');

my $strp = new DateTime::Format::Strptime(pattern => '%Y %h %e %T');

foreach my $min (sort keys %{$files})
{
    my @logs = ();
    foreach my $f (@{$files->{$min}})
    {
    	if ($f =~ /\/(\d{4})\/\d{2}\/\d{2}\/msg_/)
    	{
            my $year = $1;
			my $cat = ($f =~ /.+\.gz$/ ? 'zcat' : 'cat');
            if (defined open my $FILE, '-|', "$cat \"$f\"")
            {
                while (<$FILE>)
                { 
            	   if ($_ =~ /^(\w{3}) \s?(\d{1,2}) (\d\d:\d\d:\d\d) (.*)$/)
            	   {
            	       my $dt = $strp->parse_datetime("$year $1 $2 $3");
            	       my $str = sprintf("%sT%s.000000%s %s", $dt->ymd('-'), $dt->hms(':'), $opt_timezone, $4);  	
            	       push @logs, $str;
            	   }
                }
                close $FILE;
                if (defined open my $TMPFILE, '|-', "gzip >> ${f}.tmp")
                {
                    foreach my $log (@logs) 
                        { print {$TMPFILE} "$log\n"; }
                    close $TMPFILE;
                    rename "${f}.tmp", $f   if (scalar @logs);
                    @logs = ();
                }
            }
        }
    }
}

=head1 AUTHOR

Sebastien Thebert <octo.devel@gmail.com>

=cut

1;