~ubuntu-branches/ubuntu/lucid/phpmyadmin/lucid

« back to all changes in this revision

Viewing changes to server_status.php

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-03-08 15:25:00 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100308152500-6e8hmuqc5co39de5
Tags: 4:3.3.0-1
* New upstream version.
* Rediff debian/patches.
* Fix permissions on mediawiki export extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * displays status variables with descriptions and some hints an optmizing
5
5
 *  + reset status variables
6
6
 *
7
 
 * @version $Id: server_status.php 12727 2009-07-26 11:39:39Z helmo $
 
7
 * @version $Id: server_status.php 13259 2010-01-19 19:40:20Z lem9 $
8
8
 * @package phpMyAdmin
9
9
 */
10
10
 
28
28
 */
29
29
require './libraries/server_links.inc.php';
30
30
 
 
31
/**
 
32
 * Replication library
 
33
 */
 
34
require './libraries/replication.inc.php';
 
35
require_once './libraries/replication_gui.lib.php';
31
36
 
32
37
/**
33
38
 * Displays the sub-page heading
65
70
$server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
66
71
 
67
72
/**
68
 
 * get master status from server
69
 
 */
70
 
$server_master_status = PMA_DBI_fetch_result('SHOW MASTER STATUS'); 
71
 
 
72
 
/**
73
 
 * get slave status from server
74
 
 */
75
 
$server_slave_status = PMA_DBI_fetch_result('SHOW SLAVE STATUS'); 
76
 
 
77
 
 
78
 
/**
79
73
 * for some calculations we require also some server settings
80
74
 */
81
75
$server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
263
257
    'tc'            => array('title' => $strTransactionCoordinator),
264
258
);
265
259
 
266
 
/** 
267
 
  * replication types
268
 
  */
269
 
$replication_types = array('master', 'slave');
270
 
 
271
 
/**
272
 
  * define variables for master status
273
 
  */
274
 
$master_variables = array(
275
 
                      'File',
276
 
                      'Position',
277
 
                      'Binlog_Do_DB',
278
 
                      'Binlog_Ignore_DB'
279
 
);
280
 
 
281
 
/**
282
 
  * Define variables for slave status
283
 
  */
284
 
$slave_variables  = array(
285
 
                      'Slave_IO_State',
286
 
                      'Master_Host',
287
 
                      'Master_User',
288
 
                      'Master_Port',
289
 
                      'Connect_Retry',
290
 
                      'Master_Log_File',
291
 
                      'Read_Master_Log_Pos',
292
 
                      'Relay_Log_File',
293
 
                      'Relay_Log_Pos',
294
 
                      'Relay_Master_Log_File',
295
 
                      'Slave_IO_Running',
296
 
                      'Slave_SQL_Running',
297
 
                      'Replicate_Do_DB',
298
 
                      'Replicate_Ignore_DB',
299
 
                      'Replicate_Do_Table',
300
 
                      'Replicate_Ignore_Table',
301
 
                      'Replicate_Wild_Do_Table',
302
 
                      'Replicate_Wild_Ignore_Table',
303
 
                      'Last_Errno',
304
 
                      'Last_Error',
305
 
                      'Skip_Counter',
306
 
                      'Exec_Master_Log_Pos',
307
 
                      'Relay_Log_Space',
308
 
                      'Until_Condition',
309
 
                      'Until_Log_File',
310
 
                      'Until_Log_Pos',
311
 
                      'Master_SSL_Allowed',
312
 
                      'Master_SSL_CA_File',
313
 
                      'Master_SSL_CA_Path',
314
 
                      'Master_SSL_Cert',
315
 
                      'Master_SSL_Cipher',
316
 
                      'Master_SSL_Key',
317
 
                      'Seconds_Behind_Master'
318
 
);
319
 
/**
320
 
  * define important variables, which need to be watched for correct running of replication in slave mode
321
 
  */
322
 
$slave_variables_alerts = array(
323
 
                            'Slave_IO_Running' => 'No',
324
 
                            'Slave_SQL_Running' => 'No'
325
 
                         );
326
 
$slave_variables_oks = array(
327
 
                            'Slave_IO_Running' => 'Yes',
328
 
                            'Slave_SQL_Running' => 'Yes'
329
 
                         );
330
260
/**
331
261
 * define some needfull links/commands
332
262
 */
339
269
    = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
