Skip to content

Commit 12965af

Browse files
author
Till Brehm
committed
Merge branch '6785-hd-quota-du' into 'develop'
Resolve "Error from 100-monitor_hd_quota.inc.php when a server has no sites" Closes #6785 See merge request ispconfig/ispconfig3!1951
2 parents 7ed6ee9 + b154f05 commit 12965af

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

server/lib/classes/cron.d/100-monitor_hd_quota.inc.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function onRunJob() {
5959

6060
//* Initialize data array
6161
$data = array();
62+
$df = array();
6263

6364
//* the id of the server as int
6465
$server_id = intval($conf['server_id']);
@@ -72,20 +73,22 @@ public function onRunJob() {
7273
if(!$app->system->is_installed('setquota')) {
7374
//* No Quota on this System ...
7475

75-
//** Fetch the data for all users
76-
$dfData = shell_exec('du -s /var/www/clients/client*/web[0-9]*');
77-
78-
//* split into array
79-
$df = explode("\n", $dfData);
80-
8176
//* Get Limits for Calculation
8277
$records = $app->db->queryAllRecords('SELECT hd_quota, system_user, system_group FROM `web_domain` WHERE `server_id` = ?', $conf['server_id']);
8378
foreach ($records as $record) {
8479
$options['group'][$record['system_group']] = $record['hd_quota']*1024;
8580
$options['user'][$record['system_user']] = $record['hd_quota']*1024;
8681
}
8782

88-
//* ignore the first 5 lines, process the rest
83+
if (!empty($records)) {
84+
//** Fetch the data for all users
85+
$dfData = shell_exec('du -s /var/www/clients/client*/web[0-9]*');
86+
87+
//* split into array
88+
$df = explode("\n", $dfData);
89+
}
90+
91+
//* Loop over all the output lines, for groups.
8992
for ($i = 0; $i <= sizeof($df); $i++) {
9093
if (isset($df[$i]) && $df[$i] != '') {
9194
//* Make a array of the data
@@ -106,14 +109,14 @@ public function onRunJob() {
106109
}
107110
}
108111

109-
//* ignore the first 5 lines, process the rest
112+
//* Loop over all the output lines, for users.
110113
for ($i = 0; $i <= sizeof($df); $i++) {
111114
if (isset($df[$i]) && $df[$i] != '') {
112115
//* Make a array of the data
113116
$s1 = preg_split('/[\s]+/', $df[$i]);
114117
$s2 = preg_split('/\//', $s1[1]);
115118
$username = $s2[5];
116-
if (substr($username, 0, 3) == 'web') {
119+
if (preg_match('/^web\d+$/', $username)) {
117120
if (isset($data['user'][$username])) {
118121
$data['user'][$username]['used'] += $s1[0];
119122
$data['user'][$username]['soft'] = $options['user'][$username];

0 commit comments

Comments
 (0)