1 #============================================================= -*-perl-*-
3 # BackupPC::CGI::GeneralInfo package
7 # This module implements the GeneralInfo action for the CGI interface.
10 # Craig Barratt <cbarratt@users.sourceforge.net>
13 # Copyright (C) 2003 Craig Barratt
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 2 of the License, or
18 # (at your option) any later version.
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.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #========================================================================
31 # Version 2.1.0_CVS, released 3 Jul 2003.
33 # See http://backuppc.sourceforge.net.
35 #========================================================================
37 package BackupPC::CGI::GeneralInfo;
40 use BackupPC::CGI::Lib qw(:all);
44 GetStatusInfo("info jobs hosts queueLen");
45 my $Privileged = CheckPermission();
47 my($jobStr, $statusStr);
48 foreach my $host ( sort(keys(%Jobs)) ) {
49 my $startTime = timeStamp2($Jobs{$host}{startTime});
50 next if ( $host eq $bpc->trashJob
51 && $Jobs{$host}{processState} ne "running" );
52 $Jobs{$host}{type} = $Status{$host}{type}
53 if ( $Jobs{$host}{type} eq "" && defined($Status{$host}));
54 (my $cmd = $Jobs{$host}{cmd}) =~ s/$BinDir\///g;
55 (my $xferPid = $Jobs{$host}{xferPid}) =~ s/,/, /g;
57 <tr><td> ${HostLink($host)} </td>
58 <td align="center"> $Jobs{$host}{type} </td>
59 <td align="center"> ${UserLink(defined($Hosts->{$host})
60 ? $Hosts->{$host}{user} : "")} </td>
63 <td align="center"> $Jobs{$host}{pid} </td>
64 <td align="center"> $xferPid </td>
68 foreach my $host ( sort(keys(%Status)) ) {
69 next if ( $Status{$host}{reason} ne "Reason_backup_failed"
70 && $Status{$host}{reason} ne "Reason_restore_failed"
71 && (!$Status{$host}{userReq}
72 || $Status{$host}{reason} ne "Reason_no_ping") );
73 my $startTime = timeStamp2($Status{$host}{startTime});
74 my($errorTime, $XferViewStr);
75 if ( $Status{$host}{errorTime} > 0 ) {
76 $errorTime = timeStamp2($Status{$host}{errorTime});
78 if ( -f "$TopDir/pc/$host/SmbLOG.bad"
79 || -f "$TopDir/pc/$host/SmbLOG.bad.z"
80 || -f "$TopDir/pc/$host/XferLOG.bad"
81 || -f "$TopDir/pc/$host/XferLOG.bad.z"
84 <a href="$MyURL?action=view&type=XferLOGbad&host=${EscURI($host)}">$Lang->{XferLOG}</a>,
85 <a href="$MyURL?action=view&type=XferErrbad&host=${EscURI($host)}">$Lang->{Errors}</a>
90 (my $shortErr = $Status{$host}{error}) =~ s/(.{48}).*/$1.../;
92 <tr><td> ${HostLink($host)} </td>
93 <td align="center"> $Status{$host}{type} </td>
94 <td align="center"> ${UserLink(defined($Hosts->{$host})
95 ? $Hosts->{$host}{user} : "")} </td>
96 <td align="right"> $startTime </td>
97 <td> $XferViewStr </td>
98 <td align="right"> $errorTime </td>
99 <td> ${EscHTML($shortErr)} </td></tr>
102 my $now = timeStamp2(time);
103 my $nextWakeupTime = timeStamp2($Info{nextWakeup});
104 my $DUlastTime = timeStamp2($Info{DUlastValueTime});
105 my $DUmaxTime = timeStamp2($Info{DUDailyMaxTime});
106 my $numBgQueue = $QueueLen{BgQueue};
107 my $numUserQueue = $QueueLen{UserQueue};
108 my $numCmdQueue = $QueueLen{CmdQueue};
109 my $serverStartTime = timeStamp2($Info{startTime});
110 my $poolInfo = genPoolInfo("pool", \%Info);
111 my $cpoolInfo = genPoolInfo("cpool", \%Info);
112 if ( $Info{poolFileCnt} > 0 && $Info{cpoolFileCnt} > 0 ) {
114 <li>Uncompressed pool:
123 } elsif ( $Info{cpoolFileCnt} > 0 ) {
124 $poolInfo = $cpoolInfo;
127 Header($Lang->{H_BackupPC_Server_Status});
128 print (eval ("qq{$Lang->{BackupPC_Server_Status}}"));
134 my($name, $info) = @_;
135 my $poolSize = sprintf("%.2f", $info->{"${name}Kb"} / (1000 * 1024));
136 my $poolRmSize = sprintf("%.2f", $info->{"${name}KbRm"} / (1000 * 1024));
137 my $poolTime = timeStamp2($info->{"${name}Time"});
138 $info->{"${name}FileCntRm"} = $info->{"${name}FileCntRm"} + 0;
139 return eval("qq{$Lang->{Pool_Stat}}");