Skip to content

Commit fb4c27e

Browse files
author
vogelor
committed
The monitor now shows the date of the data (to determine how old they are)
Fixed some bugs and improved the RAID - monitor Fixed the user count in the monitor The monitor now monitors the rkhunter - log too The monitor now deletes the old data AFTER writing the new one, so there are always data in the db
1 parent 91bc8ea commit fb4c27e

File tree

9 files changed

+250
-166
lines changed

9 files changed

+250
-166
lines changed

interface/web/monitor/lib/module.conf.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@
133133
'target' => 'content',
134134
'link' => 'monitor/show_log.php?log=log_clamav');
135135

136+
$items[] = array( 'title' => "Show RKHunter-Log",
137+
'target' => 'content',
138+
'link' => 'monitor/show_data.php?type=rkhunter');
139+
136140
$items[] = array( 'title' => "Show ISPConfig-Log",
137141
'target' => 'content',
138142
'link' => 'monitor/show_log.php?log=log_ispconfig');
139143

140-
//$items[] = array( 'title' => "Show RKHunter-Log",
141-
// 'target' => 'content',
142-
// 'link' => 'monitor/show_data.php?type=rkhunter');
143-
144144
$module["nav"][] = array( 'title' => 'Logfiles',
145145
'open' => 1,
146146
'items' => $items);

interface/web/monitor/show_data.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,54 +45,63 @@
4545
case 'server_load':
4646
$template = 'templates/show_data.htm';
4747
$output .= showServerLoad();
48+
$time = getDataTime('server_load');
4849
$title = $app->lng("Server Load").' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
4950
$description = '';
5051
break;
5152
case 'disk_usage':
5253
$template = 'templates/show_data.htm';
5354
$output .= showDiskUsage();
55+
$time = getDataTime('disk_usage');
5456
$title = $app->lng("Disk usage").' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
5557
$description = '';
5658
break;
5759
case 'mem_usage':
5860
$template = 'templates/show_data.htm';
5961
$output .= showMemUsage();
62+
$time = getDataTime('mem_usage');
6063
$title = $app->lng("Memory usage").' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
6164
$description = '';
6265
break;
6366
case 'cpu_info':
6467
$template = 'templates/show_data.htm';
6568
$output .= showCpuInfo();
69+
$time = getDataTime('cpu_info');
6670
$title = $app->lng("CPU info").' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
6771
$description = '';
6872
break;
6973
case 'services':
7074
$template = 'templates/show_data.htm';
7175
$output .= showServices();
76+
$time = getDataTime('services');
7277
$title = $app->lng("Status of services").' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
7378
$description = '';
7479
break;
7580
case 'system_update':
7681
$template = 'templates/show_data.htm';
7782
$output .= showSystemUpdate();
83+
$time = getDataTime('system_update');
7884
$title = "Update State" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
7985
$description = '';
8086
break;
8187
case 'mailq':
8288
$template = 'templates/show_data.htm';
8389
$output .= showMailq();
90+
$time = getDataTime('mailq');
8491
$title = "Mailq" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
8592
$description = '';
8693
break;
8794
case 'raid_state':
8895
$template = 'templates/show_data.htm';
8996
$output .= showRaidState();
97+
$time = getDataTime('raid_state');
9098
$title = "RAID-State" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
9199
$description = '';
92100
break;
93101
case 'rkhunter':
94102
$template = 'templates/show_data.htm';
95103
$output .= showRKHunter();
104+
$time = getDataTime('rkhunter');
96105
$title = "RKHunter-Log" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
97106
$description = '';
98107
break;
@@ -105,12 +114,12 @@
105114
// Loading the template
106115
$app->uses('tpl');
107116
$app->tpl->newTemplate("form.tpl.htm");
108-
$app->tpl->setInclude('content_tpl',$template);
109-
110-
$app->tpl->setVar("output",$output);
111-
$app->tpl->setVar("title",$title);
112-
$app->tpl->setVar("description",$description);
117+
$app->tpl->setInclude('content_tpl', $template);
113118

119+
$app->tpl->setVar("output", $output);
120+
$app->tpl->setVar("title", $title);
121+
$app->tpl->setVar("description", $description);
122+
$app->tpl->setVar("time", $time);
114123

115124
$app->tpl_defaults();
116125
$app->tpl->pparse();

interface/web/monitor/show_log.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
require_once('../../lib/config.inc.php');
3232
require_once('../../lib/app.inc.php');
33+
require_once('tools.inc.php');
3334

