This file is indexed.

/usr/bin/pg_lsclusters is in postgresql-common 165+deb8u3.

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
#!/usr/bin/perl -wT
# Show all PostgreSQL clusters in a list
#
# (C) 2005-2009 Martin Pitt <mpitt@debian.org>
# (C) 2013,2014 Christoph Berg <myon@debian.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

use strict;
use PgCommon;
use Getopt::Long;

my $no_header;
exit 1 unless GetOptions ('h|no-header' => \$no_header);

my @lines;
push @lines, ['Ver', 'Cluster', 'Port', 'Status', 'Owner', 'Data directory', 'Log file']
    unless ($no_header);

foreach my $v (sort (get_versions())) {
    my @clusters = get_version_clusters $v;
    foreach my $c (sort @clusters) {
        my %info = cluster_info $v, $c;
        my $logfile;
        if ($info{logfile}) { # postgresql-common-provided location
            $logfile = $info{'logfile'};
        } elsif ($info{log_destination} and $info{log_destination} =~ /syslog/) {
            $logfile = $info{log_destination}; # could be "syslog,whatever", show both
        } else { # logging_collector is active
            my $path = $info{log_directory} || 'pg_log';
            my $file = $info{log_filename} || 'postgresql-%Y-%m-%d_%H%M%S.log';
            $logfile = "$path/$file";
        }
        push @lines, [$v, $c, $info{'port'},
            ($info{'running'} ? "online" : "down") . ($info{'recovery'} ? ",recovery" : ""),
            defined $info{'owneruid'} ? (getpwuid $info{'owneruid'})[0] : '<unknown>',
            $info{'pgdata'} || '<not set>', $logfile];
    }
}

my @colwidth = qw(1 1 1 1 1 1 1);
foreach my $line (@lines) {
    for (my $i = 0; $i < @$line - 1; $i++) { # skip adjustment for last column
        my $len = length @$line[$i];
        $colwidth[$i] = $len if ($len > $colwidth[$i]);
    }
}

my $fmtstring = join ' ', map { "%-${_}s" } @colwidth;

foreach my $line (@lines) {
    printf "$fmtstring\n", @$line;
}

__END__

=head1 NAME

pg_lsclusters - show information about all PostgreSQL clusters

=head1 SYNOPSIS

B<pg_lsclusters> [I<options>]

=head1 DESCRIPTION

This command shows a list about the configuration and status of all clusters.

=head1 OPTIONS

=over 4

=item B<-h>, B<--no-header>

Do not print the column header line.

=back

=head1 AUTHOR

Martin Pitt L<E<lt>mpitt@debian.orgE<gt>>