-
Notifications
You must be signed in to change notification settings - Fork 44
/
StatisticsSystemLoad.php
70 lines (58 loc) · 1.78 KB
/
StatisticsSystemLoad.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
class GraphRenderer_StatisticsSystemLoad extends GraphRenderer_AbstractTicker {
var $prefix;
/**
* @param $prefix "" or "db_"
*/
public function __construct($prefix) {
parent::__construct();
$this->prefix = $prefix;
}
public function getTitle() {
switch ($this->prefix) {
case "":
return ct("System load (hours)");
case "db_":
return ct("Database system load (hours)");
default:
throw new GraphException("Unknown prefix " . $this->prefix);
}
}
/**
* @return an array of columns e.g. (type, title, args)
*/
function getTickerColumns() {
$columns = array();
$columns[] = array('type' => 'number', 'title' => ct("1 min"), 'min' => 0, 'max' => 5);
$columns[] = array('type' => 'number', 'title' => ct("5 min"), 'min' => 0, 'max' => 5);
$columns[] = array('type' => 'number', 'title' => ct("15 min"), 'min' => 0, 'max' => 5);
return $columns;
}
/**
* The sources must return 'created_at' column as well, for last_updated
* @return an array of queries e.g. (query, key = created_at/data_date)
*/
function getTickerSources($days, $extra_days) {
return array(
array('query' => "SELECT * FROM site_statistics
ORDER BY created_at DESC LIMIT " . ($days + $extra_days), 'key' => 'created_at'),
);
}
/**
* @return an array of arguments passed to each {@link #getTickerSources()}
*/
function getTickerArgs() {
return array();
}
/**
* @return an array of 1..2 values of the values for the particular row,
* maybe formatted with {@link #graph_number_format()}.
*/
function getTickerData($row) {
return array(
graph_number_format($row[$this->prefix . 'system_load_1min']),
graph_number_format($row[$this->prefix . 'system_load_5min']),
graph_number_format($row[$this->prefix . 'system_load_15min']),
);
}
}