Skip to content

Commit 55c935c

Browse files
author
Till Brehm
committed
Merge branch 'CronDeprecatedWarnings_Clamav_Mem' into 'develop'
Fixes PHP warnings in monitor for mem and clamav See merge request ispconfig/ispconfig3!1810
2 parents c294568 + e5a9f19 commit 55c935c

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,26 @@ public function onRunJob() {
104104

105105
$tmp = explode("\n", $data);
106106
$lastLog = array();
107-
if ($tmp[sizeof($tmp) - 1] == '') {
108-
/* the log ends with an empty line remove this */
109-
array_pop($tmp);
110-
}
111-
if (strpos($tmp[sizeof($tmp) - 1], '-------------') !== false) {
112-
/* the log ends with "-----..." remove this */
113-
array_pop($tmp);
114-
}
115-
for ($i = sizeof($tmp) - 1; $i > 0; $i--) {
116-
if (strpos($tmp[$i], '---------') === false) {
117-
/* no delimiter found, so add this to the last-log */
118-
$lastLog[] = $tmp[$i];
119-
} else {
120-
/* delimiter found, so there is no more line left! */
121-
break;
107+
if (count($tmp) >= 2) {
108+
if ($tmp[sizeof($tmp) - 1] == '') {
109+
/* the log ends with an empty line remove this */
110+
array_pop($tmp);
111+
}
112+
if (strpos($tmp[sizeof($tmp) - 1], '-------------') !== false) {
113+
/* the log ends with "-----..." remove this */
114+
array_pop($tmp);
115+
}
116+
for ($i = sizeof($tmp) - 1; $i > 0; $i--) {
117+
if (strpos($tmp[$i], '---------') === false) {
118+
/* no delimiter found, so add this to the last-log */
119+
$lastLog[] = $tmp[$i];
120+
} else {
121+
/* delimiter found, so there is no more line left! */
122+
break;
123+
}
122124
}
123125
}
124-
126+
125127
/*
126128
* Now we have the last log in the array.
127129
* Check if the outdated-string is found...

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
3132
class cronjob_monitor_mem_usage extends cronjob {
3233

3334
// job schedule
@@ -74,13 +75,15 @@ public function onRunJob() {
7475
$memInfo = explode("\n", $miData);
7576

7677
foreach ($memInfo as $line) {
77-
$part = preg_split('/:/', $line);
78-
$key = trim($part[0]);
79-
$tmp = explode(' ', trim($part[1]));
80-
$value = 0;
81-
if (isset($tmp[1]) && $tmp[1] == 'kB')
82-
$value = $tmp[0] * 1024;
83-
$data[$key] = $value;
78+
if (strlen($line) >= 1){
79+
$part = preg_split('/:/', $line);
80+
$key = trim($part[0]);
81+
$tmp = explode(' ', trim($part[1]));
82+
$value = 0;
83+
if (isset($tmp[1]) && $tmp[1] == 'kB')
84+
$value = $tmp[0] * 1024;
85+
$data[$key] = $value;
86+
}
8487
}
8588

8689
/*

0 commit comments

Comments
 (0)