This file is indexed.

/usr/share/perl5/CipUX/CAT/Web/Module/ServerInfo.pm is in libcipux-cat-web-perl 3.4.0.3-4.2.

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

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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
package CipUX::CAT::Web::Module::ServerInfo;

use warnings;
use strict;
use English qw( -no_match_vars);
use Log::Log4perl qw(get_logger :levels);
use Scalar::Util::Numeric qw(:all);
use base qw(CipUX::CAT::Web::Module CipUX::CAT::Web::L10N);

{

    use version; our $VERSION = qv('3.4.0.3');
    use re 'taint';    # Keep data captured by parentheses tainted
    delete @ENV{qw(PATH IFS CDPATH ENV BASH_ENV)};    # Make %ENV safer

    Readonly::Scalar my $NAME   => 'serverinfo';
    Readonly::Scalar my $MODULE => 'serverinfo.cgi';

    sub register {

        my $self = shift;

        $self->set_module_name_register(
            { class => __PACKAGE__, name => $MODULE } );

        # Merge and set the configuration
        my $cfg_ar = $self->module_cfg;
        $self->set_module_cfg_register(
            { cfg_ar => $cfg_ar, name => $MODULE } );

        return 1;
    }

    sub module_cfg : CUMULATIVE(BASE FIRST) {

        my $self = shift;

        my $sdesc = 'Server information';
        my $ldesc = 'Lists information about ';
        $ldesc .= 'the local operating system.';

        my $module_hr = {};
        $module_hr->{cipuxName}             = $NAME;
        $module_hr->{cipuxTemplateDir}      = $NAME;
        $module_hr->{cipuxIcon}             = $NAME . '.png';
        $module_hr->{cipuxShortDescription} = $sdesc;
        $module_hr->{cipuxDescription}      = $ldesc;
        $module_hr->{cipuxTask}             = ['NULL'];

        return [$module_hr];
    }

    sub module {

        my ( $self, $arg_r ) = @_;

        my $rpc
            = ( exists $arg_r->{rpc_obj} )
            ? $arg_r->{rpc_obj}
            : $self->perr('rpc_obj');
        my $lh
            = ( exists $arg_r->{lh_obj} )
            ? $arg_r->{lh_obj}
            : $self->perr('lh_obj');
        my $c_hr
            = ( exists $arg_r->{c_hr} )
            ? $arg_r->{c_hr}
            : $self->perr('c_hr');

        my $l = get_logger(__PACKAGE__);
        $l->debug("module [$MODULE]");

        my $path = "tpl/$c_hr->{cat_theme}/$NAME";
        $l->debug("template path [$path]");

        eval { require Sys::Info::OS; };
        if ($EVAL_ERROR) {
            my $m = not_installed_msg( $lh, 'Sys::Info::OS' );
            return $self->error( { module => $MODULE, msg => $m } );
        }
        eval { require Sys::Info; };
        if ($EVAL_ERROR) {
            my $m = not_installed_msg( $lh, 'Sys::Info' );
            return $self->error( { module => $MODULE, msg => $m } );
        }
        eval { require Sys::MemInfo; };
        if ($EVAL_ERROR) {
            my $m = not_installed_msg( $lh, 'Sys::MemInfo' );
            return $self->error( { module => $MODULE, msg => $m } );
        }
        eval { require Filesys::DiskFree; };
        if ($EVAL_ERROR) {
            my $m = not_installed_msg( $lh, 'Filesys::DiskFree' );
            return $self->error( { module => $MODULE, msg => $m } );
        }

        my %options = ();

        my $os  = Sys::Info::OS->new(%options);
        my $si  = Sys::Info->new(%options);
        my $cpu = $si->device('CPU');

        my $data_hr = {
            os_name     => $os->name( long => 1, edition => 1 ),
            node_name   => $os->node_name,
            domain_name => $os->domain_name,
            ip          => $os->ip,
            is_linux    => $os->is_linux,
            is_bsd      => $os->is_bsd,
            httpd => $si->httpd || $lh->maketext('unknown'),
            cpu => scalar $cpu->identify,
            mem_main_total => Sys::MemInfo::totalmem(),
            mem_main_free  => Sys::MemInfo::freemem(),
            mem_swap_total => Sys::MemInfo::totalswap(),
            mem_swap_free  => Sys::MemInfo::freeswap(),
        };

        if ( my $up = $os->uptime ) {
            my $t     = $os->tick_count;
            my $up_hr = {
                up_since  => scalar localtime $up,
                up_hours  => sprintf( "%.2f", $t / 3600 ),
                up_days   => sprintf( "%.2f", $t / 86400 ),
                up_months => sprintf( "%.2f", $t / 2592000 ),
            };
            $data_hr->{up} = $up_hr;
        }

        my $handle = new Filesys::DiskFree;
        $handle->df();
        my @mnt = $handle->disks();
        $data_hr->{disks_ar} = \@mnt;
        foreach my $id (@mnt) {
            push @{ $data_hr->{diskfree} },
                {
                id           => $id,
                device_id    => $handle->device($id),
                device_avail => $handle->avail($id),
                device_total => $handle->total($id),
                device_used  => $handle->used($id),
                device_mount => $handle->mount($id),
                };
        }

        return {

            layout => "$path/layout.html",

            layout_ar => [
                { begin_html => 1, },
                { body_ar    => [ $lh->maketext('Server information') ] },
                {
                    tt2_hr => {
                        tpl      => "$path/index.html",
                        param_hr => {
                            DATA    => $data_hr,
                            MODULE  => $MODULE,
                            PATH    => $path,
                            lh      => $lh,
                            sizefmt => \&sizefmt,
                        },
                    }
                },
                { footer_hr => { show_index_back => 1, }, },
                { end_html  => 1, },
            ],
        };

    }

    sub not_installed_msg {
        my $lh = shift;
        my $m  = shift;
        return $lh->maketext( 'To use this module, please install [_1]!',
            $m );
    }

    sub sizefmt {
        my @sizefmt = qw/bytes Kb Mb Gb Tb Eb Pb/;
        my $v       = shift;
        return $v if not isint($v);
        $v =~ s{/d+}{}gmx;
        my $c = 0;
        while ( $v >= 1024.0 ) {
            $v = $v / 1024.0;
            $c++;
            last if not defined $sizefmt[$c];
        }
        if ( $v < 10 ) {
            $v = sprintf( "%1.2f", $v );
        }
        else {
            $v = sprintf( "%.1f", $v );
        }
        $v =~ s/0+$//g;
        $v =~ s/\.$//g;
        my $e = ( defined $sizefmt[$c] ) ? $sizefmt[$c] : 'very large';
        return "$v $e";

    }

}

