Skip to content

Commit 671a41a

Browse files
author
vogelor
committed
monitor: the ispconfig - Log is now part of the system-state
1 parent 9c1b52f commit 671a41a

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

interface/web/monitor/show_sys_state.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,33 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
381381
break;
382382
}
383383
}
384+
385+
if ($type == 'sys_log'){
386+
switch ($record['state']) {
387+
case 'ok':
388+
$messages['ok'][] = 'The System-Log is O.K. ' .
389+
"<a href='#' onclick='loadContent(\"monitor/log_list.php\");'>[more...]</a>";
390+
break;
391+
case 'warning':
392+
$messages['warning'][] = 'There are some warnings in your System-Log ' .
393+
"<a href='#' onclick='loadContent(\"monitor/log_list.php\");'>[more...]</a>";
394+
break;
395+
case 'error':
396+
$messages['error'][] = 'There are errors in your System-Log ' .
397+
"<a href='#' onclick='loadContent(\"monitor/log_list.php\");'>[more...]</a>";
398+
break;
399+
default:
400+
$messages['unknown'][] = 'sys-log:??? ' .
401+
"<a href='#' onclick='loadContent(\"monitor/log_list.php\");'>[more...]</a>";
402+
break;
403+
}
404+
}
405+
384406
if ($type == 'log_clamav'){
385407
/* this type has no state */
386408
}
387-
if ($type == 'log_freshclam'){
409+
410+
if ($type == 'log_freshclam'){
388411
switch ($record['state']) {
389412
case 'ok':
390413
$messages['ok'][] = 'Your Virus-protection is ok ' .
@@ -400,6 +423,7 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
400423
break;
401424
}
402425
}
426+
403427
if ($type == 'log_ispconfig'){
404428
/* this type has no state */
405429
}

server/mods-available/monitor_core_module.inc.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ function doMonitor()
120120
$this->monitorMailQueue();
121121
$this->monitorRaid();
122122
$this->monitorRkHunter();
123+
$this->monitorSysLog();
123124
}
124125

125126
function monitorServer(){
@@ -729,7 +730,49 @@ function monitorRkHunter(){
729730
$this->_delOldRecords($type, 0, 2);
730731
}
731732

732-
function monitorMailLog()
733+
function monitorSysLog(){
734+
global $app;
735+
global $conf;
736+
737+
/* the id of the server as int */
738+
$server_id = intval($conf["server_id"]);
739+
740+
/** The type of the data */
741+
$type = 'sys_log';
742+
743+
/*
744+
* is there any warning or error for this server?
745+
*/
746+
$state = 'ok';
747+
$dbData = $app->dbmaster->queryAllRecords("SELECT loglevel FROM sys_log WHERE server_id = " . $server_id . " AND loglevel > 0");
748+
if (is_array($dbData)) {
749+
foreach($dbData as $item){
750+
if ($item['loglevel'] == 1) $state = $this->_setState($state, 'warning');
751+
if ($item['loglevel'] == 2) $state = $this->_setState($state, 'error');
752+
}
753+
}
754+
755+
/** There is no monitor-data because the data is in the sys_log table */
756+
$data['output']= '';
757+
758+
/*
759+
* Insert the data into the database
760+
*/
761+
$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
762+
"VALUES (".
763+
$server_id . ", " .
764+
"'" . $app->dbmaster->quote($type) . "', " .
765+
time() . ", " .
766+
"'" . $app->dbmaster->quote(serialize($data)) . "', " .
767+
"'" . $state . "'" .
768+
")";
769+
$app->dbmaster->query($sql);
770+
771+
/* The new data is written, now we can delete the old one */
772+
$this->_delOldRecords($type, 10);
773+
}
774+
775+
function monitorMailLog()
733776
{
734777
global $app;
735778
global $conf;

0 commit comments

Comments
 (0)