"Fossies" - the Fresh Open Source Software Archive 
Member "BackupPC-4.4.0/lib/BackupPC/CGI/GeneralInfo.pm" (20 Jun 2020, 6525 Bytes) of package /linux/privat/BackupPC-4.4.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "GeneralInfo.pm" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
4.3.2_vs_4.4.0.
1 #============================================================= -*-perl-*-
2 #
3 # BackupPC::CGI::GeneralInfo package
4 #
5 # DESCRIPTION
6 #
7 # This module implements the GeneralInfo action for the CGI interface.
8 #
9 # AUTHOR
10 # Craig Barratt <cbarratt@users.sourceforge.net>
11 #
12 # COPYRIGHT
13 # Copyright (C) 2001-2020 Craig Barratt
14 #
15 # This program is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation, either version 3 of the License, or
18 # (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #
28 #========================================================================
29 #
30 # Version 4.4.0, released 20 Jun 2020.
31 #
32 # See http://backuppc.sourceforge.net.
33 #
34 #========================================================================
35
36 package BackupPC::CGI::GeneralInfo;
37
38 use strict;
39 use BackupPC::CGI::Lib qw(:all);
40
41 sub action
42 {
43 GetStatusInfo("info jobs hosts queueLen");
44 my $Privileged = CheckPermission();
45
46 my($jobStr, $statusStr);
47 foreach my $host ( sort(keys(%Jobs)) ) {
48 my $startTime = timeStamp2($Jobs{$host}{startTime});
49 next if ( $host eq $bpc->scgiJob );
50 next if ( !$Privileged && !CheckPermission($host) );
51 $Jobs{$host}{type} = $Status{$host}{type}
52 if ( $Jobs{$host}{type} eq "" && defined($Status{$host}) );
53 (my $cmd = $Jobs{$host}{cmd}) =~ s/$BinDir\///g;
54 (my $xferPid = $Jobs{$host}{xferPid}) =~ s/,/, /g;
55 $jobStr .= <<EOF;
56 <tr><td class="border"> ${HostLink($host)} </td>
57 <td align="center" class="border"> $Jobs{$host}{type} </td>
58 <td align="center" class="border"> ${UserLink(defined($Hosts->{$host})
59 ? $Hosts->{$host}{user} : "")} </td>
60 <td class="border" data-date_format="$Conf{CgiDateFormatMMDD}"> $startTime </td>
61 <td class="border"> $cmd </td>
62 <td align="center" class="border"> $Jobs{$host}{pid} </td>
63 <td align="center" class="border"> $xferPid </td>
64 <td align="center" class="border"> $Jobs{$host}{xferState} </td>
65 <td align="center" class="border"> $Jobs{$host}{xferFileCnt} </td>
66 EOF
67 $jobStr .= "</tr>\n";
68 }
69 foreach my $host ( sort(keys(%Status)) ) {
70 next
71 if (
72 $Status{$host}{reason} ne "Reason_backup_failed"
73 && $Status{$host}{reason} ne "Reason_restore_failed"
74 && ( !$Status{$host}{userReq}
75 || $Status{$host}{reason} ne "Reason_no_ping")
76 );
77 next if ( !$Privileged && !CheckPermission($host) );
78 my $startTime = timeStamp2($Status{$host}{startTime});
79 my($errorTime, $XferViewStr);
80 if ( $Status{$host}{errorTime} > 0 ) {
81 $errorTime = timeStamp2($Status{$host}{errorTime});
82 }
83 if ( -f "$TopDir/pc/$host/SmbLOG.bad"
84 || -f "$TopDir/pc/$host/SmbLOG.bad.z"
85 || -f "$TopDir/pc/$host/XferLOG.bad"
86 || -f "$TopDir/pc/$host/XferLOG.bad.z" ) {
87 $XferViewStr = <<EOF;
88 <a href="$MyURL?action=view&type=XferLOGbad&host=${EscURI($host)}">$Lang->{XferLOG}</a>,
89 <a href="$MyURL?action=view&type=XferErrbad&host=${EscURI($host)}">$Lang->{Errors}</a>
90 EOF
91 } else {
92 $XferViewStr = "";
93 }
94 (my $shortErr = $Status{$host}{error}) =~ s/(.{48}).*/$1.../;
95 $statusStr .= <<EOF;
96 <tr><td class="border"> ${HostLink($host)} </td>
97 <td align="center" class="border"> $Status{$host}{type} </td>
98 <td align="center" class="border"> ${UserLink(defined($Hosts->{$host})
99 ? $Hosts->{$host}{user} : "")} </td>
100 <td align="right" class="border" data-date_format="$Conf{CgiDateFormatMMDD}"> $startTime </td>
101 <td class="border"> $XferViewStr </td>
102 <td align="right" class="border" data-date_format="$Conf{CgiDateFormatMMDD}"> $errorTime </td>
103 <td class="border"> ${EscHTML($shortErr)} </td></tr>
104 EOF
105 }
106
107 my $now = timeStamp2(time);
108 my $nextWakeupTime = timeStamp2($Info{nextWakeup});
109 my $DUlastTime = timeStamp2($Info{DUlastValueTime});
110 my $DUmaxTime = timeStamp2($Info{DUDailyMaxTime});
111 my $DUInodemaxTime = timeStamp2($Info{DUInodeDailyMaxTime});
112 my $numBgQueue = $QueueLen{BgQueue};
113 my $numUserQueue = $QueueLen{UserQueue};
114 my $numCmdQueue = $QueueLen{CmdQueue};
115 my $serverStartTime = timeStamp2($Info{startTime});
116 my $configLoadTime = timeStamp2($Info{ConfigLTime});
117
118 my $poolInfo = genPoolInfo("pool4", "pool", \%Info);
119 my $cpoolInfo = genPoolInfo("cpool4", "cpool", \%Info);
120
121 if ( $Info{pool4FileCnt} > 0 && $Info{cpool4FileCnt} > 0 ) {
122 $poolInfo = <<EOF;
123 <li>Uncompressed pool:
124 <ul>
125 $poolInfo
126 </ul>
127 <li>Compressed pool:
128 <ul>
129 $cpoolInfo
130 </ul>
131 EOF
132 } elsif ( $Info{cpool4FileCnt} > 0 ) {
133 $poolInfo = $cpoolInfo;
134 }
135 my $generalInfo = "";
136 if ( $Privileged ) {
137 $generalInfo = eval("qq{$Lang->{BackupPC_Server_Status_General_Info}}");
138 if ( -r "$LogDir/poolUsage4.png" && -r "$LogDir/poolUsage52.png" ) {
139 $generalInfo .= <<EOF;
140 <ul>
141 <ul>
142 <p><img src="$MyURL?action=view&type=poolUsage&num=4">
143 <p><img src="$MyURL?action=view&type=poolUsage&num=52">
144 </ul>
145 </ul>
146 EOF
147 }
148 }
149
150 my $content = eval("qq{$Lang->{BackupPC_Server_Status}}");
151 Header($Lang->{H_BackupPC_Server_Status}, $content);
152 Trailer();
153 }
154
155 sub genPoolInfo
156 {
157 my($name, $name3, $info) = @_;
158 my $poolSize = sprintf("%.2f", $info->{"${name}Kb"} / (1024 * 1024));
159 my $poolRmSize = sprintf("%.2f", $info->{"${name}KbRm"} / (1024 * 1024));
160 my $poolTime = timeStamp2($info->{"${name}Time"});
161 $info->{"${name}FileCntRm"} = $info->{"${name}FileCntRm"} + 0;
162 if ( $Conf{PoolV3Enabled} ) {
163 $poolSize .= sprintf("+%.2f", $info->{"${name3}Kb"} / (1024 * 1024));
164 $poolRmSize .= sprintf("+%.2f", $info->{"${name3}KbRm"} / (1024 * 1024));
165 foreach my $stat ( qw(DirCnt FileCnt FileCntRep FileRepMax FileCntRm) ) {
166 $Info{"$name$stat"} = $Info{"$name$stat"} . "+" . $Info{"$name3$stat"};
167 }
168 }
169 return eval("qq{$Lang->{Pool_Stat}}");
170 }
171
172 1;