Files
cacti/scripts/ss_sql.php
T
netniV 89f0a06216 Resolving issue #2304 and #2311
This commit corrects a previous unseen issue where the PHP environment at command line level is being populated with environment variables normally only seen when called from a web server.

issue#2304: Installation progress stays at 0%
issue#2311: Unable to update PHP location during installation due to incorrect CLI environment

The new check uses the php_sapi_name() function to verify that we are indeed at 'cli' level.  All other values returned by php_sapi_name are considered non-cli including 'cli-server' which is for client/server scenarios.

Most checks have now been replaced by a single defintion ('CACTI_CLI') to define whether in CLI mode.  If a script is only to be called from CLI it must either defined 'CACTI_CLI_ONLY' or include include/cli_check.php instead of include/global.php.
2019-01-15 13:57:50 +00:00

36 lines
1011 B
PHP

<?php
/* do NOT run this script through a web browser */
$no_http_headers = true;
/* display no errors */
error_reporting(0);
if (!isset($called_by_script_server)) {
include_once(dirname(__FILE__) . '/../include/cli_check.php');
print call_user_func('ss_sql');
}
function ss_sql() {
global $database_username;
global $database_password;
global $database_hostname;
if ($database_password != '') {
$result = `mysqladmin --host=$database_hostname --user=$database_username --password=$database_password status`;
} else {
$result = `mysqladmin --host=$database_hostname --user=$database_username status`;
}
$result = preg_replace('/: /', ':', $result);
$result = preg_replace('/ /', ' ', $result);
$result = preg_replace('/Slow queries/', 'SlowQueries', $result);
$result = preg_replace('/Open tables/', 'OpenTables', $result);
$result = preg_replace('/Queries per second avg/', 'QPS', $result);
$result = preg_replace('/Flush tables/', 'FlushTables', $result);
return trim($result);
}