Skip to content

Commit 36d3079

Browse files
author
vogelor
committed
monitor now monitors RAID
changed the menu (hopefully now better to understand) fixed some small errors in update-state
1 parent 7dda468 commit 36d3079

File tree

5 files changed

+337
-46
lines changed

5 files changed

+337
-46
lines changed

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$module["startpage"] = "monitor/show_sys_state.php?state=system";
1111

1212
unset($items);
13-
$items[] = array( 'title' => "Show System State",
13+
$items[] = array( 'title' => "Show Overview",
1414
'target' => 'content',
1515
'link' => 'monitor/show_sys_state.php?state=system');
1616

@@ -59,27 +59,27 @@
5959
'target' => 'content',
6060
'link' => 'monitor/show_data.php?type=cpu_info');
6161

62-
$module["nav"][] = array( 'title' => 'System-Information',
62+
$module["nav"][] = array( 'title' => 'Hardware-Information',
6363
'open' => 1,
6464
'items' => $items);
6565

6666
/*
6767
* Clear and set the Navigation-Items
6868
*/
6969
unset($items);
70-
$items[] = array( 'title' => "Show Server State",
70+
$items[] = array( 'title' => "Show Overview",
7171
'target' => 'content',
7272
'link' => 'monitor/show_sys_state.php?state=server');
73-
/*
74-
* The next menu is only available at debian or Ubuntu
75-
*/
76-
if(file_exists('/etc/debian_version')){
73+
7774
$items[] = array( 'title' => "Show Update State",
7875
'target' => 'content',
7976
'link' => 'monitor/show_data.php?type=system_update');
80-
}
8177

82-
$items[] = array( 'title' => "Show Server Load",
78+
$items[] = array( 'title' => "Show RAID state",
79+
'target' => 'content',
80+
'link' => 'monitor/show_data.php?type=raid_state');
81+
82+
$items[] = array( 'title' => "Show Server load",
8383
'target' => 'content',
8484
'link' => 'monitor/show_data.php?type=server_load');
8585

@@ -95,11 +95,8 @@
9595
'target' => 'content',
9696
'link' => 'monitor/show_data.php?type=services');
9797

98-
$items[] = array( 'title' => "Show Mailq",
99-
'target' => 'content',
100-
'link' => 'monitor/show_data.php?type=mailq');
10198

102-
$module["nav"][] = array( 'title' => 'Monitoring',
99+
$module["nav"][] = array( 'title' => 'Server State',
103100
'open' => 1,
104101
'items' => $items);
105102

@@ -108,6 +105,10 @@
108105
*/
109106
unset($items);
110107

108+
$items[] = array( 'title' => "Show Mail-Queue",
109+
'target' => 'content',
110+
'link' => 'monitor/show_data.php?type=mailq');
111+
111112
$items[] = array( 'title' => "Show Mail-Log",
112113
'target' => 'content',
113114
'link' => 'monitor/show_log.php?log=log_mail');
@@ -136,6 +137,9 @@
136137
'target' => 'content',
137138
'link' => 'monitor/show_log.php?log=log_ispconfig');
138139

140+
//$items[] = array( 'title' => "Show RKHunter-Log",
141+
// 'target' => 'content',
142+
// 'link' => 'monitor/show_data.php?type=rkhunter');
139143

140144
$module["nav"][] = array( 'title' => 'Logfiles',
141145
'open' => 1,

interface/web/monitor/show_data.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@
8484
$title = "Mailq" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
8585
$description = '';
8686
break;
87+
case 'raid_state':
88+
$template = 'templates/show_data.htm';
89+
$output .= showRaidState();
90+
$title = "RAID-State" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
91+
$description = '';
92+
break;
93+
case 'rkhunter':
94+
$template = 'templates/show_data.htm';
95+
$output .= showRKHunter();
96+
$title = "RKHunter-Log" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
97+
$description = '';
98+
break;
8799
default:
88100
$template = '';
89101
break;

interface/web/monitor/show_sys_state.php

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ function _getServerState($serverId, $serverName, $showAll)
168168
/*
169169
* Show some state-info
170170
*/
171-
$res .= showServerLoad();
172-
$res .= ' '. showDiskUsage();
173-
$res .= ' '.showServices();
171+
//$res .= showServerLoad();
172+
//$res .= ' '. showDiskUsage();
173+
//$res .= ' '.showServices();
174174
}
175175

176176

@@ -289,13 +289,49 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
289289
$messages['warning'][] = 'One or more Components needs a update ' .
290290
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
291291
break;
292+
case 'no_state':
293+
/*
294+
* not debian and not Ubuntu, so the state could not be monitored...
295+
*/
296+
break;
292297
default:
293-
$messages['unknown'][] = 'System-Updatese:??? ' .
298+
$messages['unknown'][] = 'System-Update:??? ' .
294299
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
295300
break;
296301
}
297302
}
298303

304+
if ($type == 'raid_state'){
305+
switch ($record['state']) {
306+
case 'ok':
307+
$messages['ok'][] = 'Your RAID is ok ' .
308+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
309+
break;
310+
case 'info':
311+
$messages['info'][] = 'Your RAID is in RESYNC mode ' .
312+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
313+
break;
314+
case 'critical':
315+
$messages['critical'][] = 'Your RAID has one FAULT disk. Replace as soon as possible! '.
316+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
317+
break;
318+
case 'error':
319+
$messages['error'][] = 'Your RAID is not working anymore ' .
320+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
321+
break;
322+
case 'no_state':
323+
/*
324+
* mdadm is not installed or the RAID is not supported...
325+
*/
326+
break;
327+
default:
328+
$messages['unknown'][] = 'RAID state: ??? ' .
329+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
330+
break;
331+
}
332+
}
333+
334+
299335
if ($type == 'mailq'){
300336
switch ($record['state']) {
301337
case 'ok':

interface/web/monitor/tools.inc.php

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
<?php
2+
/*
3+
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
229
function showServerLoad(){
330
global $app;
431

@@ -250,15 +277,49 @@ function showSystemUpdate()
250277
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'system_update' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
251278

252279
if(isset($record['data'])) {
253-
$data = unserialize($record['data']);
254-
$html = nl2br($data['output']);
280+
/*
281+
* First, we have to detect, if there is any monitoring-data.
282+
* If not (because the destribution is not supported) show this.
283+
*/
284+
if ($record['state'] == 'no_state'){
285+
$html = '<p>' . "Your distribution is not supported for this monitoring" . '</p>';
286+
}
287+
else {
288+
$data = unserialize($record['data']);
289+
$html = nl2br($data['output']);
290+
}
255291
} else {
256292
$html = '<p>' . "No Update-Data available" . '</p>';
257293
}
258294

259295
return $html;
260296
}
261297

298+
function showRaidState()
299+
{
300+
global $app;
301+
302+
/* fetch the Data from the DB */
303+
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'raid_state' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
304+
305+
if(isset($record['data'])) {
306+
/*
307+
* First, we have to detect, if there is any monitoring-data.
308+
* If not (because the destribution is not supported) show this.
309+
*/
310+
if ($record['state'] == 'no_state'){
311+
$html = '<p>' . "mdadm ist not installed or your Server has no supported RAID" . '</p>';
312+
}
313+
else {
314+
$data = unserialize($record['data']);
315+
$html = nl2br($data['output']);
316+
}
317+
} else {
318+
$html = '<p>' . "No RAID-Data available" . '</p>';
319+
}
320+
321+
return $html;
322+
}
262323

263324
function showMailq()
264325
{

0 commit comments

Comments
 (0)