340
270
      '&goto=server_status.php&' . PMA_generate_common_url();
341
271
 
342
 
$links['repl'][$strShowSlaveHosts]
 
272
if ($server_master_status) {
 
273
  $links['repl'][$strShowSlaveHosts]
343
274
    = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
344
275
      '&goto=server_status.php&' . PMA_generate_common_url();
345
 
$links['repl'][$strShowSlaveStatus]
346
 
    = 'sql.php?sql_query=' . urlencode('SHOW SLAVE STATUS') .
347
 
      '&goto=server_status.php&' . PMA_generate_common_url();
 
276
  $links['repl'][$strShowMasterStatus] = '#replication_master';
 
277
}
 
278
if ($server_slave_status) {
 
279
  $links['repl'][$strShowSlaveStatus] = '#replication_slave';
 
280
}
 
281
      
348
282
$links['repl']['doc'] = 'replication';
349
283
 
350
284
$links['qcache'][$strFlushQueryCache]
387
321
}
388
322
unset($name, $value, $filter, $section, $allocations);
389
323
 
390
 
// check which replication is available
391
 
foreach ($replication_types as $type)
392
 
{
393
 
  if (count(${"server_{$type}_status"}) > 0)
394
 
    ${"server_{$type}_status_run"} = true;
395
 
  else 
396
 
    ${"server_{$type}_status_run"} = false;
397
 
}
398
324
// rest
399
325
$sections['all']['vars'] =& $server_status;
400
326
 
423
349
</p>
424
350
 
425
351
<?php
426
 
