AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.124
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/server/mysql/mysql-test/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/server/mysql/mysql-test/t/dynamic_tracing.test
# This scripts checks dtrace probes provided by mysqld using real dtrace tool
# and systemtap.
--source include/not_windows.inc

--let OUTPUT_FILENAME= $MYSQLTEST_VARDIR/tmp/output.txt
--let MYSQLD_PIDFILE= `SELECT @@pid_file`
--let MYSQLD= $MYSQLD
--let SCRIPT_OUTPUT_FILE= $MYSQLTEST_VARDIR/tmp/script_output.txt

--perl
  my $pid_filename = $ENV{'MYSQLD_PIDFILE'};
  my $output_filename = $ENV{'OUTPUT_FILENAME'};
  my $mysqld = $ENV{'MYSQLD'};

  my $mysqld_pid = 0;
  my $dyn_trace_tool_available = 0;
  my $user_has_permissions = 0;
  my $mysqld_has_dtrace_probes = 0;
  my $command = "";
  my $ret;

# Check whether Dtrace tool exists or not. If exists then capture its output.
  $ret = `dtrace -V 2>&1`;
  if ($? == 0)
  {
    if (($ret =~ m/Sun D/) || ($ret =~ m/Oracle D/))
    {
      $dyn_trace_tool_available = 1;

      # Check whether user has Dtrace tool execution permission or not	
      $ret = `dtrace -v 2>&1`;
      if (!($ret =~ m/DTrace requires additional privileges/))		
      {
        $user_has_permissions = 1;

        $mysqld_pid= `cat $pid_filename`; 
        chomp($mysqld_pid); 		

        # Check whether MySQL Dtrace providers exists or not.
        $ret=`dtrace -l -p $mysqld_pid |
          egrep -ci \"net-read-done|connection-start|query-parse-start\"`;
        if ($ret != 0)
        {
          $mysqld_has_dtrace_probes = 1;
          $command = "dtrace -s \$MYSQL_TEST_DIR/std_data/dtrace.d ";
        }
      }
    }
  }
  else
  {
    # check whether stap tool exists or not.
    $ret= `stap 2>&1`;
    if ($ret == 0)
    {
      $dyn_trace_tool_available= 1;

      # Check whether user has permission to run stap.
      $ret= `stap -e 'probe process("ls").function("main") { exit() }'
             -c ls 2>&1|egrep -ic "You should be part of the group \"stapusr"`; 

      # Check whether user has permission to run staprun or not. 
      if ($ret == 0)
      {
        $ret= `staprun 2>&1|egrep -ic "Permission denied"`;
      }
      if ($ret == 0)
      {
        $user_has_permissions= 1;

        # Check whether MySQL stap markers are available or not.
        $ret= `stap -L 'process("$mysqld").mark("*")'|
          egrep -ci \"net__read__done|connection__start|query__parse__start\"`; 
          if ($ret != 0)
          {
            $mysqld_has_dtrace_probes = 1;
            $command= "stap \$MYSQL_TEST_DIR/std_data/system_tap.stp $mysqld ";
          }
      }
    }
  }

  # Write output to file.
  open(FILE, ">> $output_filename");
  print FILE "--let \$DYN_TRACE_TOOL_AVAILABLE= $dyn_trace_tool_available\n";
  print FILE "--let \$USER_HAS_PERMISSIONS= $user_has_permissions\n";
  print FILE "--let \$MYSQLD_HAS_DTRACE_PROBES= $mysqld_has_dtrace_probes\n";
  print FILE "--let COMMAND= $command\n";
  close(FILE);
EOF

source $OUTPUT_FILENAME;

if (!$DYN_TRACE_TOOL_AVAILABLE)
{
  --skip Real DTrace or System tap tool is required to run this test.
}

if (!$USER_HAS_PERMISSIONS)
{
  --skip dtrace/stap tool requires additional privileges to run this test.
}

if (!$MYSQLD_HAS_DTRACE_PROBES)
{
  --skip MySQLD does not have MySQL probes.
}

--disable_result_log
DELIMITER $;

CREATE PROCEDURE create_table_and_insert_rows()
BEGIN
  DECLARE count INT;
  SET count = 1;

  SELECT SLEEP(10);
  CREATE TABLE t1 (f1 INT);
  INSERT INTO t1 VALUES (7894);
  WHILE count <= 5 DO
    INSERT INTO t1 SELECT * FROM t1;
    SET count = count + 1;
  END WHILE;

  SET count = 1;
  WHILE count <= 10000 DO
    SELECT SQL_NO_CACHE count(*) from t1;
    SET count = count + 1;
  END WHILE;
END
$

DELIMITER ;$

# Running Dtrace script in background.
--perl
   system("$ENV{'COMMAND'} >$ENV{'SCRIPT_OUTPUT_FILE'} 2>&1 &"); 
EOF

CALL create_table_and_insert_rows();
# Waiting for few secs to allow Dtrace to write all trace output to file.
SELECT SLEEP(4);
--enable_result_log

# Dtrace output
--exec cat $SCRIPT_OUTPUT_FILE

# Cleanup
--remove_file $OUTPUT_FILENAME
--remove_file $SCRIPT_OUTPUT_FILE
DROP TABLE t1;
DROP PROCEDURE create_table_and_insert_rows;

Anon7 - 2022
AnonSec Team