Skip to content
Commits on Source (2)
  • Nephiaust's avatar
    Fixed warning for mem checks · cb8bd37a
    Nephiaust authored
    
    (Added check to test if line is gt than 1 character)
    
    PHP Warning:  Undefined array key 1 in /usr/local/ispconfig/server/lib/classes/cron.d/100-monitor_mem_usage.inc.php on line 79
    
    PHP Deprecated:  trim(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/ispconfig/server/lib/classes/cron.d/100-monitor_mem_usage.inc.php on line 79
    
    Signed-off-by: default avatarNephiaust <29741794+Nephiaust@users.noreply.github.com>
    cb8bd37a
  • Nephiaust's avatar
    Fixed deprecated warning on log · a2effad1
    Nephiaust authored
    
    Added check of array to be a minimum of 2
    
    PHP Warning:  Undefined array key -1 in /usr/local/ispconfig/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php on line 111
    
    PHP Deprecated:  strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/local/ispconfig/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php on line 111
    
    Signed-off-by: default avatarNephiaust <29741794+Nephiaust@users.noreply.github.com>
    a2effad1
......@@ -104,24 +104,26 @@ class cronjob_monitor_clamav_log extends cronjob {
$tmp = explode("\n", $data);
$lastLog = array();
if ($tmp[sizeof($tmp) - 1] == '') {
/* the log ends with an empty line remove this */
array_pop($tmp);
}
if (strpos($tmp[sizeof($tmp) - 1], '-------------') !== false) {
/* the log ends with "-----..." remove this */
array_pop($tmp);
}
for ($i = sizeof($tmp) - 1; $i > 0; $i--) {
if (strpos($tmp[$i], '---------') === false) {
/* no delimiter found, so add this to the last-log */
$lastLog[] = $tmp[$i];
} else {
/* delimiter found, so there is no more line left! */
break;
if (count($tmp) >= 2) {
if ($tmp[sizeof($tmp) - 1] == '') {
/* the log ends with an empty line remove this */
array_pop($tmp);
}
if (strpos($tmp[sizeof($tmp) - 1], '-------------') !== false) {
/* the log ends with "-----..." remove this */
array_pop($tmp);
}
for ($i = sizeof($tmp) - 1; $i > 0; $i--) {
if (strpos($tmp[$i], '---------') === false) {
/* no delimiter found, so add this to the last-log */
$lastLog[] = $tmp[$i];
} else {
/* delimiter found, so there is no more line left! */
break;
}
}
}
/*
* Now we have the last log in the array.
* Check if the outdated-string is found...
......
......@@ -28,6 +28,8 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
use IDS\Event;
class cronjob_monitor_mem_usage extends cronjob {
// job schedule
......@@ -74,13 +76,15 @@ class cronjob_monitor_mem_usage extends cronjob {
$memInfo = explode("\n", $miData);
foreach ($memInfo as $line) {
$part = preg_split('/:/', $line);
$key = trim($part[0]);
$tmp = explode(' ', trim($part[1]));
$value = 0;
if (isset($tmp[1]) && $tmp[1] == 'kB')
$value = $tmp[0] * 1024;
$data[$key] = $value;
if (strlen($line) >= 1){
$part = preg_split('/:/', $line);
$key = trim($part[0]);
$tmp = explode(' ', trim($part[1]));
$value = 0;
if (isset($tmp[1]) && $tmp[1] == 'kB')
$value = $tmp[0] * 1024;
$data[$key] = $value;
}
}
/*
......