echo "\tDaemon.php [options]\n"; echo "\n"; echo "\toptions:\n"; echo "\t\t--help display this help message\n"; echo "\t\t--log=<filename> The location of the log file (default in config.ini)\n"; echo "\t\t--env=(testing|producction)\n"; echo "\n"; } //end displayUsage() //configure command line arguments if (isset($argc) && $argc > 0) { foreach ($argv as $arg) { $args = explode('=', $arg); switch ($args[0]) { case '--help': return displayUsage(); case '--log': $log = $args[1]; break; case '--env': $env = $args[1]; break; } //end switch } //end foreach } //end if // load the classes from library $appPath = dirname(__FILE__); $basePath = str_ireplace('cron', '', $appPath);
* * @author Shkodenko V. Taras (taras -at- shkodenko.com) * @requires PHP 5.X * @requires MySQL 5.X * */ define('VERSION', '1.0'); // command line arguments; check below for usage $cmdArgs = getopt('h:u:p'); // connect to mysql database $dbHost = isset($cmdArgs['h']) ? $cmdArgs['h'] : ini_get("mysqli.default_host"); $dbUser = isset($cmdArgs['u']) ? $cmdArgs['u'] : ini_get("mysqli.default_user"); $dbPass = isset($cmdArgs['p']) ? $cmdArgs['p'] : ini_get("mysqli.default_pw"); // check args if (strlen($dbHost) <= 0 && strlen($dbUser) <= 0 && strlen($dbPass) <= 0) { displayUsage(); } // clean up password value from possible single quotes ' $dbPass = str_replace("'", "", $dbPass); // get variables $getMySQLVariables = 'mysql -h ' . $dbHost . ' -u ' . $dbUser . ' -p\'' . $dbPass . '\' -e "SHOW VARIABLES"'; echo __FILE__ . ' +' . __LINE__ . ' running command: ' . $getMySQLVariables . PHP_EOL; exec($getMySQLVariables, $aOut1, $resCmd1); // echo 'Command result: ' . var_export($resCmd1, 1) . PHP_EOL; // echo 'Command output: ' . var_export($aOut1, 1) . PHP_EOL; $fv = array(); if (is_array($aOut1) && count($aOut1)) { $i = 0; $searchKeys = array('key_buffer_size', 'query_cache_size', 'tmp_table_size', 'innodb_buffer_pool_size', 'innodb_additional_mem_pool_size', 'innodb_log_buffer_size', 'max_connections', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'); $cntSrch = count($searchKeys); foreach ($aOut1 as $v1) {