@@ -522,7 +522,7 @@ sub get_myawrrpt {
522
522
<tr><td>Innodb_rows_inserted(s):</td><td align=\" right\" >$sec_Innodb_rows_inserted </td></tr>
523
523
<tr><td>Innodb_rows_updated(s):</td><td align=\" right\" > $sec_Innodb_rows_updated </td></tr>
524
524
<tr><td>Innodb_rows_deleted(s):</td><td align=\" right\" > $sec_Innodb_rows_deleted </td></tr>
525
- <tr><td>Innodb_rows_read(/ s):</td><td align=\" right\" > $sec_Innodb_rows_read </td></tr>
525
+ <tr><td>Innodb_rows_read(s):</td><td align=\" right\" > $sec_Innodb_rows_read </td></tr>
526
526
527
527
<tr><td>Innodb_data_reads(s):</td><td align=\" right\" > $sec_Innodb_data_reads </td></tr>
528
528
<tr><td>Innodb_data_writes(s):</td><td align=\" right\" > $sec_Innodb_data_writes </td></tr>
@@ -632,6 +632,199 @@ sub get_myawrrpt {
632
632
}
633
633
$sql .=" $end_snap_id " ;
634
634
635
+
636
+ my $isfirst =1;
637
+ my $sinterval ;
638
+ my $insert_diff ;
639
+ my $update_diff ;
640
+ my $delete_diff ;
641
+ my $select_diff ;
642
+ my $read_request ;
643
+ my $read ;
644
+ my $innodb_rows_inserted_diff ;
645
+ my $innodb_rows_updated_diff ;
646
+ my $innodb_rows_deleted_diff ;
647
+ my $innodb_rows_read_diff ;
648
+ my $innodb_os_log_fsyncs_diff ;
649
+ my $innodb_os_log_written_diff ;
650
+ my $stps ;
651
+ my $shits ;
652
+
653
+ my ($pre_snap_time ,$pre_unix_s ,$pre_Innodb_rows_inserted ,$pre_Innodb_rows_updated ,$pre_Innodb_rows_deleted ,$pre_Innodb_rows_read ,$pre_Innodb_buffer_pool_read_requests ,$pre_Innodb_buffer_pool_reads ,$pre_Innodb_os_log_fsyncs ,$pre_Innodb_os_log_written ,$pre_Com_select ,$pre_Com_delete ,$pre_Com_insert ,$pre_Com_update );
654
+
655
+ $sth = $dbh -> prepare(" select a.snap_time,UNIX_TIMESTAMP(a.snap_time) unix_s ,a.Innodb_rows_inserted,a.Innodb_rows_updated,a.Innodb_rows_deleted,a.Innodb_rows_read,a.Innodb_buffer_pool_read_requests,a.Innodb_buffer_pool_reads,a.Innodb_os_log_fsyncs,a.Innodb_os_log_written, b.Com_select,b.Com_delete,b.Com_insert,b.Com_update ,b.Threads_running from myawr_innodb_info a,myawr_mysql_info b where a.host_id=b.host_id and a.snap_id=b.snap_id and a.host_id=$tid and a.snap_id in ($sql ) and a.snap_time between \" $start_snap_time \" and \" $end_snap_time \" " );
656
+ $sth -> execute();
657
+
658
+ print MYAWR_REPORT " <p /><h3>Innodb activity(1)</h3><p /><table border=\" 1\" > <tr><th>Snap Time</th><th>Com_ins</th><th>Com_upd</th><th>Com_del</th><th>Com_sel</th><th>TPS</th><th>Buf_read_req</th><th>Hit%</th><th>Innodb_rows_ins</th><th>Innodb_rows_upd</th><th>Innodb_rows_del</th><th>Innodb_rows_read</th><th>Innodb_log_fsyncs</th><th>Innodb_log_wrn(k/s)</th><th>Threads_running</th></tr>" ;
659
+
660
+ while ( my @result = $sth -> fetchrow_array ){
661
+ if ($isfirst ==1){
662
+ $pre_snap_time =$result [0];
663
+ $pre_unix_s =$result [1];
664
+ $pre_Innodb_rows_inserted =$result [2];
665
+ $pre_Innodb_rows_updated =$result [3];
666
+ $pre_Innodb_rows_deleted =$result [4];
667
+ $pre_Innodb_rows_read =$result [5];
668
+ $pre_Innodb_buffer_pool_read_requests =$result [6];
669
+ $pre_Innodb_buffer_pool_reads =$result [7];
670
+ $pre_Innodb_os_log_fsyncs =$result [8];
671
+ $pre_Innodb_os_log_written =$result [9];
672
+ $pre_Com_select =$result [10];
673
+ $pre_Com_delete =$result [11];
674
+ $pre_Com_insert =$result [12];
675
+ $pre_Com_update =$result [13];
676
+
677
+ $isfirst =0;
678
+ }else {
679
+ $sinterval =$result [1]-$pre_unix_s ;
680
+ if ($sinterval >0){
681
+
682
+ $select_diff = int (($result [10]-$pre_Com_select ) / $sinterval );
683
+ $delete_diff =int ( ($result [11]-$pre_Com_delete ) / $sinterval );
684
+ $insert_diff = int (($result [12]-$pre_Com_insert ) / $sinterval );
685
+ $update_diff = int (($result [13]-$pre_Com_update ) / $sinterval );
686
+ $stps =$insert_diff +$update_diff +$delete_diff ;
687
+
688
+ $read_request = int (($result [6]-$pre_Innodb_buffer_pool_read_requests ) / $sinterval );
689
+ $read = int (($result [7]-$pre_Innodb_buffer_pool_reads ) / $sinterval );
690
+
691
+ if ($read_request >0) {
692
+ $shits = int (($read_request -$read )/$read_request *10000)/100;
693
+ }
694
+
695
+ $innodb_rows_inserted_diff = int (($result [2]-$pre_Innodb_rows_inserted ) / $sinterval );
696
+ $innodb_rows_updated_diff = int (($result [3]-$pre_Innodb_rows_updated ) / $sinterval );
697
+ $innodb_rows_deleted_diff = int (($result [4]-$pre_Innodb_rows_deleted ) / $sinterval );
698
+ $innodb_rows_read_diff = int (($result [5]-$pre_Innodb_rows_read ) / $sinterval );
699
+
700
+ $innodb_os_log_fsyncs_diff = int (($result [8]- $pre_Innodb_os_log_fsyncs ) / $sinterval );
701
+ $innodb_os_log_written_diff = int (($result [9]-$pre_Innodb_os_log_written ) / $sinterval /1024);
702
+
703
+ print MYAWR_REPORT " <tr><td>$result [0]</td><td align=\" right\" >$insert_diff </td><td align=\" right\" >$update_diff </td><td>$delete_diff </td><td>$select_diff </td><td>$stps </td><td>$read_request </td><td>$shits </td><td>$innodb_rows_inserted_diff </td><td>$innodb_rows_updated_diff </td><td>$innodb_rows_deleted_diff </td><td>$innodb_rows_read_diff </td><td>$innodb_os_log_fsyncs_diff </td><td>$innodb_os_log_written_diff </td><td>$result [14]</td></tr>" ;
704
+ print MYAWR_REPORT " \n " ;
705
+ }
706
+ $pre_snap_time =$result [0];
707
+ $pre_unix_s =$result [1];
708
+ $pre_Innodb_rows_inserted =$result [2];
709
+ $pre_Innodb_rows_updated =$result [3];
710
+ $pre_Innodb_rows_deleted =$result [4];
711
+ $pre_Innodb_rows_read =$result [5];
712
+ $pre_Innodb_buffer_pool_read_requests =$result [6];
713
+ $pre_Innodb_buffer_pool_reads =$result [7];
714
+ $pre_Innodb_os_log_fsyncs =$result [8];
715
+ $pre_Innodb_os_log_written =$result [9];
716
+ $pre_Com_select =$result [10];
717
+ $pre_Com_delete =$result [11];
718
+ $pre_Com_insert =$result [12];
719
+ $pre_Com_update =$result [13];
720
+ }
721
+
722
+ }
723
+ print MYAWR_REPORT " </table><p /><p />" ;
724
+
725
+
726
+
727
+ my $innodb_bp_pages_flushed_diff ;
728
+ my $innodb_data_reads_diff ;
729
+ my $innodb_data_writes_diff ;
730
+ my $innodb_data_read_diff ;
731
+ my $innodb_data_written_diff ;
732
+ my $unflushed_log ;
733
+ my $uncheckpointed_bytes ;
734
+
735
+ my ($pre_Innodb_buffer_pool_pages_data ,$pre_Innodb_buffer_pool_pages_free ,$pre_Innodb_buffer_pool_pages_dirty ,$pre_Innodb_buffer_pool_pages_flushed ,$pre_Innodb_data_reads ,$pre_Innodb_data_writes ,$pre_Innodb_data_read ,$pre_Innodb_data_written ,$pre_history_list ,$pre_log_bytes_written ,$pre_log_bytes_flushed ,$pre_last_checkpoint ,$pre_queries_inside ,$pre_queries_queued ,$pre_read_views );
736
+
737
+ $isfirst =1;
738
+
739
+
740
+ $sth = $dbh -> prepare(" select a.snap_time,UNIX_TIMESTAMP(a.snap_time) unix_s,Innodb_buffer_pool_pages_data,Innodb_buffer_pool_pages_free,Innodb_buffer_pool_pages_dirty,Innodb_buffer_pool_pages_flushed,Innodb_data_reads,Innodb_data_writes,Innodb_data_read,Innodb_data_written,history_list,log_bytes_written,log_bytes_flushed,last_checkpoint,queries_inside,queries_queued,read_views from myawr_innodb_info a where a.host_id=$tid and a.snap_id in ($sql ) and a.snap_time between \" $start_snap_time \" and \" $end_snap_time \" " );
741
+ $sth -> execute();
742
+
743
+ print MYAWR_REPORT " <p /><h3>Innodb activity(2)</h3><p /><table border=\" 1\" > <tr><th>Snap Time</th><th>Indb_pdata</th><th>Indb_pfree</th><th>Indb_pdirty</th><th>Indb_pflush</th><th>Indb_dreads</th><th>Indb_dwrites</th><th>Indb_dread(k/s)</th><th>Indb_dwritten(k/s)</th><th>his_list</th><th>Inlog_uflush</th><th>Inlog_uckpt</th><th>queries_inside</th><th>queries_queued</th><th>read_views</th></tr>" ;
744
+
745
+ while ( my @result = $sth -> fetchrow_array ){
746
+ if ($isfirst ==1){
747
+ $pre_snap_time =$result [0];
748
+ $pre_unix_s =$result [1];
749
+
750
+ $pre_Innodb_buffer_pool_pages_data =$result [2];
751
+ $pre_Innodb_buffer_pool_pages_free =$result [3];
752
+ $pre_Innodb_buffer_pool_pages_dirty =$result [4];
753
+ $pre_Innodb_buffer_pool_pages_flushed =$result [5];
754
+
755
+ $pre_Innodb_data_reads =$result [6];
756
+ $pre_Innodb_data_writes =$result [7];
757
+ $pre_Innodb_data_read =$result [8];
758
+ $pre_Innodb_data_written =$result [9];
759
+ $pre_history_list =$result [10];
760
+ $pre_log_bytes_written =$result [11];
761
+ $pre_log_bytes_flushed =$result [12];
762
+ $pre_last_checkpoint =$result [13];
763
+
764
+ $pre_queries_inside =$result [14];
765
+ $pre_queries_queued =$result [15];
766
+ $pre_read_views =$result [16];
767
+
768
+ $isfirst =0;
769
+ }else {
770
+ $sinterval =$result [1]-$pre_unix_s ;
771
+ if ($sinterval >0){
772
+
773
+ $innodb_bp_pages_flushed_diff =int (($result [5]-$pre_Innodb_buffer_pool_pages_flushed )/$sinterval );
774
+ $innodb_data_reads_diff =int (($result [6]-$pre_Innodb_data_reads )/$sinterval ) ;
775
+ $innodb_data_writes_diff =int (($result [7]-$pre_Innodb_data_writes )/$sinterval );
776
+ $innodb_data_read_diff =int (($result [8]-$pre_Innodb_data_read )/$sinterval /1024);
777
+ $innodb_data_written_diff =int (($result [9]-$pre_Innodb_data_written )/$sinterval /1024);
778
+ $unflushed_log =int (($result [11]-$result [12])/$sinterval /1024);
779
+ $uncheckpointed_bytes =int (($result [11]-$result [13])/$sinterval /1024);
780
+
781
+
782
+ print MYAWR_REPORT " <tr><td>$result [0]</td><td align=\" right\" >$result [2]</td><td align=\" right\" >$result [3]</td><td>$result [4]</td><td>$innodb_bp_pages_flushed_diff </td><td>$innodb_data_reads_diff </td><td>$innodb_data_writes_diff </td><td>$innodb_data_read_diff </td><td>$innodb_data_written_diff </td><td>$result [10]</td><td>$unflushed_log </td><td>$uncheckpointed_bytes </td><td>$result [14]</td><td>$result [15]</td><td>$result [16]</td></tr>" ;
783
+ print MYAWR_REPORT " \n " ;
784
+
785
+ }
786
+
787
+ $pre_snap_time =$result [0];
788
+ $pre_unix_s =$result [1];
789
+
790
+ $pre_Innodb_buffer_pool_pages_data =$result [2];
791
+ $pre_Innodb_buffer_pool_pages_free =$result [3];
792
+ $pre_Innodb_buffer_pool_pages_dirty =$result [4];
793
+ $pre_Innodb_buffer_pool_pages_flushed =$result [5];
794
+
795
+ $pre_Innodb_data_reads =$result [6];
796
+ $pre_Innodb_data_writes =$result [7];
797
+ $pre_Innodb_data_read =$result [8];
798
+ $pre_Innodb_data_written =$result [9];
799
+ $pre_history_list =$result [10];
800
+ $pre_log_bytes_written =$result [11];
801
+ $pre_log_bytes_flushed =$result [12];
802
+ $pre_last_checkpoint =$result [13];
803
+
804
+ $pre_queries_inside =$result [14];
805
+ $pre_queries_queued =$result [15];
806
+ $pre_read_views =$result [16];
807
+
808
+ }
809
+
810
+ }
811
+ print MYAWR_REPORT " </table><p /><hr/><p />" ;
812
+
813
+
814
+
815
+ $sth = $dbh -> prepare(" select a.snap_id,a.snap_time,a.cpu_user,a.cpu_system,a.cpu_idle,a.cpu_iowait,b.load1,b.load5,d.Threads_connected,d.Threads_running,(select count(1) from myawr_innodb_lock_waits e where a.host_id=e.host_id and a.snap_id=e.snap_id ) lock_waits from myawr_cpu_info a,myawr_load_info b,(select host_id,snap_id,snap_time from myawr_engine_innodb_status where host_id=$tid and snap_id BETWEEN $start_snap_id and $end_snap_id and snap_time between \" $start_snap_time \" and \" $end_snap_time \" group by host_id,snap_id,snap_time) c,myawr_mysql_info d where a.host_id=b.host_id and a.host_id=c.host_id and a.host_id=d.host_id and a.snap_id=b.snap_id and a.snap_id=c.snap_id and a.snap_id=d.snap_id " );
816
+ $sth -> execute();
817
+
818
+ print MYAWR_REPORT " <p /><h3>MySql peak point Info(you can use myawrsrpt to generate a snap report)</h3><p /><table border=\" 1\" > <tr><th>Snap ID</th><th>Snap Time</th><th>user</th><th>system</th><th>idle</th><th>iowait</th> <th>load1</th><th>load5</th> <th>Threads_connected</th><th>Threads_running</th><th>lock_waits</th> </tr>" ;
819
+
820
+ while ( my @result = $sth -> fetchrow_array ) {
821
+ print MYAWR_REPORT " <tr><td>$result [0]</td><td align=\" right\" >$result [1]</td><td align=\" right\" >$result [2]</td><td>$result [3]</td><td>$result [4]</td><td>$result [5]</td><td align=\" right\" >$result [6]</td><td align=\" right\" >$result [7]</td><td>$result [8]</td><td>$result [9]</td><td>$result [10]</td></tr>" ;
822
+ print MYAWR_REPORT " \n " ;
823
+ }
824
+ print MYAWR_REPORT " </table><p /><hr/><p />" ;
825
+ print MYAWR_REPORT " \n " ;
826
+
827
+
635
828
$sth = $dbh -> prepare(" SELECT a.snap_time,a.load1,a.load5,a.load15 from myawr_load_info a WHERE a.host_id=$tid and a.snap_id in ($sql ) and a.snap_time between \" $start_snap_time \" and \" $end_snap_time \" " );
636
829
$sth -> execute();
637
830
0 commit comments