Skip to content

Commit

Permalink
Fixed: Cron tasks for traffic accounting are never executed due to wr…
Browse files Browse the repository at this point in the history
…ong command in /etc/cron.d/imscp cron file

CS fixes
  • Loading branch information
nuxwin committed Apr 18, 2017
1 parent ac8654f commit 94ff36b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Expand Up @@ -7,6 +7,9 @@ Git 1.4.x
BACKEND
Fixed: Can't use an undefined value as a HASH reference; DBI::selectrow_hashref() return undef on empty results

CRON
Fixed: Cron tasks for traffic accounting are never executed due to wrong command in /etc/cron.d/imscp cron file

SERVERS
Fixed: Error: quota: Unknown namespace: Trash (Dovecot/IMAP)

Expand Down
4 changes: 2 additions & 2 deletions configs/debian/cron.d/imscp
@@ -1,8 +1,8 @@
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Traffic accounting
0,30 * * * * root perl nice -n 10 ionice -c2 -n5 {TRAFF_ROOT_DIR}/imscp-srv-traff > {LOG_DIR}/imscp-srv-traff.log 2>&1
0,30 * * * * root perl nice -n 10 ionice -c2 -n5 {TRAFF_ROOT_DIR}/imscp-vrl-traff > {LOG_DIR}/imscp-vrl-traff.log 2>&1
0,30 * * * * root nice -n 10 ionice -c2 -n5 perl {TRAFF_ROOT_DIR}/imscp-srv-traff > {LOG_DIR}/imscp-srv-traff.log 2>&1
0,30 * * * * root nice -n 10 ionice -c2 -n5 perl {TRAFF_ROOT_DIR}/imscp-vrl-traff > {LOG_DIR}/imscp-vrl-traff.log 2>&1

# Quota accounting
@daily root nice -n 10 ionice -c2 -n5 perl {QUOTA_ROOT_DIR}/imscp-dsk-quota > {LOG_DIR}/imscp-dsk-quota.log 2>&1
Expand Down
29 changes: 15 additions & 14 deletions engine/traffic/imscp-vrl-traff
Expand Up @@ -54,7 +54,7 @@ sub run
my $halfTimestamp = $timestamp - ($timestamp % 1800);
my %trafficDb;

# Collects traffic data
# Collects traffic data from each server implementing the getTraffic() method
for my $server(iMSCP::Servers->getInstance( )->getListWithFullNames( )) {
eval "require $server";
if (my $subref = $server->can( 'getTraffic' )) {
Expand Down Expand Up @@ -97,17 +97,11 @@ sub run
my $domainName = $domainRow->{'domain_name'};
my $upperDomainId = $domainRow->{'upper_domain_id'};

next unless
$trafficDb{'Servers::httpd'}->{$domainName}
next unless $trafficDb{'Servers::httpd'}->{$domainName}
|| $trafficDb{'Servers::ftpd'}->{$domainName}
|| $trafficDb{'Servers::mta'}->{$domainName}
|| $trafficDb{'Servers::po'}->{$domainName};

my $httpdTraffic = $trafficDb{'Servers::httpd'}->{$domainName} || 0;
my $ftpdTraffic = $trafficDb{'Servers::ftpd'}->{$domainName} || 0;
my $mtaTraffic = $trafficDb{'Servers::mta'}->{$domainName} || 0;
my $poTraffic = $trafficDb{'Servers::po'}->{$domainName} || 0;

$dbh->do(
'
INSERT INTO domain_traffic (
Expand All @@ -119,12 +113,19 @@ sub run
dtraff_ftp = dtraff_ftp + ?,
dtraff_mail = dtraff_mail + ?,
dtraff_pop = dtraff_pop + ?
',
undef,
$upperDomainId, $halfTimestamp, $httpdTraffic, $ftpdTraffic, $mtaTraffic, $poTraffic,
$httpdTraffic, $ftpdTraffic, $mtaTraffic, $poTraffic
);

',
undef,
$upperDomainId,
$halfTimestamp,
$trafficDb{'Servers::httpd'}->{$domainName} || 0,
$trafficDb{'Servers::ftpd'}->{$domainName} || 0,
$trafficDb{'Servers::mta'}->{$domainName} || 0,
$trafficDb{'Servers::po'}->{$domainName} || 0,
$trafficDb{'Servers::httpd'}->{$domainName} || 0,
$trafficDb{'Servers::ftpd'}->{$domainName} || 0,
$trafficDb{'Servers::mta'}->{$domainName} || 0,
$trafficDb{'Servers::po'}->{$domainName} || 0
);

if($dbh->err) {
error($dbh->errstr);
Expand Down

0 comments on commit 94ff36b

Please sign in to comment.