-
Notifications
You must be signed in to change notification settings - Fork 56
/
db_connect_graph_getdata.php
55 lines (44 loc) · 1.32 KB
/
db_connect_graph_getdata.php
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
function index($arr1,$arr2,$arr3,$arr4){
ini_set('date.timezone','Asia/Shanghai');
/*
$ip = $_GET['ip'];
$dbname = $_GET['dbname'];
$port = $_GET['port'];
*/
$ip = $arr1;
$dbname = $arr2;
$port = $arr3;
$interval_time = $arr4;
require 'conn.php';
$get_info="select create_time,threads_connected from mysql_status_history where host='${ip}' and dbname='${dbname}' and port=${port} and
create_time >=${interval_time} AND create_time <=NOW() group by FLOOR(UNIX_TIMESTAMP(create_time)/60)";
$result1 = mysqli_query($con,$get_info);
//echo $get_info;
$array= array();
class Connections{
public $create_time;
public $threads_connected;
}
while($row = mysqli_fetch_array($result1,MYSQLI_ASSOC)){
$cons=new Connections();
$cons->create_time = $row['create_time'];
//$user->user_max = $row['user_max'];
$cons->threads_connected = $row['threads_connected'];
$array[]=$cons;
}
$top_data=json_encode($array);
// echo "{".'"user"'.":".$data."}";
echo $top_data;
}
/*$fn = isset($_GET['fn']) ? $_GET['fn'] : 'main';
if (function_exists($fn)) {
call_user_func($fn);
}
*/
$ip = $_GET['ip'];
$dbname = $_GET['dbname'];
$port = $_GET['port'];
$interval_time = $_GET['interval_time'];
index($ip,$dbname,$port,$interval_time);
?>