forked from Cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.php
More file actions
25 lines (17 loc) · 660 Bytes
/
sql.php
File metadata and controls
25 lines (17 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
error_reporting(0);
include(dirname(__FILE__) . '/../include/cli_check.php');
global $database_hostname, $database_username, $database_password;
$cmd = 'mysqladmin -h ' . cacti_escapeshellarg($database_hostname) . ' -u ' . cacti_escapeshellarg($database_username);
if ($database_password != '') {
$cmd .= ' -p' . cacti_escapeshellarg($database_password);
}
$cmd .= ' status';
$output = shell_exec($cmd);
if ($output === null || $output === '') {
print 'U';
} else {
// Extract the 6th field (Queries per second avg), matching original awk '{print $6}'
$parts = preg_split('/\s+/', trim($output));
print isset($parts[5]) ? $parts[5] : 'U';
}