-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpure-monitor.cgi
executable file
·85 lines (65 loc) · 2.62 KB
/
pure-monitor.cgi
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
#!/usr/bin/perl
# View Pure-FTPd users.
do '../web-lib.pl';
&init_config();
print "Refresh: $config{'refresh'}\r\n"
if ($config{'refresh'});
&header($text{'pure-monitor_title'}, undef, "intro", 1, 1, undef, $text{'index_mail'});
# Check if there is CSS styles set
if ($config{'conf_pureCSS'}) { print "<STYLE type=\"text/css\">
$config{'conf_pureCSS'}\n</STYLE>\n\n"; }
# Check if pure-ftpwho is installed.
if (!-x $config{'conf_pureftpdftpwho'}) {
print "<p><center><h2>",&text('pureftpdmonitor_conf',
"$config{'conf_pureftpdftpwho'}",
"/config.cgi?$module_name"),
"</h2></center><p><hr>\n";
&footer("/", $text{'index'});
exit;
}
# Check for monitoring
open (FIC, "$config{'conf_pureftpdftpwho'} -s|");
@results=<FIC>; close(FIC);
# No connected users for the moment
if(!$results[0]) { print "<center><h1>$text{'pure-monitor_nothing'}
</h1></center><br><br><br>\n\n"; } else {
# Number of connected Pure-FTPd users
$users=@results;
if($users==1){ print "<center><h1>$text{'pure-monitor_one'}</h1>";}
else {printf "<center><h1>$text{'pure-monitor_many'}</h1>",$users;}
# Results: table construction
print <<EOF;
<table width="100%" cellspacing="4" border="2" cellpadding="4"><tr $tb>
<td>$text{'pure-monitor_pid'}</td>
<td>$text{'pure-monitor_acct'}</td>
<td>$text{'pure-monitor_time'}</td>
<td>$text{'pure-monitor_state'}</td>
<td>$text{'pure-monitor_file'}</td>
<td>$text{'pure-monitor_peer'}</td>
<td>$text{'pure-monitor_total'}</td>
<td>$text{'pure-monitor_percent'}</td>
<td>$text{'pure-monitor_bandwidth'}</td>
<td>$text{'pure-monitor_local'}</td></tr>
EOF
# Table construction
foreach $i (@results) {
# pid|acct|time|state|file|peer|local|port|current|total|%|bandwidth
local ($pid, $login, $time, $state, $file, $peer, $local,
$port, $current, $total, $percent, $bandwidth) = split(/\|/, $i);
if(!$file){ $file = " "; }
if ($state eq "UL") { $state=$text{'pure-monitor_Uploading'}; }
elsif ($state eq " DL ") { $state=$text{'pure-monitor_Downloading'}; }
elsif ($state eq "IDLE") { $state=$text{'pure-monitor_Idle'}; }
if(int($time/60)<10)
{ $ttime="0".int($time/60); }
else { $ttime=int($time/60); }
if($time-(60*int($time/60))<10)
{ $ttime="$ttime:0".($time-(60*int($time/60))); }
else { $ttime="$ttime:".($time-(60*int($time/60))); }
print "<tr valign=\"middle\">
<td>$pid</td><td>$login</td><td>$ttime</td><td>$state</td><td>$file</td><td>$peer</td>
<td>$total</td><td>$percent %</td><td>$bandwidth $text{'pure-monitor_speed'}</td>
<td>$local:$port</td></tr>";
}
print "</table></center><br><br><br><br>\n\n\n"; }
&footer("", $text{'index_return'});