1;

__END__

=pod

=head1 NAME

CipUX::CAT::Web::Module::ServerInfo - Lists all perl versions of CipUX


=head1 VERSION

This document describes CipUX::CAT::Web::Module::ServerInfo version 3.4.0.3


=head1 SYNOPSIS

This CAT Web module can be used to see installed CipUX Perl module versions.

=head1 DESCRIPTION


This CAT Web module can be used to see installed CipUX Perl module versions.

=head1 INTERFACE

=head2 module

Use this method to start the list.

=head1 DIAGNOSTICS

Throws the error

  To use this module, please install Module::List::Pluggable!

if Module::List::Pluggable is not installed.

=head1 CONFIGURATION AND ENVIRONMENT

CipUX::CAT::Web::Module::ServerInfo requires no configuration files or
environment variables. However it merges its configuration from
CipUX::CAT::Web::Module and itself.


=head1 DEPENDENCIES

 Log::Log4perl
 CipUX::CAT::Web::Module
 Module::List::Pluggable

=head1 INCOMPATIBILITIES

None reported.


=head1 BUGS AND LIMITATIONS

No bugs have been reported.


=head1 AUTHOR

Christian Kuelker  C<< <christian.kuelker@cipworx.org> >>


=head1 LICENCE AND COPYRIGHT

Copyright (C) 2010, Christian Kuelker
C<< <christian.kuelker@cipworx.org> >>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under
the GNU GPL licence version 2 or any later version.


=head1 DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

=cut