Skip to content

Commit 76f4863

Browse files
committed
Update 100-monitor_hd_quota.inc.php
1 parent 694e065 commit 76f4863

File tree

1 file changed

+7
-55
lines changed

1 file changed

+7
-55
lines changed

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

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class cronjob_monitor_hd_quota extends cronjob {
3333
// job schedule
3434
protected $_schedule = '*/5 * * * *';
3535
protected $_run_at_new = true;
36-
3736
private $_tools = null;
3837

3938
/* this function is optional if it contains no custom code */
@@ -70,7 +69,7 @@ public function onRunJob() {
7069
//* The state of the harddisk_quota.
7170
$state = 'ok';
7271

73-
if(!$app->system->is_installed('setquota')) {
72+
if(!$app->system->is_installed('setquota')) {
7473
//* No Quota on this System ...
7574

7675
//** Fetch the data for all users
@@ -88,7 +87,7 @@ public function onRunJob() {
8887

8988
//* ignore the first 5 lines, process the rest
9089
for ($i = 0; $i <= sizeof($df); $i++) {
91-
if (isset($df[$i]) && $df[$i] != '') {
90+
if ($df[$i] != '') {
9291
//* Make a array of the data
9392
$s1 = preg_split('/[\s]+/', $df[$i]);
9493
$s2 = preg_split('/\//', $s1[1]);
@@ -109,7 +108,7 @@ public function onRunJob() {
109108

110109
//* ignore the first 5 lines, process the rest
111110
for ($i = 0; $i <= sizeof($df); $i++) {
112-
if (isset($df[$i]) && $df[$i] != '') {
111+
if ($df[$i] != '') {
113112
//* Make a array of the data
114113
$s1 = preg_split('/[\s]+/', $df[$i]);
115114
$s2 = preg_split('/\//', $s1[1]);
@@ -129,9 +128,7 @@ public function onRunJob() {
129128
}
130129
}
131130
}
132-
133-
}else{
134-
131+
}else{
135132
//* Fetch the data for all users
136133
$dfData = shell_exec('repquota -au 2>/dev/null');
137134

@@ -140,7 +137,7 @@ public function onRunJob() {
140137

141138
//* ignore the first 5 lines, process the rest
142139
for ($i = 5; $i <= sizeof($df); $i++) {
143-
if (isset($df[$i]) && $df[$i] != '') {
140+
if ($df[$i] != '') {
144141
//* Make a array of the data
145142
$s = preg_split('/[\s]+/', $df[$i]);
146143
$username = $s[0];
@@ -156,29 +153,6 @@ public function onRunJob() {
156153
$data['user'][$username]['hard'] = $s[4];
157154
$data['user'][$username]['files'] = $s[5];
158155
}
159-
//* Fetch the data for all users
160-
$dfData = shell_exec('repquota -au 2>/dev/null');
161-
162-
//* Split into array
163-
$df = explode("\n", $dfData);
164-
165-
//* ignore the first 5 lines, process the rest
166-
for ($i = 5; $i <= sizeof($df); $i++) {
167-
if (isset($df[$i]) && $df[$i] != '') {
168-
//* Make a array of the data
169-
$s = preg_split('/[\s]+/', $df[$i]);
170-
$username = $s[0];
171-
if (substr($username, 0, 3) == 'web') {
172-
if (isset($data['user'][$username])) {
173-
$data['user'][$username]['used'] += $s[2];
174-
$data['user'][$username]['soft'] += $s[3];
175-
$data['user'][$username]['hard'] += $s[4];
176-
$data['user'][$username]['files'] += $s[5];
177-
} else {
178-
$data['user'][$username]['used'] = $s[2];
179-
$data['user'][$username]['soft'] = $s[3];
180-
$data['user'][$username]['hard'] = $s[4];
181-
$data['user'][$username]['files'] = $s[5];
182156
}
183157
}
184158
}
@@ -191,7 +165,7 @@ public function onRunJob() {
191165

192166
//* ignore the first 5 lines, process the rest
193167
for ($i = 5; $i <= sizeof($df); $i++) {
194-
if (isset($df[$i]) && $df[$i] != '') {
168+
if ($df[$i] != '') {
195169
//* Make a array of the data
196170
$s = preg_split('/[\s]+/', $df[$i]);
197171
$groupname = $s[0];
@@ -205,32 +179,10 @@ public function onRunJob() {
205179
$data['group'][$groupname]['soft'] = $s[3];
206180
$data['group'][$groupname]['hard'] = $s[4];
207181
}
208-
//** Fetch the data for all users
209-
$dfData = shell_exec('repquota -ag 2>/dev/null');
210-
211-
//* split into array
212-
$df = explode("\n", $dfData);
213-
214-
//* ignore the first 5 lines, process the rest
215-
for ($i = 5; $i <= sizeof($df); $i++) {
216-
if (isset($df[$i]) && $df[$i] != '') {
217-
//* Make a array of the data
218-
$s = preg_split('/[\s]+/', $df[$i]);
219-
$groupname = $s[0];
220-
if (substr($groupname, 0, 6) == 'client') {
221-
if (isset($data['group'][$groupname])) {
222-
$data['group'][$groupname]['used'] += $s[2];
223-
$data['group'][$groupname]['soft'] += $s[3];
224-
$data['group'][$groupname]['hard'] += $s[4];
225-
} else {
226-
$data['group'][$groupname]['used'] = $s[2];
227-
$data['group'][$groupname]['soft'] = $s[3];
228-
$data['group'][$groupname]['hard'] = $s[4];
229182
}
230183
}
231184
}
232-
}
233-
185+
}
234186
$res = array();
235187
$res['server_id'] = $server_id;
236188
$res['type'] = $type;

0 commit comments

Comments
 (0)