if ($server_master_status_run || $server_slave_status_run) {
 
352
if ($server_master_status || $server_slave_status)
 
353
{
427
354
    $replicationOut = "";
428
 
    foreach ($replication_types as $type) {
429
 
        if (${"server_{$type}_status_run"}) {
430
 
            if ($replicationOut != "") {
 
355
    foreach ($replication_types as $type)
 
356
    {
 
357
        if (${"server_{$type}_status"})
 
358
        {
 
359
            if ($replicationOut != "")
431
360
                $replicationOut .= $strAndSmall . ' ';
432
 
            }
433
 
        $replicationOut .= '<b>' . $type . '</b> ';
 
361
            $replicationOut .= '<b>' . $type . '</b> ';
434
362
        }
435
363
    }
436
364
    echo sprintf('<p>' . $strReplicationStatusInfo . '</p>', $replicationOut);
589
517
 
590
518
<div id="serverstatusqueriesdetails">
591
519
<?php
 
520
 
 
521
$used_queries = $sections['com']['vars'];
 
522
// reverse sort by value to show most used statements first
 
523
arsort($used_queries);
 
524
// remove all zero values from the end
 
525
while (end($used_queries) == 0) {
 
526
    array_pop($used_queries);
 
527
}
 
528
 
592
529
// number of tables to split values into
593
 
$tables         = 2;
594
 
$rows_per_table = (int) ceil(count($sections['com']['vars']) / $tables);
 
530
$tables         = 3;
 
531
$max_rows_per_table = (int) ceil(count($used_queries) / $tables);
595
532
$current_table  = 0;
596
533
$odd_row        = true;
597
 
$countRows      = 0;
 
534
$count_displayed_rows      = 0;
598
535
$perc_factor    = 100 / ($server_status['Questions'] - $server_status['Connections']);
599
 
foreach ($sections['com']['vars'] as $name => $value) {
 
536
 
 
537
foreach ($used_queries as $name => $value) {
600
538
    $current_table++;
601
 
    if ($countRows === 0 || $countRows === $rows_per_table) {
 
539
    if ($count_displayed_rows === 0 || $count_displayed_rows === $max_rows_per_table) {
602
540
        $odd_row = true;
603
 
        if ($countRows === $rows_per_table) {
 
541
        if ($count_displayed_rows === $max_rows_per_table) {
604
542
            echo '    </tbody>' . "\n";
605
543
            echo '    </table>' . "\n";
 
544
            $count_displayed_rows = 0;
606
545
        }
607
546
?>
608
547
    <table id="serverstatusqueriesdetails<?php echo $current_table; ?>" class="data">
619
558
    } else {
620
559
        $odd_row = !$odd_row;
621
560
    }
622
 
    $countRows++;
 
561
    $count_displayed_rows++;
623
562
 
624
563
// For the percentage column, use Questions - Connections, because
625
564
// the number of connections is not an item of the Query types
631
570
            <th class="name"><?php echo htmlspecialchars($name); ?></th>
632
571
            <td class="value"><?php echo PMA_formatNumber($value, 4, 0); ?></td>
633
572
            <td class="value"><?php echo
634
 
                PMA_formatNumber($value * $hour_factor, 4, 2); ?></td>
 
573
                PMA_formatNumber($value * $hour_factor, 3, 3); ?></td>
635
574
            <td class="value"><?php echo
636
575
                PMA_formatNumber($value * $perc_factor, 0, 2); ?>%</td>
637
576
        </tr>
646
585
<?php
647
586
//Unset used variables
648
587
unset(
649
 
    $tables, $rows_per_table, $current_table, $countRows, $perc_factor,
 
588
    $tables, $max_rows_per_table, $current_table, $count_displayed_rows, $perc_factor,
650
589
    $hour_factor, $sections['com'],
651
590
    $server_status['Aborted_clients'], $server_status['Aborted_connects'],
652
591
    $server_status['Max_used_connections'], $server_status['Bytes_received'],
653
592
    $server_status['Bytes_sent'], $server_status['Connections'],
654
 
    $server_status['Questions'], $server_status['Uptime']
 
593
    $server_status['Questions'], $server_status['Uptime'],
 
594
    $used_queries
655
595
);
656
596
 
657
597
foreach ($sections as $section_name => $section) {
770
710
</div> 
771
711
<?php
772
712
/* if the server works as master or slave in replication process, display useful information */
773
 
if ($server_master_status_run || $server_slave_status_run)
 
713
if ($server_master_status || $server_slave_status)
774
714
{
775
 
  ?>
 
715
?>
776
716
  <hr class="clearfloat" />
777
717
 
778
718
  <h3><a name="replication"></a><?php echo $strReplicationStatus; ?></h3>
779
 
  <?php 
780
 
  
781
 
  foreach ($replication_types as $type)
782
 
  {
783
 
    if (${"server_{$type}_status_run"})
784
 
    {
785
 
    ?>
786
 
    <h4><?php echo ${"strReplicationStatus_{$type}"}; ?></h4>
787
 
    <?php 
788
 
    ?>
789
 
    <table id="server<?php echo $type; ?>replicationsummary" class="data"> 
790
 
    
791
 
    <thead>
792
 
    <tr>
793
 
        <th><?php echo $strVar; ?></th>
794
 
        <th><?php echo $strValue; ?></th>
795
 
    </tr>
796
 
    </thead>
797
 
    <tbody>
798
 
    <?php
799
 
    $odd_row = true;
800
 
    foreach(${"{$type}_variables"} as $variable)
801
 
    {
802
 
    ?>
803
 
    <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
804
 
      <td class="name">
805
 
        <?php echo $variable; ?>
806
 
      </td>
807
 
      <td class="value">
808
 
        <?php 
809
 
        if (isset(${"{$type}_variables_alerts"}[$variable])
810
 
            && ${"{$type}_variables_alerts"}[$variable] == ${"server_{$type}_status"}[0][$variable]) {
811
 
        echo '<span class="attention">';
 
719
<?php 
812
720
 
813
 
        } elseif (isset(${"{$type}_variables_oks"}[$variable])
814
 
            && ${"{$type}_variables_oks"}[$variable] == ${"server_{$type}_status"}[0][$variable]) {
815
 
            echo '<span class="allfine">';
816
 
        } else {
817
 
            echo '<span>';
818
 
        }
819
 
        echo ${"server_{$type}_status"}[0][$variable]; 
820
 
        echo '</span>';
821
 
        ?>
822
 
      </td>
823
 
    </tr>
824
 
    <?php
825
 
    $odd_row = ! $odd_row;
826
 
    }
827
 
    unset(${"server_{$type}_status"});
828
 
    ?>
829
 
    </tbody>
830
 
    </table>
831
 
    <?php
832
 
    }
833
 
  }
834
 
  unset($types);
 
721
    foreach ($replication_types as $type)
 
722
    {
 
723
        if (${"server_{$type}_status"}) {
 
724
            PMA_replication_print_status_table($type);
 
725
        }
 
726
    }
 
727
    unset($types);
835
728
}
836
729
?>
837
730