/[BackupPC]/upstream/2.1.0/lib/BackupPC/CGI/GeneralInfo.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/2.1.0/lib/BackupPC/CGI/GeneralInfo.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Jun 22 19:12:04 2005 UTC (16 years, 11 months ago) by dpavlin
File size: 5565 byte(s)
import of version 2.1.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) 2003 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 2 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, write to the Free Software
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #
29 #========================================================================
30 #
31 # Version 2.1.0, released 20 Jun 2004.
32 #
33 # See http://backuppc.sourceforge.net.
34 #
35 #========================================================================
36
37 package BackupPC::CGI::GeneralInfo;
38
39 use strict;
40 use BackupPC::CGI::Lib qw(:all);
41
42 sub action
43 {
44 GetStatusInfo("info jobs hosts queueLen");
45 my $Privileged = CheckPermission();
46
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 next if ( !$Privileged && !CheckPermission($host) );
53 $Jobs{$host}{type} = $Status{$host}{type}
54 if ( $Jobs{$host}{type} eq "" && defined($Status{$host}));
55 (my $cmd = $Jobs{$host}{cmd}) =~ s/$BinDir\///g;
56 (my $xferPid = $Jobs{$host}{xferPid}) =~ s/,/, /g;
57 $jobStr .= <<EOF;
58 <tr><td class="border"> ${HostLink($host)} </td>
59 <td align="center" class="border"> $Jobs{$host}{type} </td>
60 <td align="center" class="border"> ${UserLink(defined($Hosts->{$host})
61 ? $Hosts->{$host}{user} : "")} </td>
62 <td class="border"> $startTime </td>
63 <td class="border"> $cmd </td>
64 <td align="center" class="border"> $Jobs{$host}{pid} </td>
65 <td align="center" class="border"> $xferPid </td>
66 EOF
67 $jobStr .= "</tr>\n";
68 }
69 foreach my $host ( sort(keys(%Status)) ) {
70 next if ( $Status{$host}{reason} ne "Reason_backup_failed"
71 && $Status{$host}{reason} ne "Reason_restore_failed"
72 && (!$Status{$host}{userReq}
73 || $Status{$host}{reason} ne "Reason_no_ping") );
74 next if ( !$Privileged && !CheckPermission($host) );
75 my $startTime = timeStamp2($Status{$host}{startTime});
76 my($errorTime, $XferViewStr);
77 if ( $Status{$host}{errorTime} > 0 ) {
78 $errorTime = timeStamp2($Status{$host}{errorTime});
79 }
80 if ( -f "$TopDir/pc/$host/SmbLOG.bad"
81 || -f "$TopDir/pc/$host/SmbLOG.bad.z"
82 || -f "$TopDir/pc/$host/XferLOG.bad"
83 || -f "$TopDir/pc/$host/XferLOG.bad.z"
84 ) {
85 $XferViewStr = <<EOF;
86 <a href="$MyURL?action=view&type=XferLOGbad&host=${EscURI($host)}">$Lang->{XferLOG}</a>,
87 <a href="$MyURL?action=view&type=XferErrbad&host=${EscURI($host)}">$Lang->{Errors}</a>
88 EOF
89 } else {
90 $XferViewStr = "";
91 }
92 (my $shortErr = $Status{$host}{error}) =~ s/(.{48}).*/$1.../;
93 $statusStr .= <<EOF;
94 <tr><td class="border"> ${HostLink($host)} </td>
95 <td align="center" class="border"> $Status{$host}{type} </td>
96 <td align="center" class="border"> ${UserLink(defined($Hosts->{$host})
97 ? $Hosts->{$host}{user} : "")} </td>
98 <td align="right" class="border"> $startTime </td>
99 <td class="border"> $XferViewStr </td>
100 <td align="right" class="border"> $errorTime </td>
101 <td class="border"> ${EscHTML($shortErr)} </td></tr>
102 EOF
103 }
104 my $now = timeStamp2(time);
105 my $nextWakeupTime = timeStamp2($Info{nextWakeup});
106 my $DUlastTime = timeStamp2($Info{DUlastValueTime});
107 my $DUmaxTime = timeStamp2($Info{DUDailyMaxTime});
108 my $numBgQueue = $QueueLen{BgQueue};
109 my $numUserQueue = $QueueLen{UserQueue};
110 my $numCmdQueue = $QueueLen{CmdQueue};
111 my $serverStartTime = timeStamp2($Info{startTime});
112 my $configLoadTime = timeStamp2($Info{ConfigLTime});
113 my $poolInfo = genPoolInfo("pool", \%Info);
114 my $cpoolInfo = genPoolInfo("cpool", \%Info);
115 if ( $Info{poolFileCnt} > 0 && $Info{cpoolFileCnt} > 0 ) {
116 $poolInfo = <<EOF;
117 <li>Uncompressed pool:
118 <ul>
119 $poolInfo
120 </ul>
121 <li>Compressed pool:
122 <ul>
123 $cpoolInfo
124 </ul>
125 EOF
126 } elsif ( $Info{cpoolFileCnt} > 0 ) {
127 $poolInfo = $cpoolInfo;
128 }
129 my $generalInfo = eval("qq{$Lang->{BackupPC_Server_Status_General_Info}}")
130 if ( $Privileged );
131 my $content = eval("qq{$Lang->{BackupPC_Server_Status}}");
132 Header($Lang->{H_BackupPC_Server_Status}, $content);
133 Trailer();
134 }
135
136 sub genPoolInfo
137 {
138 my($name, $info) = @_;
139 my $poolSize = sprintf("%.2f", $info->{"${name}Kb"} / (1000 * 1024));
140 my $poolRmSize = sprintf("%.2f", $info->{"${name}KbRm"} / (1000 * 1024));
141 my $poolTime = timeStamp2($info->{"${name}Time"});
142 $info->{"${name}FileCntRm"} = $info->{"${name}FileCntRm"} + 0;
143 return eval("qq{$Lang->{Pool_Stat}}");
144 }
145
146 1;

  ViewVC Help
Powered by ViewVC 1.1.26