1 | <?php |
||
8 | class ZabbixGraph |
||
9 | { |
||
10 | protected $httpClient; |
||
11 | protected $oldZabbix; |
||
12 | protected $username; |
||
13 | protected $password; |
||
14 | |||
15 | protected $width = 400; |
||
16 | protected $height = 200; |
||
17 | protected $startTime; |
||
18 | protected $endTime; |
||
19 | |||
20 | /** |
||
21 | * Construct and initalize ZabbixGraph. |
||
22 | * |
||
23 | * @param string $url Full url of Zabbix location |
||
24 | * @param string $username Zabbix username |
||
25 | * @param string $password Zabbix password |
||
26 | * @param bool $oldZabbix Set to true if using Zabbix 1.8 or older, by default set to false |
||
27 | */ |
||
28 | 7 | public function __construct($url, $username, $password, $oldZabbix = false) |
|
38 | |||
39 | /** |
||
40 | * Create HTTP client for requesting the graph. The HTTP client should preserve cookies. |
||
41 | * |
||
42 | * @param string $url Full url of Zabbix location |
||
43 | * @return HttpClient |
||
44 | */ |
||
45 | 1 | protected function createHttpClient($url) |
|
52 | |||
53 | /** |
||
54 | * Request graph from Zabbix and return a raw image. If an error |
||
55 | * occurred Zabbix will output this as an image. |
||
56 | * |
||
57 | * @param int $graphId ID of the graph to be requested |
||
58 | * @return string |
||
59 | */ |
||
60 | 7 | public function find($graphId) |
|
74 | |||
75 | /** |
||
76 | * Login to Zabbix to acquire the needed session for requesting the graph. |
||
77 | */ |
||
78 | 7 | protected function login() |
|
88 | |||
89 | /** |
||
90 | * Specify width of the graph in pixels, by default 400. |
||
91 | * |
||
92 | * @param int $width Width in pixels |
||
93 | * @return $this |
||
94 | */ |
||
95 | 2 | public function width($width) |
|
101 | |||
102 | /** |
||
103 | * Specify height of the graph in pixels, by default 400. |
||
104 | * |
||
105 | * @param int $height Height in pixels |
||
106 | * @return $this |
||
107 | */ |
||
108 | 2 | public function height($height) |
|
114 | |||
115 | /** |
||
116 | * Specify start date and time of the data displayed in the graph. |
||
117 | * |
||
118 | * @param DateTime $startTime Start date and time |
||
119 | * @return $this |
||
120 | */ |
||
121 | 2 | public function startTime(DateTime $startTime) |
|
127 | |||
128 | /** |
||
129 | * Specify end date and time of the data displayed in the graph. |
||
130 | * |
||
131 | * @param DateTime $endTime End date and time |
||
132 | * @return $this |
||
133 | */ |
||
134 | 1 | public function endTime(DateTime $endTime) |
|
140 | } |
||
141 |