tbrehm
2013-09-05 71accc61eb6474935434e2973e360a63dec8112e
- Added DB size report in monitor. Thanks to Florian for the patch!
5 files modified
65 ■■■■■ changed files
interface/lib/classes/functions.inc.php 10 ●●●● patch | view | raw | blame | history
interface/lib/classes/tools_monitor.inc.php 38 ●●●●● patch | view | raw | blame | history
interface/web/monitor/lib/lang/en.lng 5 ●●●●● patch | view | raw | blame | history
interface/web/monitor/lib/module.conf.php 5 ●●●●● patch | view | raw | blame | history
interface/web/monitor/show_data.php 7 ●●●●● patch | view | raw | blame | history
interface/lib/classes/functions.inc.php
@@ -322,7 +322,13 @@
            return intval($string);
        }
    }
    public function formatBytes($size, $precision = 2) {
        $base=log($size)/log(1024);
        $suffixes=array('','k','M','G','T');
        return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)];
    }
    /** IDN converter wrapper.
     * all converter classes should be placed in ISPC_CLASS_PATH.'/idn/'
     */
@@ -395,4 +401,4 @@
        
}
?>
?>
interface/lib/classes/tools_monitor.inc.php
@@ -118,6 +118,44 @@
        return $html;
    }
    function showDatabaseSize () {
    global $app;
    /* fetch the Data from the DB */
    $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
    if(isset($record['data'])) {
        $data = unserialize($record['data']);
        /*
                Format the data
                */
                $html =
                   '<div class="systemmonitor-state state-'.$record['state'].'">
                    <div class="systemmonitor-content icons32 ico-'.$record['state'].'">
                    <table>
                    <thead>
                    <tr>
                    <td>'.$app->lng("monitor_database_name_txt").'</td>
                    <td>'.$app->lng("monitor_database_size_txt").'</td>
                    <td>'.$app->lng("monitor_database_client_txt").'</td>
                    </tr>';
                foreach($data as $line) {
                    $html .= '<tr>';
                    if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']);
                    $t=$app->db->queryOneRecord("SELECT username FROM client WHERE sys_groupid = ".$line['client_id']);
                    $line['client_id']=$t['username'];
                    unset($t);
                    foreach ($line as $item) {
                $html .= '<td>' . $item . '</td>';
                    }
                    $html .= '</tr></tmpl loop>';
                }
                $html .= '</tbody></table>';
                $html .= '</div></div>';
        } else {
                $html = '<p>'.$app->lng("no_data_database_size_txt").'</p>';
        }
        return $html;
    }
    function showMemUsage () {
        global $app;
interface/web/monitor/lib/lang/en.lng
@@ -10,6 +10,7 @@
$wb['no_data_serverload_txt'] = 'No data about the server load available at the moment. Please check again later.';
$wb['no_data_memusage_txt'] = 'No data about the memory usage available at the moment. Please check again later.';
$wb['no_data_diskusage_txt'] = 'No data about the disk usage available at the moment. Please check again later.';
$wb['no_data_database_size_txt'] = 'No data about the database usage available at the moment. Please check again later.';
$wb['no_data_cpuinfo_txt'] = 'No data about the CPU available at the moment. Please check again later.';
$wb['no_data_services_txt'] = 'No data about the services available at the moment. Please check again later.';
$wb['no_data_updates_txt'] = 'No data about updates available at the moment. Please check again later.';
@@ -58,6 +59,10 @@
$wb['monitor_diskusage_available_txt'] = 'Available';
$wb['monitor_diskusage_usage_txt'] = 'Use%';
$wb['monitor_diskusage_mounted_txt'] = 'Mounted on';
$wb['monitor_database_name_txt'] = 'Database';
$wb['monitor_database_size_txt'] = 'Size';
$wb['monitor_database_client_txt'] = 'Client';
$wb['monitor_database_domain_txt'] = 'Domain';
$wb['monitor_logs_mail_txt'] = 'Mail - Log';
$wb['monitor_logs_mailwarn_txt'] = 'Mail-Warn - Log';
$wb['monitor_logs_mailerr_txt'] = 'Mail-Error - Log';
interface/web/monitor/lib/module.conf.php
@@ -106,6 +106,11 @@
                  'link'    => 'monitor/show_data.php?type=disk_usage',
                  'html_id' => 'disk_usage');
$items[] = array( 'title'       => "Show MySQL Database size",
                  'target'      => 'content',
                  'link'        => 'monitor/show_data.php?type=database_size',
                  'html_id' => 'database_usage');
$items[] = array( 'title'     => "Show Memory usage",
                  'target'     => 'content',
                  'link'    => 'monitor/show_data.php?type=mem_usage',
interface/web/monitor/show_data.php
@@ -61,6 +61,13 @@
        $title = $app->lng("Disk usage").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
        $description = '';
        break;
    case 'database_size':
        $template = 'templates/show_data.htm';
        $output .= $app->tools_monitor->showDatabaseSize();
        $time = $app->tools_monitor->getDataTime('database_size');
        $title = $app->lng("Database size").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
        $description = '';
        break;
    case 'mem_usage':
        $template = 'templates/show_data.htm';
        $output .= $app->tools_monitor->showMemUsage();