Skip to content

Commit 7162553

Browse files
author
vogelor
committed
The monitor now monitors the mailq and (on debian/ubuntu) the update-status
1 parent e3170a1 commit 7162553

File tree

5 files changed

+256
-31
lines changed

5 files changed

+256
-31
lines changed

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'target' => 'content',
1515
'link' => 'monitor/show_sys_state.php?state=system');
1616

17-
$module["nav"][] = array( 'title' => 'System State',
17+
$module["nav"][] = array( 'title' => 'System State (All Servers)',
1818
'open' => 1,
1919
'items' => $items);
2020

@@ -51,8 +51,17 @@
5151
$_SESSION['monitor']['server_name'] = $servers[0]['server_name'];
5252

5353
/*
54-
* Logmonitoring module
54+
* Clear and set the Navigation-Items
5555
*/
56+
unset($items);
57+
58+
$items[] = array( 'title' => "Show CPU info",
59+
'target' => 'content',
60+
'link' => 'monitor/show_data.php?type=cpu_info');
61+
62+
$module["nav"][] = array( 'title' => 'System-Information',
63+
'open' => 1,
64+
'items' => $items);
5665

5766
/*
5867
* Clear and set the Navigation-Items
@@ -61,6 +70,14 @@
6170
$items[] = array( 'title' => "Show Server State",
6271
'target' => 'content',
6372
'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')){
77+
$items[] = array( 'title' => "Show Update State",
78+
'target' => 'content',
79+
'link' => 'monitor/show_data.php?type=system_update');
80+
}
6481

6582
$items[] = array( 'title' => "Show Server Load",
6683
'target' => 'content',
@@ -78,6 +95,9 @@
7895
'target' => 'content',
7996
'link' => 'monitor/show_data.php?type=services');
8097

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

82102
$module["nav"][] = array( 'title' => 'Monitoring',
83103
'open' => 1,
@@ -88,23 +108,6 @@
88108
*/
89109
unset($items);
90110

91-
$items[] = array( 'title' => "Show CPU info",
92-
'target' => 'content',
93-
'link' => 'monitor/show_data.php?type=cpu_info');
94-
95-
$module["nav"][] = array( 'title' => 'System-Information',
96-
'open' => 1,
97-
'items' => $items);
98-
99-
/*
100-
* Logmonitoring module
101-
*/
102-
103-
/*
104-
* Clear and set the Navigation-Items
105-
*/
106-
unset($items);
107-
108111
$items[] = array( 'title' => "Show Mail-Log",
109112
'target' => 'content',
110113
'link' => 'monitor/show_log.php?log=log_mail');

interface/web/monitor/show_data.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@
7272
$title = $app->lng("Status of services").' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
7373
$description = '';
7474
break;
75+
case 'system_update':
76+
$template = 'templates/show_data.htm';
77+
$output .= showSystemUpdate();
78+
$title = "Update State" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
79+
$description = '';
80+
break;
81+
case 'mailq':
82+
$template = 'templates/show_data.htm';
83+
$output .= showMailq();
84+
$title = "Mailq" . ' (Server: ' . $_SESSION['monitor']['server_name'] . ')';
85+
$description = '';
86+
break;
7587
default:
7688
$template = '';
7789
break;

interface/web/monitor/show_sys_state.php

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function _getServerState($serverId, $serverName, $showAll)
142142
/*
143143
* There is no need, to show the "ok" - messages
144144
*/
145-
if ($key != 'ok')
145+
// if ($key != 'ok')
146146
{
147147
$res .= $key . ':<br />';
148148
foreach ($state as $msg)
@@ -278,6 +278,52 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
278278
break;
279279
}
280280
}
281+
if ($type == 'system_update'){
282+
switch ($record['state']) {
283+
case 'ok':
284+
$messages['ok'][] = 'Your System is up to date. ' .
285+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
286+
287+
break;
288+
case 'warning':
289+
$messages['warning'][] = 'One or more Components needs a update ' .
290+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
291+
break;
292+
default:
293+
$messages['unknown'][] = 'System-Updatese:??? ' .
294+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
295+
break;
296+
}
297+
}
298+
299+
if ($type == 'mailq'){
300+
switch ($record['state']) {
301+
case 'ok':
302+
$messages['ok'][] = 'Your Mailq load is ok ' .
303+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
304+
break;
305+
case 'info':
306+
$messages['info'][] = 'Your Mailq in under heavy load ' .
307+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
308+
break;
309+
case 'warning':
310+
$messages['warning'][] = 'Your Mailq in under high load ' .
311+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
312+
break;
313+
case 'critical':
314+
$messages['critical'][] = 'Your Mailq in under higher load ' .
315+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
316+
break;
317+
case 'error':
318+
$messages['error'][] = 'Your Mailq in under highest load ' .
319+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
320+
break;
321+
default:
322+
$messages['unknown'][] = 'Mailq: ??? ' .
323+
"<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
324+
break;
325+
}
326+
}
281327
if ($type == 'log_clamav'){
282328
/* this type has no state */
283329
}
@@ -311,9 +357,9 @@ function _processDbState($type, $serverId, &$serverState, &$messages)
311357
*/
312358
function _setState($oldState, $newState)
313359
{
314-
/*
315-
* Calculate the weight of the old state
316-
*/
360+
/*
361+
* Calculate the weight of the old state
362+
*/
317363
switch ($oldState) {
318364
case 'no_state': $oldInt = 0;
319365
break;
@@ -350,9 +396,9 @@ function _setState($oldState, $newState)
350396
break;
351397
}
352398

353-
/*
354-
* Set to the higher level
355-
*/
399+
/*
400+
* Set to the higher level
401+
*/
356402
if ($newInt > $oldInt){
357403
return $newState;
358404
}

interface/web/monitor/tools.inc.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function showServerLoad(){
1111
/*
1212
Format the data
1313
*/
14-
$html .=
14+
$html =
1515
'<table id="system_load">
1616
<tr>
1717
<td>' . $app->lng("Server online since").':</td>
@@ -53,7 +53,7 @@ function showDiskUsage () {
5353
/*
5454
Format the data
5555
*/
56-
$html .= '<table id="system_disk">';
56+
$html = '<table id="system_disk">';
5757
foreach($data as $line) {
5858
$html .= '<tr>';
5959
foreach ($line as $item) {
@@ -84,7 +84,7 @@ function showMemUsage ()
8484
/*
8585
Format the data
8686
*/
87-
$html .= '<table id="system_memusage">';
87+
$html = '<table id="system_memusage">';
8888

8989
foreach($data as $key => $value){
9090
if ($key != '') {
@@ -115,7 +115,7 @@ function showCpuInfo ()
115115
/*
116116
Format the data
117117
*/
118-
$html .= '<table id="system_cpu">';
118+
$html = '<table id="system_cpu">';
119119
foreach($data as $key => $value){
120120
if ($key != '') {
121121
$html .= '<tr>
@@ -145,7 +145,7 @@ function showServices ()
145145
/*
146146
Format the data
147147
*/
148-
$html .= '<table id="system_services">';
148+
$html = '<table id="system_services">';
149149

150150
if($data['webserver'] != -1) {
151151
if($data['webserver'] == 1) {
@@ -239,6 +239,41 @@ function showServices ()
239239
}
240240

241241

242+
return $html;
243+
}
244+
245+
function showSystemUpdate()
246+
{
247+
global $app;
248+
249+
/* fetch the Data from the DB */
250+
$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");
251+
252+
if(isset($record['data'])) {
253+
$data = unserialize($record['data']);
254+
$html = nl2br($data['output']);
255+
} else {
256+
$html = '<p>' . "No Update-Data available" . '</p>';
257+
}
258+
259+
return $html;
260+
}
261+
262+
263+
function showMailq()
264+
{
265+
global $app;
266+
267+
/* fetch the Data from the DB */
268+
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mailq' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
269+
270+
if(isset($record['data'])) {
271+
$data = unserialize($record['data']);
272+
$html = nl2br($data['output']);
273+
} else {
274+
$html = '<p>' . "No Mailq-Data available" . '</p>';
275+
}
276+
242277
return $html;
243278
}
244279
?>

0 commit comments

Comments
 (0)