3435
//* Check permissions for module
3536
$app->auth->check_module_permissions('monitor');
@@ -114,7 +115,7 @@
114115

115116
$app->tpl->setVar("title", $title);
116117
$app->tpl->setVar("log_id",$logId);
117-
118+
$app->tpl->setVar("time", getDataTime($logId));
118119

119120
$app->tpl_defaults();
120121
$app->tpl->pparse();

interface/web/monitor/show_sys_state.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,20 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
385385
/* this type has no state */
386386
}
387387
if ($type == 'log_freshclam'){
388-
/* this type has no state */
388+
switch ($record['state']) {
389+
case 'ok':
390+
$messages['ok'][] = 'Your Virus-protection is ok ' .
391+
"<a href='#' onclick='loadContent(\"monitor/show_log.php?log=log_freshclam\");'>[more...]</a>";
392+
break;
393+
case 'warning':
394+
$messages['warning'][] = 'Your Virus-protection is OUTDATED! ' .
395+
"<a href='#' onclick='loadContent(\"monitor/show_log.php?log=log_freshclam\");'>[more...]</a>";
396+
break;
397+
default:
398+
$messages['unknown'][] = 'Freshclam: ???! ' .
399+
"<a href='#' onclick='loadContent(\"monitor/show_log.php?log=log_freshclam\");'>[more...]</a>";
400+
break;
401+
}
389402
}
390403
if ($type == 'log_ispconfig'){
391404
/* this type has no state */
@@ -402,6 +415,9 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
402415
if ($type == 'log_messages'){
403416
/* this type has no state */
404417
}
418+
if ($type == 'rkhunter'){
419+
/* this type has no state */
420+
}
405421
}
406422

407423
/*

interface/web/monitor/templates/show_data.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ <h2><tmpl_var name="title"></h2>
33
<div class="panel panel_system">
44

55
<div class="pnl_formarea">
6-
<fieldset><legend></legend>
6+
<fieldset><legend>Data from: <tmpl_var name="time"></legend>
77
<div class="systemmonitor"><tmpl_var name="output"></div>
88
</fieldset>
99
</div>

interface/web/monitor/templates/show_log.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2><tmpl_var name="title"></h2>
1111
</div>
1212

1313
<div class="pnl_formarea">
14-
<fieldset><legend></legend>
14+
<fieldset><legend>Data from: <tmpl_var name="time"></legend>
1515
<div class="codeview"><tmpl_var name="log_data"></div>
1616
</fieldset>
1717
</div>

interface/web/monitor/templates/show_sys_state.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2><tmpl_var name="title"></h2>
1111
</div>
1212

1313
<div class="pnl_formarea">
14-
<fieldset><!-- legend>Sys-State</legend -->
14+
<fieldset><legend></legend>
1515
<div class="stateview"><tmpl_var name="state_data"></div>
1616
</fieldset>
1717
</div>

interface/web/monitor/tools.inc.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,38 @@ function showRaidState()
359359
return $html;
360360
}
361361

362+
function showRKHunter()
363+
{
364+
global $app;
365+
366+
/* fetch the Data from the DB */
367+
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'rkhunter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
368+
369+
if(isset($record['data'])) {
370+
$html =
371+
'<div class="systemmonitor-state systemmonitor-state-' . $record['state'] . '">
372+
<div class="systemmonitor-state-' . $record['state'] . '-icon">';
373+
374+
/*
375+
* First, we have to detect, if there is any monitoring-data.
376+
* If not (because the destribution is not supported) show this.
377+
*/
378+
$data = unserialize($record['data']);
379+
if ($data['output'] == ''){
380+
$html .= '<p>' . "rkhunter ist not installed, so there is no log data" . '</p>';
381+
}
382+
else {
383+
$html .= nl2br($data['output']);
384+
}
385+
$html .= '</div></div>';
386+
387+
} else {
388+
$html = '<p>' . "No RKHunter-Data available" . '</p>';
389+
}
390+
391+
return $html;
392+
}
393+
362394
function showMailq()
363395
{
364396
global $app;
@@ -375,4 +407,18 @@ function showMailq()
375407

376408
return $html;
377409
}
410+
411+
function getDataTime($type) {
412+
global $app;
413+
414+
/* fetch the Data from the DB */
415+
$record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
416+
417+
if(isset($record['created'])) {
418+
$res = date('Y-m-d H:i', $record['created']);
419+
} else {
420+
$res = '????-??-?? ??:??';
421+
}
422+
return $res;
423+
}
378424
?>

0 commit comments

Comments
 (0)