tbrehm
2008-12-09 eaa00d8cb42b07a7f6a6c48504e94edb552df97d
interface/web/monitor/show_sys_state.php
@@ -55,16 +55,37 @@
{
    $output = _getServerState($_SESSION['monitor']['server_id'], $_SESSION['monitor']['server_name'], true);
    $title = "Server State";
    $stateType = 'server';
}
else
{
    $output = _getSysState();
    $title = "System State";
    $stateType = 'system';
}
$app->tpl->setVar("state_data",$output);
$app->tpl->setVar("state_type",$stateType);
$app->tpl->setVar("title",$title);
$app->tpl->setVar("description",$description);
/*
 Creating the array with the refresh intervals
 Attention: the core-moule ist triggered every 5 minutes,
            so reload every 2 minutes is impossible!
*/
$refresh = (isset($_GET["refresh"]))?intval($_GET["refresh"]):0;
$refresh_values = array('0' => '- '.$app->lng("No Refresh").' -','5' => '5 '.$app->lng("minutes"),'10' => '10 '.$app->lng("minutes"),'15' => '15 '.$app->lng("minutes"),'30' => '30 '.$app->lng("minutes"),'60' => '60 '.$app->lng("minutes"));
$tmp = '';
foreach($refresh_values as $key => $val) {
   if($key == $refresh) {
      $tmp .= "<option value='$key' SELECTED>$val</option>";
   } else {
      $tmp .= "<option value='$key'>$val</option>";
   }
}
$app->tpl->setVar("refresh",$tmp);
/*
 * doing the output
@@ -98,7 +119,7 @@
    global $app;
    /*  The State of the server */
    $serverState = 'unknown';
    $serverState = 'ok';
    /** The Number of several infos, warnings, errors, ... */
    $count = array('unknown' => 0, 'info' => 0, 'warning' => 0, 'critical' => 0, 'error' => 0);
@@ -118,9 +139,9 @@
        _processDbState($record['type'], $serverId, &$serverState, &$messages);
    }
    $res .= '<div class="systemmonitor-state systemmonitor-state-' . $serverState . '">';
    $res .= '<div class="systemmonitor-serverstate">';
    $res .= '<div class="systemmonitor-state-' . $serverState . '-icon">';
    $res .= '<div class="systemmonitor-state state-'.$serverState.'">';
    $res .= '<div class="systemmonitor-device device-server">';
    $res .= '<div class="systemmonitor-content icons32 ico-'.$serverState.'">';
    $res .= 'Server: ' . $serverName . '<br />';
    $res .= 'State: ' . $serverState . '<br />';
    //        $res .= sizeof($messages['ok']) . ' ok | ';
@@ -142,7 +163,7 @@
            /*
             * There is no need, to show the "ok" - messages
             */
            if ($key != 'ok')
//            if ($key != 'ok')
            {
                $res .= $key . ':<br />';
                foreach ($state as $msg)
@@ -168,9 +189,9 @@
        /*
         * Show some state-info
         */
        $res .= showServerLoad();
        $res .= '&nbsp;'. showDiskUsage();
        $res .= '&nbsp;'.showServices();
        //$res .= showServerLoad();
        //$res .= '&nbsp;'. showDiskUsage();
        //$res .= '&nbsp;'.showServices();
    }
@@ -264,7 +285,7 @@
    if ($type == 'services'){
        switch ($record['state']) {
            case 'ok':
                $messages['error'][] = 'All needed Services are online ' .
                $messages['ok'][] = 'All needed Services are online ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=services\");'>[more...]</a>";
                break;
@@ -278,11 +299,106 @@
                break;
        }
    }
    if ($type == 'system_update'){
        switch ($record['state']) {
            case 'ok':
                $messages['ok'][] = 'Your System is up to date. ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
                break;
            case 'warning':
                $messages['warning'][] = 'One or more Components needs a update ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
                break;
            case 'no_state':
                /*
                 *  not debian and not Ubuntu, so the state could not be monitored...
                 */
                break;
            default:
                $messages['unknown'][] = 'System-Update:??? ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=system_update\");'>[more...]</a>";
                break;
        }
    }
    if ($type == 'raid_state'){
        switch ($record['state']) {
            case 'ok':
                $messages['ok'][] = 'Your RAID is ok ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
                break;
            case 'info':
                $messages['info'][] = 'Your RAID is in RESYNC mode ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
                break;
            case 'critical':
                $messages['critical'][] = 'Your RAID has one FAULT disk. Replace as soon as possible! '.
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
                break;
            case 'error':
                $messages['error'][] = 'Your RAID is not working anymore ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
                break;
            case 'no_state':
                /*
                 *  mdadm is not installed or the RAID is not supported...
                 */
                break;
            default:
                $messages['unknown'][] = 'RAID state: ??? ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=raid_state\");'>[more...]</a>";
                break;
        }
    }
    if ($type == 'mailq'){
        switch ($record['state']) {
            case 'ok':
                $messages['ok'][] = 'Your Mailq load is ok ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
                break;
            case 'info':
                $messages['info'][] = 'Your Mailq in under heavy load ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
                break;
            case 'warning':
                $messages['warning'][] = 'Your Mailq in under high load ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
                break;
            case 'critical':
                $messages['critical'][] = 'Your Mailq in under higher load ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
                break;
            case 'error':
                $messages['error'][] = 'Your Mailq in under highest load ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
                break;
            default:
                $messages['unknown'][] = 'Mailq: ??? ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=mailq\");'>[more...]</a>";
                break;
        }
    }
    if ($type == 'log_clamav'){
        /* this type has no state */
    }
    if ($type == 'log_freshclam'){
        /* this type has no state */
        switch ($record['state']) {
            case 'ok':
                $messages['ok'][] = 'Your Virus-protection is ok ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_log.php?log=log_freshclam\");'>[more...]</a>";
                break;
            case 'warning':
                $messages['warning'][] = 'Your Virus-protection is OUTDATED! ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_log.php?log=log_freshclam\");'>[more...]</a>";
                break;
            default:
                $messages['unknown'][] = 'Freshclam: ???! ' .
                                    "<a href='#' onclick='loadContent(\"monitor/show_log.php?log=log_freshclam\");'>[more...]</a>";
                break;
        }
    }
    if ($type == 'log_ispconfig'){
        /* this type has no state */
@@ -299,6 +415,9 @@
    if ($type == 'log_messages'){
        /* this type has no state */
    }
    if ($type == 'rkhunter'){
        /* this type has no state */
    }
}
 /*
@@ -311,15 +430,15 @@
  */
function _setState($oldState, $newState)
{
        /*
         * Calculate the weight of the old state
         */
   /*
    * Calculate the weight of the old state
    */
    switch ($oldState) {
        case 'no_state': $oldInt = 0;
            break;
        case 'unknown': $oldInt = 1;
        case 'ok': $oldInt = 1;
            break;
        case 'ok': $oldInt = 2;
        case 'unknown': $oldInt = 2;
            break;
        case 'info': $oldInt = 3;
            break;
@@ -350,9 +469,9 @@
            break;
    }
        /*
         * Set to the higher level
         */
   /*
    * Set to the higher level
    */
    if ($newInt > $oldInt){
        return $newState;
    }